‎2009 Jan 15 12:54 PM
Hi, I have a set of data in an internal table, with fields a b c d e.
My requirement is rather confusing
-
( KEY refers to combination of a b c and d )
sort itab by a,b,c,d
loop at itab based on sort key ( a,b,c,d)
at break in KEY sum all e for the records with the SAME KEY.
if sum(e) > 0.
remove this set from itab
else.
keep them
endloop.
-
I am not sure how to proceed, can anyone help?
‎2009 Jan 15 1:01 PM
Try this:
sort itab by a b c d.
loop at itab into wa_itab.
at end d.
sum.
if wa_itab-e > 0. " or compare with ur required threshold value'.
delete itab where a = wa_itab-a and b = wa_itab-b and c = wa_itab-c and d = wa_itab-d.
endif.
endat.
endloop.
‎2009 Jan 15 12:59 PM
Hi,
Its little bit confusing.
Can u tell ur requirement briefly.
Thanks.
‎2009 Jan 15 1:00 PM
roughly:
SORT iatb BY a b c d.
LOOP AT itab.
AT END OF d.
SUM.
IF itab-e > 0.
DELETE itab WHERE a = itab-a
AND b = itab-b
AND c = itab-c
AND d = itab-d.
ENDIF.
ENDAT.
ENDLOOP.
‎2009 Jan 15 1:01 PM
Try this:
sort itab by a b c d.
loop at itab into wa_itab.
at end d.
sum.
if wa_itab-e > 0. " or compare with ur required threshold value'.
delete itab where a = wa_itab-a and b = wa_itab-b and c = wa_itab-c and d = wa_itab-d.
endif.
endat.
endloop.
‎2009 Jan 15 1:05 PM
Hello,
sort itab by a,b,c,d
loop at itab based on sort key ( a,b,c,d)
at break in KEY sum all e for the records with the SAME KEY.
if sum(e) > 0.
remove this set from itab
else.
keep them
endloop.
You can try this code and check:
SORT itab BY a b c d.
LOOP AT itab INTO wa.
wa1 = wa.
v_sum_e = v_sum_e + wa-e.
AT END OF d.
IF v_sum_e > 0.
ELSE.
DELETE itab
WHERE a = wa1-a AND b = wa1-b AND c = wa1-c AND d = wa1-d.
ENDIF.
ENDAT.
ENDLOOP.
Plz try & let us know.
BR,
Suhas
‎2009 Jan 15 1:06 PM
assuming you can add a new_field at the end of itab structure this is the logic.
sort itab by abcd.
loop at itab.
at end of d. "assuming fields in structure are defined in sequence abcd
sum.
if e > 0 .
modify table itab and set 'X' to new_field where key = abcd.
endif.
endat.
endloop.
delete itab where new_field = 'X'
‎2009 Jan 15 1:08 PM
Hi Suker,
try it this way:
Loop at itab into wa.
At end of d.
Sum.
w_sum = wa-e.
If w_sum > 0.
Delete itab where ...
Endif.
Endat.
Endloop.With luck,
Pritam.
‎2009 Jan 15 1:28 PM
Hi,
SORT itab BY a b c d.
LOOP AT itab INTO wa.
v_sum = v_sum + wa-e.
AT END OF d.
IF v_sum NE 0.
DELETE itab
WHERE a = wa-a AND b = wa-b AND c = wa-c AND d = wa-d.
ENDIF.
CLEAR v_sum.
ENDAT.
ENDLOOP.