Upload text file to database

I need the user to select a chemical and supplier and the file to upload.
Then I want the file to be inserted into the MSDS table where the MSDS record relates to the chemical and supplier.
Any help would be great thanks,
Dan.

Hi Kamal,
Thanks for replying - would really appreciate any help. I'm working with Dan on this one.
I'm not sure what you mean by application interface. We have a PL/SQL http frontend that everything (including the upload and view) will be run through. What we want to be able to do is to upload a txt files to a blob.
Thanks again for any help!
Niall

Similar Messages

  • How to extract data from  text file to database table

    Hi ,
    I am trying to upload  data in text file to database table  using GUI_UPLOAD function .what would be the program for that.
    thanks in advance.

    Hi,
    I don't think you have a standard sap program to upload data from file to database table...
    Instead you can create a custom program like this..
    DATA: T_FILEDATA(1000) OCCURS 0 WITH HEADER LINE.
    DATA: T_ZTABLE LIKE ZTABLE OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = 'C:\TEST.TXT'
      tables
        data_tab                      = T_FILEDATA
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_READ_ERROR               = 2
       NO_BATCH                      = 3
       GUI_REFUSE_FILETRANSFER       = 4
       INVALID_TYPE                  = 5
       NO_AUTHORITY                  = 6
       UNKNOWN_ERROR                 = 7
       BAD_DATA_FORMAT               = 8
       HEADER_NOT_ALLOWED            = 9
       SEPARATOR_NOT_ALLOWED         = 10
       HEADER_TOO_LONG               = 11
       UNKNOWN_DP_ERROR              = 12
       ACCESS_DENIED                 = 13
       DP_OUT_OF_MEMORY              = 14
       DISK_FULL                     = 15
       DP_TIMEOUT                    = 16
       OTHERS                        = 17
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT T_FILEDATA.
      T_ZTABLE = T_FILEDATA.
      APPEND T_ZTABLE.
    ENDLOOP.
    MODIFY ZTABLE FROM TABLE T_ZTABLE.
    COMMIT WORK..
    Thanks,
    Naren

  • Upload .txt file to database in coldfusion

    Hi i need to know how  to upload text file in to database using coldfusion and the file does not have any column names. Can anyone help me in this.
    The sample of data in file is:
    00012009032216001111039289000005.9900100000000000000.00

    You can start by using list functions.  After uploading and reading the file, you can treat the resulting variable as a list delimited by chr(10) & chr(13).  As far as processing each line goes, you have to know it's structure.

  • Help needed in reading text file to database table

    Hello experts,
    i have to insert the values from the column of this text file and insert them in my database table.
    I have done a few file to table insertions but i'm having some trouble with this one.
    Any suggestions plz
    thanks
    liab_report      1.00                                                                                                                              Page: 1
    CDC:00537 / Mon Jun-21-2010                           LIABILITY REPORT                               Mon Jun-21-2010 22:06:26
    DRAW    1; SET    1;  November 7, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         701040.00          0.00     660146.00          0.00      40894.00    0.00          0.00
        Div3        1444128.00          0.00    1330056.00          0.00     114072.00    0.00          0.00
        Div4        4711900.00          0.00    3889700.00          0.00     822200.00    0.00          0.00
                    6857068.00          0.00    5879902.00          0.00     977166.00    0.00          0.00
    DRAW    2; SET    1;  November 14, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         817817.00          0.00     817817.00          0.00          0.00    0.00          0.00
        Div3        1687405.00          0.00    1611742.00          0.00      75663.00    0.00          0.00
        Div4        3402100.00          0.00    3034200.00          0.00     367900.00    0.00          0.00
                    5907322.00          0.00    5463759.00          0.00     443563.00    0.00          0.00
    DRAW    3; SET    1;  November 21, 2009
                         TOTAL       PAID ON         TOTAL    EXPIRED ON         TOTAL    FRAC   OUTSTANDING
                       WINNERS      06/21/10          PAID      06/21/10       EXPIRED   ROUND
      DIVISION          AMOUNT        AMOUNT        AMOUNT        AMOUNT        AMOUNT  AMOUNT        AMOUNT
        Div1              0.00          0.00          0.00          0.00          0.00    0.00          0.00
        Div2         779933.00          0.00     769804.00          0.00      10129.00    0.00          0.00
        Div3        1605548.00          0.00    1525104.00          0.00      80444.00    0.00          0.00
        Div4        4891700.00          0.00    4256800.00          0.00     634000.00    0.00        900.00
                    7277181.00          0.00    6551708.00          0.00     724573.00    0.00        900.00

    Plz clarify whether u want to load text file as a file into database or value of this text file into database. If values are to be loaded from this text file, U can better format the text file and use SQL loader to load the file into database. By formatting the database, i mean remove the unnecessary headings and characters, kee only the values to be loaded idelimited by ' '(space) or ','(comma). Create a control file and load it into the target table.

  • Upload text file to oracle table with checking and aggregation

    Hi Friends,
    I am new to ODI.  I have encountered a problem which is specific to ODI 11G (11.1.1.6.3) to upload text file to oracle table with checking and aggregation.  Would you please teach me how to implement the following requirement in ODI 11G?
    Input text file a:
    staffCode, staffCat, status, data
    input text file b:
    staffCodeStart, staffCodeEnd, staffCat
    temp output oracle table c:
    staffCat, data
    output oracle table d:
    staffCat, data
    order:
    a.staffCode, a.staffCat, a.status
    filter:
    a.status = ‘active’
    join:
    a left outerjoin b on a.staffCode between b.staffCodeStart and b.staffCodeEnd
    insert temp table c:
    c.staffCat = if b.staffCat is not null then b.staffCat else a.staffCat
    c.data = a.data
    insert table d:
    if c.staffCat between 99 and 1000 then d.staffCat = c.staffCat, d.data = sum(c.data)
    else d.staffCat = c.staffCat, d.data = LAST(c.data)
    Any help on fixing this is highly appreciated. Thanks!!
    Thanks,
    Chris

    Dear Santy,
    Many thanks for your prompt reply.  May I have more information about the LAST or SUM step?
    I was successful to create and run the following interfaces p and q
    1. Drag text file a to a newly created interface panel p
    2. Filter text file a : a.status = ‘active’
    3. Lookup text file a to text file b : a.staffCode between b.staffCodeStart and b.staffCodeEnd
    4. Drag oracle temp table c to interface panel p
    5. Set c.staffCat : CASE WHEN b.staffCat IS NULL THEN a.staffCat ELSE b.staffCat END
    6. Set c.data : a.data
    7. Drag oracle temp table c to a newly created interface panel q
    8. Drag oracle table d to interface panel q
    9. Set UK to d.staffCat
    10. Set Distinct Rows to table d
    11. Set d.staffCat = c.staffCat
    12. Set d.data = SUM(c.data)
    However, the interface q should be more than that:
    If c.staffCat is between 99 and 1000, then d.data = the last record c.data; else d.data = sum(c.data)
    Would you please teach me how to do the LAST or SUM steps?  Moreover, can interface p and interface q be combined to one interface and do not use the temp table c?  Millions thanks!
    Regards,
    Chris

  • Reading Text file or Database efficiently

    Hi.
    I have an option to read EMP names randomly from either text file or database . Can anyone tell me which one will be fast. I have to read more than 5000 names dynamically for my application and pick one name randomly.
    Many thanks, Ravi

    Hi quitte ,
    Thanks for replying. I just want to pick names randomly from file or database to name each and every customer in my application dynamically.
    For this, I created one table with Unique names and would like to design a code such that each customers will be named dynamically.
    Any Suggestions or Advise?
    Ravi

  • Upload text files with non-english characters

    I use an Apex page to upload text files. Then i retrieve the contents of files from wwv_flow_files.blob_content and convert them to varchar2 with utl_raw.cast_to_varchar2, but characters like ò, à, ù become garbage.
    What could be the problem? Are characters lost when files are stored in wwv_flow_files or when i do the conversion?
    Some other info:
    * I see wwv_flow_files.DAD_CHARSET is set to "ascii", wwv_flow_files.FILE_CHARSET is null.
    * Trying utl_raw.cast_to_varchar2( utl_raw.cast_to_raw('àòèù') ) returns 'àòèù' correctly;
    * NLS_CHARACTERSET parameter is AL32UTF8 (not just english ASCII)

    Hi
    Have a look at csv upload -- suggestion needed with non-English character in csv file it might help you.
    Thanks,
    Manish

  • How to upload binary file in database?

    Using servlets..how to upload binary file into database...
    How to get the data of file in servlet...
    Please reply...i'm unable to find exact code...that i want..

    You need to do two separate parts: accept the file from a HTTP multi-part POST and then stream it into a BLOB on the database. To do the former, download Jakarta Commons FileUpload. There is extensive documentation on how to write a simple handler for the upload. You then need to send the data to a BLOB. The specifics vary from database to database but generally you will insert or update a row with an empty blob, get a reference to the blob, pipe the data and then commit.
    If you do a quick forum search, this question has been asked (and answered) dozens of times. Some of the replies may even have code for you. Best of luck.
    - Saish

  • How to upload a file to database in Apex 4.2.2?

    How to upload a file to database in Apex 4.2.2 in Existing Application? Also How to view the uploaded file within this application?
    Any help to his question is very appreciated?
    Thanks,
    Prak.

    980835 wrote:
    Please update your forum profile with a real handle instead of "980835".
    Actually we want to upload the file to our own table and retrive from it as well. Is it possible to see the file of person whom we are pulling?
    This is covered in the documentation: About BLOB Support in Forms and Reports. There's also a tutorial in the Oracle Learning Library.

  • Uploaded text file has a new line added at the top using BSP MVC applicatio

    I have a BSP MVC application that uploads data on to the application server. When I open the uploaded text file, the very first line on the file looks like the line below. ->
    htmlb:button:click:nullhtmlb_form_1UploadUpload0htmlbdfsdf
    But the rest of the file looks okay. This is causing other than .txt files to get corrupted.
    Here is the code from my DO_HANDLE_EVENT.
    data: entity   type ref to if_http_entity,
          name     type string,
          content  type xstring,
          content_type type string,
          idx      type i value 1,
          v_root(26) value '
    houappl131\SRM_Download\',
          v_unxfile(100),
          v_transfer type xstring,
          v_type(6),
          v_len type i,
          v_dirfile type zfileinfo,
          v_ofile(80),
          v_guid type guid_32.
      class cl_htmlb_manager definition load.
      data:        v_asn(10) type n.
      data: fu        type ref to cl_htmlb_fileupload,
                       file_id   type string value 'batchfile'.
      data: o_page_context type ref to if_bsp_page_context.
      data: parent type ref to cl_bsp_controller2,
            lo_model                       type ref to cl_sus_m_asn_detail.
      o_page_context = me->get_page_context( ).
      cl_htmlb_manager=>dispatch_event_ex( request = request
      page_context = o_page_context
      event_handler = me ).
      refresh z_batch->message.
      if htmlb_event->server_event = 'Upload'.
        fu ?= cl_htmlb_manager=>get_data( request = request id = file_id name
                                             = 'fileUpload' ).
        if fu->file_name gt space.
              z_batch->parameters-fpath = fu->file_name.
              v_len = strlen( z_batch->parameters-fpath ).
              if v_len gt 4.
                v_len = v_len - 3.
              endif.
              v_type = z_batch->parameters-fpath+v_len(3).
              search z_batch->parameters-fpath for '.'.
              if sy-fdpos gt 0 and v_len gt 0.
                v_len = v_len - sy-fdpos.
                v_type = z_batch->parameters-fpath+sy-fdpos(v_len).
              endif.
              clear v_asn.
              v_asn = z_batch->parameters-asnhdr.
              concatenate v_asn
                          z_batch->parameters-asnitem
                          z_batch->parameters-batch
                          v_type
                          into v_unxfile separated by '.'.
              concatenate v_root v_unxfile into v_unxfile.
              condense v_unxfile no-gaps.
              open dataset v_unxfile for output in binary mode.
                while idx <= request->num_multiparts( ).
                  entity = request->get_multipart( idx ).
                  name = fu->file_name .
                  if name is not initial.
                    content_type = entity->get_header_field( 'Content-Type' ).
                    clear content.
                    content      = entity->get_data( ).
                    v_transfer = content.
                    transfer content to v_unxfile.
                    append content to z_batch->filetab.
                  endif.
                  idx = idx + 1.
                endwhile.
                close dataset v_unxfile.
            endif.
      endif.
    Here is my fileupload button in the view
    <htmlb:page title="File Upload " >
        <htmlb:form method       = "post"
                    encodingType = "multipart/form-data" >
          <htmlb:label id     = "Batchnum"
                       design = "Label"
                       for    = "Batchnumber"
                       text   = "Batch" />
          <htmlb:inputField id    = "Batchinput"
                            value = "//zbatch/parameters.batch" />
          <htmlb:fileUpload id="batchfile" />
          <htmlb:button id      = "Upload"
                        text    = "Upload"
                        onClick = "Upload" />
          <htmlb:button id      = "Close"
                        text    = "Close window"
                        onClick = "Close" />
    Any of you gurus know why this is happening?

    I solved it myself

  • How to upload text file

    hi
    i want to create BDC program for the data uploding.. but i dont hv much knwloadge of about it. i need to sample code the data upload program. i hv to upload text file format. im using gui_upload funtion  if u hv any sample plz send me it plz... thnx
    regad
    nawa

    Check the following code:
    Selection screen :
    SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-020.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .
    PARAMETERS: p_locl  RADIOBUTTON GROUP g1                   " desktop file
                        DEFAULT 'X' USER-COMMAND fil,
                p_phys  RADIOBUTTON GROUP g1.                  " appln server file
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 .
    PARAMETERS: p_ifile  TYPE   dxfile-filename LOWER CASE,       " source file
                p_afile  TYPE   dxfile-filename LOWER CASE,       " asset class file
                p_cfile  TYPE   dxfile-filename LOWER CASE,       " Cost center file
                p_dfile  TYPE   dxfile-filename LOWER CASE,       " Depr key  file
                p_ofile  TYPE   dxfile-filename LOWER CASE.       " Audit file
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-015.
    PARAMETERS: p_test RADIOBUTTON GROUP g2 DEFAULT 'X',        " test run
                p_create RADIOBUTTON GROUP g2.                  " data migretion
    SELECTION-SCREEN END OF BLOCK b3.
    SELECTION-SCREEN END OF BLOCK b4.
    Main program :
    REPORT  zfaac900
            LINE-SIZE 132
            LINE-COUNT 65
            NO STANDARD PAGE HEADING
            MESSAGE-ID ZFAA.
    * includes
    INCLUDE: zfaac900_top,
             zfaac900_selection_screen,
             zfaac900_subroutine.
    * AT SELECTION SCREEN ON VALUE REQUEST
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ifile.
      PERFORM help_input_file USING p_phys p_locl CHANGING p_ifile.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_afile.
      PERFORM help_asset_file USING p_phys p_locl CHANGING p_afile.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cfile.
      PERFORM help_cost_file USING p_phys p_locl CHANGING p_cfile.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dfile.
      PERFORM help_depr_file USING p_phys p_locl CHANGING p_dfile.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ofile.
      PERFORM help_audit_file USING p_phys p_locl CHANGING p_ofile.
    * AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      PERFORM check_screen USING p_ifile p_afile p_cfile p_dfile
                                 p_ofile p_locl p_phys.
    * TOP-OF-PAGE
    TOP-OF-PAGE.
      ULINE.
       PERFORM sjm_heading IN PROGRAM zacai0005.
      ULINE.
    * START_OF_SELECTION
    START-OF-SELECTION.
      PERFORM get_input USING    p_ifile p_afile p_cfile p_dfile
                        CHANGING i_input i_asset i_cost i_depr.
    Subroutines :
    *&      Form  help_input_file
    *        text
    FORM help_input_file  USING    p_phys_file   TYPE c
                                   p_locl_file   TYPE c
                          CHANGING p_source_path TYPE any.
      IF p_phys_file EQ 'X'.
        CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
          EXPORTING
            dynpfield_filename = 'P_IFILE'
            dyname             = sy-repid
            dynumb             = sy-dynnr
            filetype           = 'P'
            location           = 'A'.
      ELSEIF p_locl_file EQ 'X'.
        PERFORM help_local_file CHANGING p_source_path.
      ENDIF.
    ENDFORM.                    " help_input_file
    *&      Form  help_asset_file
    *       text
    FORM help_asset_file  USING    p_phys_file   TYPE c
                                   p_locl_file   TYPE c
                          CHANGING p_source_path TYPE any.
      IF p_phys_file EQ 'X'.
        CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
          EXPORTING
            dynpfield_filename = 'P_AFILE'
            dyname             = sy-repid
            dynumb             = sy-dynnr
            filetype           = 'P'
            location           = 'A'.
      ELSEIF p_locl_file EQ 'X'.
        PERFORM help_local_file CHANGING p_source_path.
      ENDIF.
    ENDFORM.                    " help_asset_file
    *&      Form  help_cost_file
    *       text
    FORM help_cost_file  USING     p_phys_file   TYPE c
                                   p_locl_file   TYPE c
                          CHANGING p_source_path TYPE any.
      IF p_phys_file EQ 'X'.
        CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
          EXPORTING
            dynpfield_filename = 'P_CFILE'
            dyname             = sy-repid
            dynumb             = sy-dynnr
            filetype           = 'P'
            location           = 'A'.
      ELSEIF p_locl_file EQ 'X'.
        PERFORM help_local_file CHANGING p_source_path.
      ENDIF.
    ENDFORM.                    " help_cost_file
    *&      Form  help_depr_file
    *       text
    FORM help_depr_file  USING     p_phys_file   TYPE c
                                   p_locl_file   TYPE c
                          CHANGING p_source_path TYPE any.
      IF p_phys_file EQ 'X'.
        CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
          EXPORTING
            dynpfield_filename = 'P_DFILE'
            dyname             = sy-repid
            dynumb             = sy-dynnr
            filetype           = 'P'
            location           = 'A'.
      ELSEIF p_locl_file EQ 'X'.
        PERFORM help_local_file CHANGING p_source_path.
      ENDIF.
    ENDFORM.                    " help_depr_file
    *&      Form  help_audit_file
    *        text
    FORM help_audit_file  USING    p_phys_file TYPE c
                                   p_locl_file TYPE c
                          CHANGING p_audit_path TYPE any.
      IF p_phys_file EQ 'X'.
        CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
          EXPORTING
            dynpfield_filename = 'P_OFILE'
            dyname             = sy-repid
            dynumb             = sy-dynnr
            filetype           = 'P'
            location           = 'A'.
      ELSEIF p_locl_file EQ 'X'.
        PERFORM help_local_file CHANGING p_audit_path.
      ENDIF.
    ENDFORM.                    " help_audit_file
    *&      Form  help_local_file
    *       Local File Path
    FORM help_local_file  CHANGING p_path TYPE any .
      DATA:  lt_file_table TYPE filetable,
             la_file_table LIKE LINE OF lt_file_table,
             l_rc TYPE i,
             l_pcdsn TYPE cffile-filename.
      REFRESH lt_file_table.
      CLEAR la_file_table.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        CHANGING
          file_table = lt_file_table
          rc         = l_rc.
      READ TABLE lt_file_table INTO la_file_table INDEX 1.
      l_pcdsn = la_file_table-filename.
      MOVE l_pcdsn TO p_path.
    ENDFORM.                    " help_local_file
    *&      Form  check_phys_file
    *      Validation of Physical  File
    FORM check_phys_file  USING  p_file TYPE any.
      DATA: l_str(300) TYPE c.
      CLEAR l_str.
      OPEN DATASET p_file IN TEXT MODE FOR INPUT ENCODING DEFAULT.
      IF sy-subrc <> 0.
        IF g_file_flag = 'I'.
          MESSAGE e000 WITH text-021.
        ELSEIF g_file_flag = 'A'.
          MESSAGE e000 WITH text-095.
        ELSEIF g_file_flag = 'C'.
          MESSAGE e000 WITH text-096.
        ELSEIF g_file_flag = 'D'.
          MESSAGE e000 WITH text-097.
        ENDIF.
      ENDIF.
      READ DATASET p_file INTO l_str.
      IF sy-subrc <> 0.
        IF g_file_flag = 'I'.
          MESSAGE e000 WITH text-017.
        ELSEIF g_file_flag = 'A'.
          MESSAGE e000 WITH text-098.
        ELSEIF g_file_flag = 'C'.
          MESSAGE e000 WITH text-099.
        ELSEIF g_file_flag = 'D'.
          MESSAGE e000 WITH text-100.
        ENDIF.
      ENDIF.
      CLEAR: g_file_flag.
      CLOSE DATASET p_file.
    ENDFORM.                    " check_phys_file
    *&      Form  check_local_file
    *       Validation of Local File
    FORM check_local_file  USING    p_file TYPE any.
      DATA:  l_size       TYPE     i.
      CLEAR: l_size.
      CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
        EXPORTING
          fname          = p_file
        IMPORTING
    *      exist          = l_exist
          filesize       = l_size
        EXCEPTIONS
          fileinfo_error = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
        IF g_file_flag = 'I'.
          MESSAGE e000 WITH text-016.
        ELSEIF g_file_flag = 'A'.
          MESSAGE e000 WITH text-101.
        ELSEIF g_file_flag = 'C'.
          MESSAGE e000 WITH text-102.
        ELSEIF g_file_flag = 'D'.
          MESSAGE e000 WITH text-103.
        ENDIF.
      ENDIF.
      IF l_size IS INITIAL.
        IF g_file_flag = 'I'.
          MESSAGE e000 WITH text-024.
        ELSEIF g_file_flag = 'A'.
          MESSAGE e000 WITH text-107.
        ELSEIF g_file_flag = 'C'.
          MESSAGE e000 WITH text-108.
        ELSEIF g_file_flag = 'D'.
          MESSAGE e000 WITH text-109.
        ENDIF.
      ENDIF.
      CLEAR: g_file_flag.
    ENDFORM.                    " check_local_file
    *&      Form  get_input
    *       To gate input data from local file or from application server
    FORM get_input USING     p_ifilename TYPE   any
                             p_afilename TYPE   any
                             p_cfilename TYPE   any
                             p_dfilename TYPE   any
                   CHANGING  p_input_table TYPE t_input_table
                             p_asset_table TYPE t_asset_table
                             p_cost_table  TYPE t_cost_table
                             p_depr_table TYPE t_depr_table.
    * to populate the input table
      PERFORM upload_file USING p_ifilename CHANGING i_local.
      g_file_flag = 'I'.
      PERFORM split_localtable CHANGING p_input_table p_asset_table
                                        p_cost_table  p_depr_table.
      CLEAR g_file_flag.
      REFRESH i_local.
    * to populate the asset class table
      PERFORM upload_file USING p_afilename CHANGING i_local.
      g_file_flag = 'A'.
      PERFORM split_localtable CHANGING p_input_table p_asset_table
                                        p_cost_table  p_depr_table  .
      CLEAR g_file_flag.
      REFRESH i_local.
    * to populate the cost center table
      PERFORM upload_file USING p_cfilename CHANGING i_local.
      g_file_flag = 'C'.
      PERFORM split_localtable CHANGING p_input_table p_asset_table
                                        p_cost_table  p_depr_table  .
      CLEAR g_file_flag.
      REFRESH i_local.
    * to populate the depr key table
      PERFORM upload_file USING p_dfilename CHANGING i_local.
      g_file_flag = 'D'.
      PERFORM split_localtable CHANGING p_input_table p_asset_table
                                        p_cost_table  p_depr_table  .
      CLEAR g_file_flag.
      REFRESH i_local.
    ENDFORM.                    " get_input
    *&      Form  upload_file
    *       text
    FORM upload_file  USING    p_filename TYPE any
                 CHANGING p_local_table TYPE t_local_table.
    * To get the input data from desktop file
      IF p_locl = 'X'.
        DATA:  l_file TYPE string.
        CLEAR: l_file,
               p_local_table.
        l_file = p_filename.
        CALL FUNCTION 'GUI_UPLOAD'
          EXPORTING
            filename                = l_file
            filetype                = 'ASC'
          TABLES
            data_tab                = p_local_table
          EXCEPTIONS
            file_open_error         = 1
            file_read_error         = 2
            no_batch                = 3
            gui_refuse_filetransfer = 4
            invalid_type            = 5
            no_authority            = 6
            unknown_error           = 7
            bad_data_format         = 8
            header_not_allowed      = 9
            separator_not_allowed   = 10
            header_too_long         = 11
            unknown_dp_error        = 12
            access_denied           = 13
            dp_out_of_memory        = 14
            disk_full               = 15
            dp_timeout              = 16
            OTHERS                  = 17.
        IF sy-subrc <> 0.
          MESSAGE e002 WITH l_file.
        ENDIF.
      ELSE.
    *    To get the data from application server file
        OPEN DATASET p_filename IN TEXT MODE FOR INPUT ENCODING DEFAULT.
        IF sy-subrc <> 0.
          MESSAGE e001 WITH p_filename.
        ENDIF.
        CLEAR: wa_local.
        DO.
          READ DATASET p_filename INTO wa_local.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          APPEND wa_local TO p_local_table.
          CLEAR: wa_local.
        ENDDO.
        CLOSE DATASET p_filename.
      ENDIF.
    ENDFORM.                    " upload_file
    *&      Form  split_localtable
    *       text
    FORM split_localtable CHANGING p_input_tab TYPE t_input_table
                                   p_asset_tab TYPE t_asset_table
                                   p_cost_tab  TYPE t_cost_table
                                   p_depr_tab TYPE t_depr_table.
      DATA: l_cnt TYPE i.
      CLEAR: l_cnt, wa_local.
      LOOP AT i_local INTO wa_local.
        REFRESH i_split[].
        SPLIT wa_local AT c_tab INTO TABLE i_split.
        CLEAR l_cnt.
        ADD 1 TO l_cnt.
        CLEAR wa_split.
        LOOP AT i_split INTO wa_split.
          IF g_file_flag = 'I'.
            ASSIGN COMPONENT l_cnt OF STRUCTURE wa_input TO <fs_field>.
          ELSEIF g_file_flag = 'A'.
            ASSIGN COMPONENT l_cnt OF STRUCTURE wa_asset TO <fs_field>.
          ELSEIF g_file_flag = 'C'.
            ASSIGN COMPONENT l_cnt OF STRUCTURE wa_cost TO <fs_field>.
          ELSEIF g_file_flag = 'D'.
            ASSIGN COMPONENT l_cnt OF STRUCTURE wa_depr TO <fs_field>.
          ENDIF.
          CLEAR <fs_field>.
          <fs_field> = wa_split-col.
          ADD 1 TO l_cnt.
          CLEAR wa_split.
        ENDLOOP.
        IF g_file_flag = 'I'.
          APPEND wa_input TO p_input_tab.
          CLEAR: wa_input .
        ELSEIF g_file_flag = 'A'.
          APPEND wa_asset TO p_asset_tab.
          CLEAR: wa_asset .
        ELSEIF g_file_flag = 'C'.
          APPEND wa_cost TO p_cost_tab.
          CLEAR: wa_cost .
        ELSEIF g_file_flag = 'D'.
          APPEND wa_depr TO p_depr_tab.
          CLEAR: wa_depr .
        ENDIF.
        CLEAR: wa_local .
      ENDLOOP.
    ENDFORM.                    " split_localtable

  • Import a text file into database

    If anybody could help me with this, i would GREATLY appreciate it! I need to write a procedure to import a text file into an oracle database table. -Thanks!

    See my response in Re: import a text file into database.
    Cheers, APC

  • Uploading text file (TAB delimited) to Oracle database table

    Hi, im creating a form that will upload a text file(TAB delimited) that will insert a data in a database table. How would i do this? And what trigger will i use in the upload button? Please help..
    Thanks,
    Majic

    hi majic,
    Check any of this site related to oracle sql and plsql
    and do reply me if not found.
    1) http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/03_types.htm#LNPLS003
    Oracle composite data type help
    2) http://www.cs.umb.edu/cs634/ora9idocs/appdev.920/a96624/07_errs.htm#784
    Oracle plsql help good one check out
    3) http://www.orafaq.com/faqsql.htm#WHAT
    Oracle frequently asked questions
    4) http://www.bijoos.com/ora9/index.htm
    Oracle diff version comparasion help in above no 4 web site
    5) http://www.unix.org.ua/orelly/oracle/prog2/index.htm
    Oracle oreilly hand book good book for oracle pl/sql
    6) http://www.orafaq.com/glossary/faqgloss.htm#SQL_Loader
    check out for oracle faq good one
    7) http://www.rittman.net/archives/cat_oracle_9ias.html
    check out for Froms10g Installation and much more
    8) http://www.devarticles.com/c/a/Oracle/Creating-a-Database-in-Oracle-9i/2/
    check this for creating a oracle database in 9i***
    9) http://tahiti.oracle.com/
    suggested my many user for oracle help..check out this also
    10) http://www.jlcomp.demon.co.uk/faq/ind_faq.html
    For Full oracle related questions and answer****
    Regards,
    Asif A K.

  • Error while uploading text file....

    Halo Friends,
    I am uploading 4 text files which contain three columns separated by a tab, but when i am trying to upload those files using WS_UPLOAD Function Module i am getting a runtime error saying 'error while uploading/downloading'.
    Please solve this problem as soon as possible.
    Thanks in Advance,
    rama

    Halo again,
    Now that i am able to upload the files, i need to update the database table the update statement is executing correctly but when i debug i see that the sy-subrc value is 4 but not 0.
    and hence the it is not committed.
    Any suggestions. i am pasting my code here for your reference:
    Tables: qmfe.
    data: begin of gt1_qmfe occurs 0,
          qmnum       like qmfe-qmnum,
          fenum       like qmfe-fenum,
          /itml/usr20 like qmfe-/itml/usr20,
          end of gt1_qmfe.
    data: begin of gt2_qmfe occurs 0,
          qmnum       like qmfe-qmnum,
          fenum       like qmfe-fenum,
          /itml/usr21 like qmfe-/itml/usr21,
          end of gt2_qmfe.
    data: begin of gt3_qmfe occurs 0,
          qmnum       like qmfe-qmnum,
          fenum       like qmfe-fenum,
          /itml/usr19 like qmfe-/itml/usr19,
          end of gt3_qmfe.
    data: begin of gt4_qmfe occurs 0,
          qmnum       like qmfe-qmnum,
          fenum       like qmfe-fenum,
          /itml/usr07 like qmfe-/itml/usr07,
          end of gt4_qmfe.
    data: gs1_qmfe like line of gt1_qmfe,
          gs2_qmfe like line of gt2_qmfe,
          gs3_qmfe like line of gt3_qmfe,
          gs4_qmfe like line of gt4_qmfe.
    data: ls_lines1 type i,
          ls_lines2 type i,
          ls_lines3 type i,
          ls_lines4 type i.
    parameters: ip_file1 type RLGRAP-FILENAME default 'C:\Urgent\TextFiles\StoDt.txt'     obligatory,
                ip_file2 type RLGRAP-FILENAME default 'C:\Urgent\TextFiles\RcDtCust.txt'  obligatory,
                ip_file3 type RLGRAP-FILENAME default 'C:\Urgent\TextFiles\DockDate.txt'  obligatory,
                ip_file4 type RLGRAP-FILENAME default 'C:\Urgent\TextFiles\AWB.txt'       obligatory.
    field-symbols: <fs1> like gs1_qmfe,
                   <fs2> like gs2_qmfe,
                   <fs3> like gs3_qmfe,
                   <fs4> like gs4_qmfe.
    perform upload_gt1_qmfe.
    perform upload_gt2_qmfe.
    perform upload_gt3_qmfe.
    perform upload_gt4_qmfe.
    perform update_qmfe.
    *&      Form  upload_gt1_qmfe
          text
    -->  p1        text
    <--  p2        text
    FORM upload_gt1_qmfe .
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
       FILENAME                      = ip_file1
       FILETYPE                      = 'DAT'
      TABLES
        DATA_TAB                      = gt1_qmfe.
    describe table gt1_qmfe lines ls_lines1.
    write: / ls_lines1.
    ENDFORM.                    " upload_gt1_qmfe
    *&      Form  upload_gt2_qmfe
          text
    -->  p1        text
    <--  p2        text
    FORM upload_gt2_qmfe .
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
       FILENAME                      = ip_file2
       FILETYPE                      = 'DAT'
      TABLES
        DATA_TAB                      = gt2_qmfe.
    describe table gt2_qmfe lines ls_lines2.
    write: / ls_lines2.
    ENDFORM.                    " upload_gt2_qmfe
    *&      Form  upload_gt3_qmfe
          text
    -->  p1        text
    <--  p2        text
    FORM upload_gt3_qmfe .
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
       FILENAME                      = ip_file3
       FILETYPE                      = 'DAT'
      TABLES
        DATA_TAB                      = gt3_qmfe.
    describe table gt3_qmfe lines ls_lines3.
    write: / ls_lines3.
    ENDFORM.                    " upload_gt3_qmfe
    *&      Form  upload_gt4_qmfe
          text
    -->  p1        text
    <--  p2        text
    FORM upload_gt4_qmfe .
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
       FILENAME                      = ip_file4
       FILETYPE                      = 'DAT'
      TABLES
        DATA_TAB                      = gt4_qmfe.
    describe table gt4_qmfe lines ls_lines4.
    write: / ls_lines4.
    ENDFORM.                    " upload_gt4_qmfe
    *&      Form  update_qmfe
          text
    -->  p1        text
    <--  p2        text
    FORM update_qmfe .
    data ls_cnt type i.
    loop at gt1_qmfe assigning <fs1>.
    update qmfe set    /itml/usr20 = <fs1>-/itml/usr20
                where  qmnum       = <fs1>-qmnum
                and    fenum       = <fs1>-fenum.
    if sy-subrc = 0.
    commit work.
    add 1 to ls_cnt.
    endif.
    endloop.
    write: / ls_cnt.
    ENDFORM.                    " update_qmfe

  • Importing text file into database

    Hi again,
    Could anyone give me any pointers on how to take a text file or csv file (or any other delimeted text file) and read the contents into java and then use the read in data to then insert the delimeted data into the table.
    i assume i have to read the delimeted data into a variable then parse the complete string with the delimeter and split the data up maybe in an array. Maybe this is completely wrong, im really unsure.
    any help would be greatly appreciated even a point in the right direction would be great :)
    kind regards.

    Well, atleast i dont know of a single method, which does this kind of nonhomogenous task!! Its not hard to impliment what you want-->
    //open the text file using FileInputStream & get the contents in a String variable
    //Tokenise it
    StringTokenizer st=new StringTokenizer(your_string_retrieved_from_file,delimiter);
    int i=0;
    while(st.hasMoreTokens())
    i++;
    //SQL Statement that inserts a string into database table(integer, varchar2)
    insert into test_table values(i,st.nextToken());
    Unless you are talking about putting the tokens as coloums in a single row, i dont find why this is a problem & if you are actually doing the above case, then you might wanna rethink your design

