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.
Showing results for 
Search instead for 
Did you mean: 

How to Upload a text file with a header.

Former Member
0 Kudos

Dear all,

I use FM <b>GUI_UPLOAD </b>to upload a tab delimited file into an internal table and it works well. In this case, text file just consists of content only.

Now, That file consists of<b> header and content</b>. Using GUI_UPLOAD is useless.

I made reference on this thread:

They told to delete the first row after uploading. But<b> the problem</b> is after calling the function, there is just HEADER on the internal table. Please be noticed that, my internal table has many fields with different data types.

Here is my code



filename = f_name " a variable to hold file name

has_field_separator = 'X'


data_tab = itab


<< list of exceptions here>>


Everyone has any solutions?


0 Kudos


After uploading by using GUI_UPLOAD its take all data from u'r data file , so its take header also . So u must remove first line of internal table by using DELETE statement.

**Please reward suitable points***

With Regards

Navin Khedikar

0 Kudos

Thanks Navin for replying,

When i run the program in debug mode, there is<b> ONLY ONE</b> row in my internal table, and it is the HEADER, while my file has many lines to be uploaded.

You have any ideas?

Former Member
0 Kudos

add filetype also



filename = f_name " a variable to hold file name

<b>filetype = 'ASC'</b>

0 Kudos

Thank Chandrasekhar,

<b> But</b> it still does not work. Internal Table has just one row ( header again)

0 Kudos

Hi Solaris

I am facing exactly the same problem as you.

Do you have a solution to your problem yet?

Please advise if you do.

Thanks a million!

0 Kudos

Well, actually, i have no perfect solution.

I just used a temporary internal table in which all fields are characters. Then, I used FM GUI_UPLOAD to upload text file including header into this table as usual.

You can see that it was done successfully. Next, use a loop to transfer this temporary table to the main table. SAP will automatically convert data into values that are compatible with data type in the main table, so don't worry about different types :D.

In order to make this work more simple, field names of temporary table should be named exactly as same as those in the main one. So, u just use:

loop at itab_tmp.

move-corresponding itab_tmp to itab_main.

append itab_main.

clear itab_main.


note: both tables have their own header line, so don't need use a working area here.

Anyone has any better solution?

0 Kudos

Hi Solaris,

Why don't you declare internal table fields as character through which you are uploading data. Fields of internal table should have number of length which it suppose to hold the values of the feilds.

This should solve your problem.

If not please revert with exact problem you are facing.

If it helps please reward points.


Sagun Desai.

0 Kudos

Hi Sagun Desai,

You mean that, instead of using 2 internal tables (temporary and main), I just need to use one internal table whose all fields are characters?

If so, yes, you are right. Because SAP automatically converts data type, I think your solution is right. Thank you very much.

However, some fields need number values for later calculation; I am afraid that it can make the program more difficult to track or maintain.

One more thing: the length of header may be very different from the length of fields, therefore there might be something wrong if you use data in that table for later process.

Just my feelings. Everybody, any suggestion?