2007 Jul 23 11:58 AM
i m using at new field statement inside the loop.
whenever the data in first field changes i want to append tht whole line in another internal table.
loop at it.
at new field1.
it1 = it.
append it1.
endat.
endloop.
except first field all other fields r displaying * .
why..
how to get the data.
based on tht data i have to do some calculation.
Thanks in advance.
2007 Jul 23 12:00 PM
Hi Vinothini,
Code as follows.
loop at it.
at new field1.
<b>read table it index sy-tabix.</b>
it1 = it.
append it1.
endat.
endloop.
Thanks,
Vinay
2007 Jul 23 11:59 AM
sdo like this
data : wa like it.
loop at it.
move-corresponding it to wa.
at new field1.
it1 = wa.
append it1.
endat.
endloop.
regards
shiba dutta
2007 Jul 23 12:30 PM
i tried wat u specified but not able to reach my requirement.
my table has.
it.
field1 field2
1 a
1 b
1 c
2 d
2 e
2 f
3 g
3 h
3 i
4 j
4 k
4 l
my output must be it1.
field1 field2
1 a
2 d
3 g
4 j
how to get this.
Thanks in advance.
2007 Jul 23 12:33 PM
data : wa like it.
sort it by field1 field2.
loop at it.
move-corresponding it to wa.
at new field1.
append wa to it1.
endat.
clear : wa,it1.
endloop.
regards
shiba dutta
2007 Jul 23 12:43 PM
while using at new the respective field must be in the first column.
Check this...
ield1 field2
1 a
1 b
1 c
2 d
2 e
2 f
3 g
3 h
3 i
4 j
4 k
4 l
loop at it.
wk_field1 = it_field1.
wk_field2 = it_field2.
at new field1.
move- corresponding it to it2.
append it2.
endat.
cleart it2,it1.
endloop.
2007 Jul 23 12:00 PM
Hi Vinothini,
Code as follows.
loop at it.
at new field1.
<b>read table it index sy-tabix.</b>
it1 = it.
append it1.
endat.
endloop.
Thanks,
Vinay
2007 Jul 23 12:03 PM
Hi,
<b>Reason</b>
At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:
All character type fields (on the right) are filled with "*" after the current control level key.
All other fields (on the right) are set to their initial values after the current control level key.
<b>Solution to avoid</b>
Declare a work area similar to it and use it for appending.
loop at it.
<b>it2 = it.</b>
at new field1.
<b>it1 = it2.</b>
append it1.
endat.
endloop.
Reward if helpful.
2007 Jul 23 12:18 PM
try this...may b helpful...
data:begin of itab occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
end of itab .
data:begin of itab2 occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
end of itab2.
select maramatnr maktmaktx appending table itab
from mara inner join makt on maramatnr = maktmatnr.
data:wk_maktx like makt-maktx.
loop at itab.
wk_maktx = itab-maktx.
at new matnr.
clear itab2.
endat.
at end of matnr.
move:itab-matnr to itab2-matnr,
wk_maktx to itab2-maktx.
append itab2.
endat.
endloop.
2007 Jul 23 12:45 PM
Sorry its not like that...
here it is
hile using at new the respective field must be in the first column.
Check this...
ield1 field2
1 a
1 b
1 c
2 d
2 e
2 f
3 g
3 h
3 i
4 j
4 k
4 l
loop at it.
wk_field1 = it_field1.
wk_field2 = it_field2.
at new field1.
move wk_field1 to it2-field1.
move wk_field2 to it2-field2.
append it2.
clear : wk_field1,wk_field2.
endat.
cleart it2,it1.
endloop.
2007 Jul 23 12:48 PM
in case of at new u must use local variables to store data...
other wise u can do the same with
on change of it_field-field1.
move the necessary fields to itab2
append itab2.
clear itab2.
endon.
here local variables are not required.....