‎2007 Dec 13 10:41 AM
I've populated an internal table which is showing values suppose like below.
f1 f2 f3 f4.
1 a b 10
1 a b 20
1 a h 40
2 b c 30
2 b c 40
3 c d 50
3 c d 60
consider:
f1 as matnr-article number
f2 as maktx-article description.
Now for every new matnr (having new maktx) only new matnr and new maktx will be printed, duplicate matnr and maktx won't be displayed. Those fields will display null actually. But corresponding f3 and f4 will be printed as it is.
so values in the next internal table will be like following:
f1 f2 f3 f4.
1 a b 10
N N b 20
N N h 40
2 b c 30
N N c 40
3 c d 50
N N d 60
Consider N as null.
kindly help.
how can i populate such internal table?
Thanks.
‎2007 Dec 13 11:33 AM
Hai Cinthia,
Try this:
data: lv_f1 type matnr,
lv_f2 type maktx.
sort <internaltable> by f1.
loop at <internaltable>.
clear: lv_f1, lv_f2.
lv_f1 = <internaltable>-f1.
lv_f2 = <internaltable>-f2.
at new f1.
write: lv_f1,
lv_f2.
endat.
write: <internaltable>-f3,
<internaltable>-f4.
endloop.
with regards,
Eswar.
‎2007 Dec 13 11:09 AM
hi,
take two variables, and give first data of itab..
and in loop compare it with new value and if same use modify statement and refresh that two variables with new value..
i think it should work...
‎2007 Dec 13 11:33 AM
Hi ,
I can suggest on esimple solution.
you have data in itab.
the declare
data:begin itab_flg occurs 0.
include structure itab.
data:flg(1),
end of itab_flg.
data:v_index like sy-tabix.
data:v_maktx like makt-maktx.
start-of-selection.
sort itab by maktx. "f2
move-corresponding itab to itab_flg.
append itab_flg.
clear itab_flg.
loop at itab_flg.
clear :v_index,v_maktx.
v_index = sy-tabix + 1.
v_maktx = itab_flg-maktx.
read itab_flg index v_index.
if sy-subrc = 0 and v_maktx = itab_flg-maktx .
itab_flg-flg = 'X'.
modify itab_flg index v_index.
clear itab_flg.
endif.
endloop.
loop at itab_flg where flg = 'X'.
itab_flg-maktx = ' '. "Null value.
modify itab_flg.
clear itab_flg.
endloop.
refresh:itab.clear:itab.
Move-corresponding itab_flg to itab.
Append itab.
clear itab.
now in this itab you have the data required for you.
thanks
Sivaparvathi.
Please reward points if helpful.
‎2007 Dec 13 11:33 AM
Hai Cinthia,
Try this:
data: lv_f1 type matnr,
lv_f2 type maktx.
sort <internaltable> by f1.
loop at <internaltable>.
clear: lv_f1, lv_f2.
lv_f1 = <internaltable>-f1.
lv_f2 = <internaltable>-f2.
at new f1.
write: lv_f1,
lv_f2.
endat.
write: <internaltable>-f3,
<internaltable>-f4.
endloop.
with regards,
Eswar.