‎2007 Mar 19 11:23 AM
Hi
i have a internal table which contains data like
a1 a2 a3
100 10
100 20
100 30
100 1000
100 2000
i need the data like
100 1000 10
100 2000 20
100 30
can any one help its urgent me
‎2007 Mar 19 11:29 AM
hi
try this code.
data : count type i,
count1 type i.
loop at itab1 .
count = sy-tabix.
read table itab2 with key a1 = itab2-a1.
count1 = sy-tabix.
if sy-subrc = 0.
itab1-a2 = itab2-a2.
delete itab2 index count1 .
modify itab1 index count transporting a2.
endif.
endloop.
If you require itab2 data to be stored or not to be deleted try using a buffer .
I have tested this code it works.
Please reward if useful.
‎2007 Mar 19 11:29 AM
hi
try this code.
data : count type i,
count1 type i.
loop at itab1 .
count = sy-tabix.
read table itab2 with key a1 = itab2-a1.
count1 = sy-tabix.
if sy-subrc = 0.
itab1-a2 = itab2-a2.
delete itab2 index count1 .
modify itab1 index count transporting a2.
endif.
endloop.
If you require itab2 data to be stored or not to be deleted try using a buffer .
I have tested this code it works.
Please reward if useful.
‎2007 Mar 19 11:30 AM
Hi,
This is the fixed data in your internal; table? only thease are the records?
You mean two coumns data has to come into 3 columns ?
what's the logic for the second column? 10, 20 , 30, 1000, 2000
to come to 1000,2000, 30, what's this sequence/ we can hard code like that, but can't sort or do nothing?
I hope the requirement is not correct.
Regards,
Anji
‎2007 Mar 19 11:32 AM
the data above one is not displayed correctly
a1 , a2 , a3
100 , , 10
100 , , 20
100 , , 30
100 , 1000 ,
100 , 2000 ,
i need
100 , 1000 , 10
100 , 2000 , 20
100 , , 30
‎2007 Mar 19 11:33 AM
itab1 has
a1 a2 a3
100 10
100 20
100 30
itab2 has
a1 a4
100 1000
100 2000
loop at itab1.
read table itab2 with key a1 = itab1-a1
a4+0(2) = itab1-a2.
if sy-subrc = 0.
<move data>.
<append data>.
endif.
endloop.
‎2007 Mar 19 11:34 AM
the data above one is not displayed correctly
a1 , a2 , a3
100 , , 10
100 , , 20
100 , , 30
100 , 1000 ,
100 , 2000 ,
i need
100 , 1000 , 10
100 , 2000 , 20
100 , , 30
‎2007 Mar 19 11:35 AM
‎2007 Mar 19 11:54 AM
i have one internal table that contains data like
a1 field contains
1000
1000
1000
1000
1000
a2 field contains
space
space
space
1000
2000
a3 contain
10
20
30
space
space
now i want to move second field value to up
finally i need
100 1000 10
100 2000 20
100 space 30
suppose if the second field contain 3 values and third field contains 2 values i want
100 1000 10
100 2000 20
100 3000 space
plz hlp me
‎2007 Mar 19 12:13 PM
‎2007 Mar 19 12:30 PM
‎2007 Mar 19 12:45 PM
Hi,
Hope this helps:
DATA: BEGIN OF itab OCCURS 0,
a1 TYPE i,
a2 TYPE i,
a3 TYPE i,
a4 TYPE i,
END OF itab.
DATA: fieldtext1(20).
DATA: fieldtext2(20).
DATA: f1 TYPE n.
DATA: f2 TYPE n.
FIELD-SYMBOLS: <fs1> TYPE ANY.
FIELD-SYMBOLS: <fs2> TYPE ANY.
ITAB-A1 = 10.
ITAB-A2 = 0.
ITAB-A3 = 25.
ITAB-A4 = 12.
APPEND ITAB.
LOOP AT itab.
DO 4 TIMES.
f1 = sy-index.
CONCATENATE 'ITAB-A' f1 INTO fieldtext1.
ASSIGN (fieldtext1) TO <fs1>.
f2 = sy-index + 1.
CONCATENATE 'ITAB-A' f2 INTO fieldtext2.
ASSIGN (fieldtext2) TO <fs2>.
IF <fs1> = 0.
<fs1> = <fs2>.
CLEAR: <fs2>.
ENDIF.
ENDDO.
MODIFY itab.
ENDLOOP.
End result will be:
itab-a1 = 10.
itab-a2 = 25.
itab-a3 = 12.
itab-a4 = 0.
In this you need to follow the field naming convention.
Regards,
S. Chandra Mouli.
‎2007 Mar 19 12:44 PM
Hi Kiran,
The data is of which type, CHAR(4) or TYPE I or NUMC.
‎2007 Mar 19 12:54 PM
‎2007 Mar 19 1:11 PM
Hi Kiran,
Please discard the code from my previous post:
the following will be the code. You can modify it for character field as well.
Instead of checking <fs1> = 0, you can check <fs1> = space.
<i>DATA: BEGIN OF itab OCCURS 0,
a1 TYPE i,
a2 TYPE i,
a3 TYPE i,
a4 TYPE i,
END OF itab.
DATA: fieldtext1(20).
DATA: fieldtext2(20).
DATA: f1 TYPE n.
DATA: f2 TYPE n.
DATA: outer TYPE i.
FIELD-SYMBOLS: <fs1> TYPE ANY.
FIELD-SYMBOLS: <fs2> TYPE ANY.
itab-a1 = 0.
itab-a2 = 10.
itab-a3 = 0.
itab-a4 = 12.
APPEND itab.
LOOP AT itab.
DO 4 TIMES.
f1 = sy-index.
outer = sy-index.
CONCATENATE 'ITAB-A' f1 INTO fieldtext1.
ASSIGN (fieldtext1) TO <fs1>.
WHILE <fs1> = 0.
f2 = outer + sy-index.
CONCATENATE 'ITAB-A' f2 INTO fieldtext2.
ASSIGN (fieldtext2) TO <fs2>.
IF <fs1> = 0.
<fs1> = <fs2>.
CLEAR: <fs2>.
ENDIF.
IF f2 = 5 OR <fs1> NE 0.
EXIT.
ENDIF.
ENDWHILE.
ENDDO.
MODIFY itab.
ENDLOOP.
LOOP AT itab.
ENDLOOP.</i>
Try and revert.
Thanks and regards,
S. Chandra Mouli.