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

Split line

Former Member
0 Likes
677

Hi,

I have a internal Table like below.

data: begin of test1 occurs 0,

a1(10),

a2(4),

a3(2),

a4(2),

a5(3),

a6(4),

a7(4),

a8(3),

a9(4),

a10(4),

End of test1.

Now the Vales are like this

0032302213|0002|01|00|870|1052|3271|870||3271

Now I want split these values and put into the internal table corresponding values. Here the delemeter is |.

Ex :

test1-a1 = 0032302213.

test1-a1 = 0002.

test1-a1 = 01.

test1-a1 = 00.

test1-a1 = 870.

test1-a1 = 1052.

test1-a1 = 3271.

test1-a1 = 870.

test1-a1 = ''.

test1-a1 = 3271.

append test1.

Please give some Idea How can I do it.

Thanks & Regards

Venat

4 REPLIES 4
Read only

Former Member
0 Likes
565

Hello,

U can do it using split stmt.

SPLIT STRING AT '|' into itab-a1 itab-a2 and soon.

append itab.

Reward points.

Vasanth

Read only

Former Member
0 Likes
565

Hi Venkata ,

Hope the following code serves your requirement :-


data: begin of test1 occurs 0,
a1(10),
a2(4),
a3(2),
a4(2),
a5(3),
a6(4),
a7(4),
a8(3),
a9(4),
a10(4),
End of test1.

data : begin of value1 occurs 0,
        val1(49),
       end of value1.
value1-val1 = '0032302213|0002|01|00|870|1052|3271|870||3271'.
append value1.
value1-val1 = '0032302216|0004|03|01|871|1053|3272|871||3273'.
append value1.

loop at value1.
  split value1-val1 at '|' into test1-a1
                                test1-a2
                                test1-a3
                                test1-a4
                                test1-a5
                                test1-a6
                                test1-a7
                                test1-a8
                                test1-a9
                                test1-a10.
  append test1.
 endloop.
loop at test1.
  write: / test1-a1,
           test1-a2,
           test1-a3,
           test1-a4,
           test1-a5,
           test1-a6,
           test1-a7,
           test1-a8,
            test1-a9,
          test1-a10.
 endloop.

Regards,

Anirban.

Read only

Former Member
0 Likes
565

Use the SPLIT command !!

Regards

Anurag

Read only

Former Member
0 Likes
565

Hi VenkataG,

Use <b>SPLIT statement</b> to achieve your requirement.

Try with this code:

VALUES = '0032302213|0002|01|00|870|1052|3271|870||3271'

1)If you have only 1 value in VALUES then

<b>SPLIT VALUES AT '|' INTO TABLE TEST1.</b>

2)If VALUES is an internal table then

VALUES = '0032302213|0002|01|00|870|1052|3271|870||3271'

'0032302213|0002|01|00|870|1052|3271|870||3272'.

<b>LOOP AT VALUES.

SPLIT VALUES AT '|' INTO TABLE TEST1.

ENDLOOP.</b>

To know more about SPLIT, view the below link

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/split.htm

Thanks,

Vinay