Application Development and Automation 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: 
Read only

Pipe separated flat file upload

Former Member
0 Likes
1,548

Hi ALl,

Can any one tell me how to upload a flat file (field separator is pipe |) using the FM GUI_UPLOAD.

And than how to split the fields into there corresponding table-fields.

Thanks in advance.

regards

satish.

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
782

Upload the flat file into a flat itab using the GUI_UPLOAD.

Types: Begin of ttab,
       rec(1000) type c,
       end of ttab.

data: itab type table of ttab with header line.

After you have the data in the flat itab. Loop thru it and split at the pipe(|). Update another itab with your data.

data: Begin of itab2 occurs 0,
      field1(10) type c,
      field2(10) type c,
      field3(10) type c,
      endo of itab2.

Loop at itab.
split itab-rec at '|' into itab2-field1
                           itab2-field2
                           itab2-field3.
append itab2.
endloop.

Regards,

Rich Heilman

Read only

andreas_mann3
Active Contributor
0 Likes
782

Hi,

1) upload file in table ftab

2) split fields dyn. to your itab

DATA: BEGIN OF SPTAB OCCURS   0,
        line type string,
      END OF SPTAB.
Data : begin of itab,"your int. target table
....


loop at ftab.

split ftab at '|' into table sptab.

loop at sptab.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE itab TO <F>.
IF SY-SUBRC <> 0.
EXIT. 
endif.
<f> = sptab-line.
endloop.

endloop.

regards Andreas

Read only

Former Member
0 Likes
782

Thanks for the reply.

This is for the horizontal tab separator.

CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.

CONSTANTS:

CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

is there any specific thing for the pipe to0.

Thanks and Regards

satish

Read only

0 Likes
782

There is no specific value for Pipe as there is no Unicode conversion issues. In this case simply use:

DATA: l_delimiter TYPE c LENGTH 1 VALUE '|'.

You can specify the delimiter directly for any "normal" character, by that I mean any NON-white space characters.

Tone