‎2006 Jul 21 2:16 PM
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
‎2006 Jul 21 2:18 PM
Hello,
U can do it using split stmt.
SPLIT STRING AT '|' into itab-a1 itab-a2 and soon.
append itab.
Reward points.
Vasanth
‎2006 Jul 21 3:21 PM
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.
‎2006 Jul 21 3:46 PM
‎2006 Jul 21 4:22 PM
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