Maybe you are looking for

  • Using iPod location services to find my way round new places

    I  like to use location services with map apps (such as OffMaps and MapsWithMe) to help me find my way around new places. I understand that the information  ipod uses for location services,  the positions of various wifi transmitters,  is stored in a

  • Conversion of BDOC's to IDOC's

    Hi, I am new to BDOC's in CRM. I need to convert BDOC's to IDOC's in CRM.How to do it? "Points will not be awarded" Regards, Jayasimha Jangam Edited by: Julius Bussche on Aug 14, 2008 6:40 AM

  • (BSO) export for lev0 member in column format

    Hi there, Today I have made a (BSO) export for lev0 member in column format.(Choosed this options with the export routine) What maked me wonder was that not only lev0 member are in the export file but also lev1 member. Can someone explain why this ha

  • Tecra sound card driver will not install "driver was not installed" message

    Hello I have a Tecra 9100,running XP pro with s/p 2 and when I try to install the Yamaha AC-XG sound driver it will unzip the files then looks like he's loading the files thru InstallShied, but then a error message comes up "driver was not installed"

  • Clicking notes in timeline grid makes duplicates. How to stop it?

    I'm in graphic view in the timeline grid. When I place a note (cmd-click), that note is duplicated in every measure within in the region. I don't want this to happen, and it never did this before. Today it's doing it, for some weird reason. Yes, I'm