Skip to Content
author's profile photo Former Member
Former Member

upload files

Hi,Dear All:

I am asking for help here.

a local txt file,contain data which are refer to the data of table SPFLI.I want to call FM GUI_LOAD,So,first I must to build a internal table,and then transfer the data to it.but I am not clear with the structrue of this internal table.and after upload the file,i want to process each fields of the internal table separately(eg.to get each fields's value and then assign to a variant)

Pls give me a demo of upload files.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Oct 18, 2006 at 05:53 AM

    HI,

    check this program for uploading.

    report ZTEST2.
    
    data: file_path type string.
    
    data: file_tab type filetable.
    data: wa_tab like line of file_tab.
    data: rc type i.
    
    data: itab type standard table of cskt.
    data: wa like line of itab.
    
    start-of-selection.
    
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
        EXPORTING
          FILE_FILTER             = '.XLS'
    
        CHANGING
          FILE_TABLE              = file_tab
          RC                      = rc
              .
    
      READ TABLE file_tab into wa_tab index 1.
      file_path = wa_tab-filename.
    
    
      call method cl_gui_frontend_services=>gui_upload
        exporting
            filename                = file_Path
            HAS_FIELD_SEPARATOR     = 'X'
    
         changing
             data_tab                = itab.
    
    
      loop at itab into wa.
    
        write:/ wa-kostl.
    
      endloop.

    Regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2006 at 06:04 AM

    Hi,

    1. Declare internal table :

    It will contain one field of max size of your record

    in a single row.

    DATA : BEGIN OF i_mat OCCURS 0,

    line(1000),

    END OF i_mat.

    2.

    start-of-selection.

    CALL FUNCTION 'UPLOAD'

    EXPORTING

    FILETYPE = 'dat'

    TABLES

    data_tab = i_mat.

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    3. This will contain records row by row in your file.

    Then split each row based on delimiter (eg. by , or |

    or space etc.) and store each field in a single row

    in you actual internal table.

    This way you will get all field records into one internal table.

    REWARD if this helps.

    Message was edited by: Palak Limbachiya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2006 at 08:10 AM

    Thanks,Palak Limbachiya

    As your advice,I upload the file successfully.

    and now,the data are stored in in_tab then,I want to do some processes.Can i process in_tab directly,or transfer them to a new internal table with the same structure.

    the data in in_tab are row by row, i want to assign them to string variant separately.How can i do it,and can i use array in ABAP,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2006 at 08:35 AM

    ’AA 0064 US SAN FRANCISCO JFK US NEW YORK SFO 321 10:00:00 18:21:00 "2.572,0000" MI 0‘

    this is one row out put of the uploaded file,I want to divid the fileds into different string variants.

    I use the SPLIT statement,but I do not know the separator.

    SPLIT in_tab-line at <del> into f1 f2....fn.

    what is the <del>.

    Message was edited by: lei xiang

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.