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: 

Error in splitting records from an internal table

Former Member
0 Kudos

Hi all,

After uploading the data from flat file into an internal table the data consists of # between each field and while I try to split each field and assign to a different table the data is not getting split properly ,

i.e. split function splits the fields after 3 '#' and storing it in the table field.

Thanks & Regards

Jerry

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Jerry

I once had to re-engineer an upload program where the data in the flat file were separated using "¦". The report tried to split the flat file using fm TEXT_CONVERT_TEX_TO_SAP (I_FIELD_SEPERATOR = "¦").

The file splitting did not work because the "¦" in the file was different from the "¦" used as input for the fm. However, you could see the difference only in debugging mode when you switch the display mode from TEXT to HEX.

Perhaps you are dealing with a similar problem. In addition, the Unicode format (UTF-8) may play a role. Do you upload your file from the local PC. If so then use CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD because the corresponding fm GUI_UPLOAD is not Unicode-compatible.

If the flat file uses an exotic field separator I recommend to replace it with a simple semicolon (";").

Regards

Uwe

5 REPLIES 5

uwe_schieferstein
Active Contributor
0 Kudos

Hello Jerry

I once had to re-engineer an upload program where the data in the flat file were separated using "¦". The report tried to split the flat file using fm TEXT_CONVERT_TEX_TO_SAP (I_FIELD_SEPERATOR = "¦").

The file splitting did not work because the "¦" in the file was different from the "¦" used as input for the fm. However, you could see the difference only in debugging mode when you switch the display mode from TEXT to HEX.

Perhaps you are dealing with a similar problem. In addition, the Unicode format (UTF-8) may play a role. Do you upload your file from the local PC. If so then use CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD because the corresponding fm GUI_UPLOAD is not Unicode-compatible.

If the flat file uses an exotic field separator I recommend to replace it with a simple semicolon (";").

Regards

Uwe

0 Kudos

Hi Uwe,

I appreciate your help!!!

Even though I am using CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD to upload the data the problem remains the same. The data in flat file is tab delimited and after uploadind it internal table it is

seperated by '#' and even though using SPLIT function its not splitting the fields after each occurence of '#'.

Regards

Jerry

0 Kudos

Hi Jerry,

What Uwe said is correct. We too faced that kind of scenario. In the internal table when uploaded from flat file it will show '#' but it wont get split with '#' symbol in the program. However we solved the issue with the following class.



Data: c_tab value cl_abap_char_utilities=>newline,
         it_string type table of string.

" if it_table1 is the table which contains the flat file data, then go throuhg  this logic.

loop at it_table1 into wa_table1.

 split wa_table1 at c_tab into table it_string.

endloop.

If the table is not getting split with cl_abap_char_utilities=>newline, then try using differnt attributes of that class ( like cl_abap_char_utilities=>cr_lf, cl_abap_char_utilities=>backspace so on ).

Hope this will help.

Regards,

Swarna Munukoti.

Edited by: Swarna Munukoti on Sep 13, 2008 5:54 PM

Former Member
0 Kudos

Hi

check sy-subrc ..if it is 4 , means ur split stmt is not being executed.........

to check this u count the no of fields of Int table to be splitted.

it should match with the no. of parameters specified in split stmt....

Former Member
0 Kudos

Hi ,

I came across same scenario .... i solved this problem....

Misleading part in this is "#" u see in debugging mode .... data uploaded from tab delimited file will have tab between fields , but it will show "#".

define a data

DATA : V_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

and use like

split ur_string at V_TAB ................

I am sure that it will work ....

Njoy