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: 

SPLIT statement

former_member687052
Participant
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

8 REPLIES 8

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hai Paddu,

Your statement is correct. But i dont know how you declared the structure(E_HEAD).once again Check it.

Regards,

Nagaraju

Former Member
0 Kudos

hi,

it might be due to the first #.

try

shift w_string by 1 places left.

den split

Former Member
0 Kudos

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..

0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.