Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Upload flat file having pipeline symbol

Former Member
0 Kudos

PARAMETERS: p_file TYPE  rlgrap-filename.

*****Define Itab of your Z-Table and Work Area of That*********

**Data: Itab like table of ztmm_comp,

**         wa like line of Itab.

TYPES: BEGIN OF ttab,

        rec(1000) TYPE c,

        END OF ttab.

TYPES: BEGIN OF zs_tmm_comp,

         fld1 TYPE ztmm_comp-company,

         fld2 TYPE ztmm_comp-company_code,

         fld3 TYPE ztmm_comp-city,

   END OF zs_tmm_comp.

DATA: itab TYPE TABLE OF ttab WITH HEADER LINE.

DATA: it_datatab TYPE TABLE OF zs_tmm_comp WITH HEADER LINE.

DATA: wa TYPE zs_tmm_comp.

DATA path TYPE string.

path = p_file.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

   CALL FUNCTION 'F4_FILENAME'

     EXPORTING

       field_name = 'P_FILE'

     IMPORTING

       file_name  = p_file.

START-OF-SELECTION.

     CALL FUNCTION 'GUI_UPLOAD'

     EXPORTING

*     filename            = 'c:\file1.txt'

       filename            = path

       has_field_separator = 'X'

     TABLES

       data_tab            = it_datatab

     EXCEPTIONS

       OTHERS              = 1.

   LOOP AT itab.

     CLEAR it_datatab.

     SPLIT itab-rec AT '|' INTO it_datatab-fld1

                                it_datatab-fld2

                                it_datatab-fld3.

     APPEND it_datatab.

   ENDLOOP.

   LOOP AT it_datatab INTO wa.

     MODIFY ztmm_comp FROM wa.

*    modify ztmm_comp FROM it_datatab.

     IF sy-subrc = 0.

       MESSAGE s000(000) WITH 'The data has been saved'.

     ENDIF.

   ENDLOOP.

6 REPLIES 6

Former Member
0 Kudos

What is your question?

parin_doshi3
Explorer
0 Kudos

Instead of "X" try to pass the pipeline symbol

former_member182915
Active Contributor
0 Kudos

What is your question?

Former Member
0 Kudos

actually I need to upload folder containing more then 1 flat file. so is there any way to do that.?

0 Kudos

Hi Ankit,

Check METHOD DIRECTORY_LIST_FILES in CL_GUI_FRONTEND_SERVICES Class.It will Return all the file details FILE_TABLE internal table for the directory entered in DIRECTORY Parameter. Then you can loop through the internal table FILE_TABLE and Use GUI_UPLOAD to load the file from Local PC one by one.

R

0 Kudos

FINE

select all file a time by using frontend services class , save the path  in a internal table.

make a loop at that table process above code each of entry of that internal table.