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

Flat file header diferent from remaining file (function module GUI_UPLOAD)

SrgioMonteiro
Participant
0 Likes
754

Hello gurus,

I need to upload a flat file but the header is the control record with the number of lines in the file, and has a diferent structure from remaining file records.

I'm using GUI_UPLOAD in ASCII mode for the flat file and my first line with the control record does not "fit" the structure of the remaining records.

Whats the best way I read diferent line structures in the flat file so I can have a counter from the first line and all other lines in an internal table?

Using GUI_UPLOAD twice with diferent internal tables will have performance degraded...

regards.

Sérgio.

5 REPLIES 5
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
721

Hello,

If it is a flat file upload the file contents to an internal table of type string (DATA: ITAB TYPE STANDARD TABLE OF STRING).

Now read the 1st line which is the header & populate the remaining lines to an internal table.

BR,

Suhas

Read only

0 Likes
721

Hello Suhas,

Thanks for your reply, but how do you suggest defining the initial table of string characters? What I've found is that if I define a line string and my flat file has several TAB separated fields, only the first column is uploaded to the internal table because the table only has one field. If I define several character fields to accommodate all required fields it should work but I don't believe that there is not a most efficient method in ABAP unless this one uploading all data in strings and then convert them all to the required data types.

regards.

Sérgio.

Read only

Former Member
0 Likes
721

Hi,

Declare an itab as

ITAB TYPE STANDARD TABLE OF STRING

Variable for Tab limited

data :gc_con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

pass the control record to the internal table first then.

loop at it_final into wa_final.

      • concatenating gc_con_tab will add TABs in your output.

CONCATENATE wa_final-f1 wa_final-f2

into ITABl separated by gc_con_tab.

append ITAB.

endloop.

Then use GUI_DOWNLOAD to download ITAB.

Regards,

Shanmugavel chandrasekaran

Read only

0 Likes
721

Hello Shanmugavel, now I'm lost... I ask about uploading a file with a diferent structure in the first record, and if there is any way to manage this eficiently in ABAP.

I think your reply is to make a download, not an upload, correct?

Thanks

Sérgio.

Read only

Former Member
0 Likes
721

Hi ,

try out this option in the thread .

The logic is simple but effective..

Br,

Vijay.