‎2008 Jan 05 9:40 AM
Hi,
I am working on a BDC program. Here, I have to split a text at # and move the same into an internal table. See below.
W_STRING = #H#263##030108#DG#030108#EUR#Rf.123#DN-123#0002#############
SPLIT W_STRING AT '#' INTO E_HEAD-FIRST E_HEAD-RTYPE E_HEAD-BUKRS......
where E_HEAD is the structure I want to move the data.
But, after this statement, E_HEAD-FIRST is holding # and rest all the fields are blank.
Is anything wrong in the statement I have used....? Could someone clarify my doubt..? Please suggest me how to split in such case.
Thanks in advance.
Best Regards,
Paddu.
‎2008 Jan 05 9:48 AM
HI,
data: abc type table of string with header line.
split field-name at '#' into Table abc.
Read Table abc index 1.
itab-field1 = abc.
Read Table abc index 2
itab-field2 = abc.
Do like this ..
Finally, append itab to an internal table.
Regards,
TALWINDER
‎2008 Jan 05 9:48 AM
HI,
data: abc type table of string with header line.
split field-name at '#' into Table abc.
Read Table abc index 1.
itab-field1 = abc.
Read Table abc index 2
itab-field2 = abc.
Do like this ..
Finally, append itab to an internal table.
Regards,
TALWINDER
‎2008 Jan 05 9:54 AM
First Use:
Shift w_string.
and then split it.
Then use this statement on all values.
Replace ALL OCCURENCES of '#' with ' '.
This will surely solve ur problem.
awrd points if helpful
Bhupal
‎2008 Jan 05 9:54 AM
Hai Paddu,
Your statement is correct. But i dont know how you declared the structure(E_HEAD).once again Check it.
Regards,
Nagaraju
‎2008 Jan 05 9:55 AM
hi,
it might be due to the first #.
try
shift w_string by 1 places left.
den split
‎2008 Jan 05 10:04 AM
Hi Paddu,
Execute the below code then ur problem will be resolved ok..
W_STRING =' #H#263##030108'.
SHIFT W_STRING.
SPLIT W_STRING AT '#' INTO E_HEAD-FIRST E_HEAD-RTYPE E_HEAD-BUKRS......
*DEFAULT SHIFT IS LEFT SHIFT AT THAT TIME FIRST HASH SYMBOL WILL DELETED..
Award points if helpful.
Kiran Kumar.G
Have a Nice Day..
‎2008 Jan 05 11:36 AM
Hi Kiran,
Thanks for your reply.
I tried like you said. I shifted the string left first after that I splitted that at #. But, even now I am getting only one field.
I am getting E_HEAD-RTYPE as H. and rest all the fields blank. I used the same statement you said.
Please suggest me how to proceed.
Thasnks,
Paddu.
‎2008 Jan 05 10:16 AM
Hi,
I think this is due to two or more ## symbols like this beside.
So before splitting the string do:-
REPLACE ##WITH # INTO W_STRING.
These REPLACE statements can repeated if u have ### in u r file.
ie W_STRING = #xyz##abd###cd#.
Then for three ###
REPLACE ##WITH # INTO W_STRING.
REPLACE ##WITH # INTO W_STRING.
Then
1. SPLIT W_STRING AT # INTO field1 field2 ... fieldn.
2. SPLIT W_STRING AT # INTO TABLE itab.
‎2008 Jan 05 11:42 AM
Hi Paddu,
dont use hard code '#' while spliting. just follow as below.
data: lv_tabch TYPE char01 VALUE cl_abap_char_utilities=>horizontal_tab.
if you use lv_tabch system will take care of the Symbols either ',' or '#' or tab delimeted.......
and SPLIT LS_FILE AT lv_tabch INTO -
-
Reward me with points if it helps you
Thanks,
Murali.