‎2011 Aug 22 10:38 AM
Hello Guys,
I want to sum WRBTR in my internal table based of transparent table regup , i need to do that using to fields the first one kunnr and the second one is xref1 this field for my customer is a like a sub-kunnr .
i declare the following structure:
data : ti_regup type standard table of regup.
field-symbol: <wa_regup> like line of ti_regup.my problem is that i dont know how to get this total, i guess if i use a internal table i could use a collect , but it doesnt work anyway because WRBTR only have the amounts no the sign of the amount i need to read other field SHKZG to know if it is necessary substrac or add to get the total. any ideas ? thank you guys
‎2011 Aug 22 10:47 AM
Try this way
data: begin of itab occurs 0.
data: xkunnr type kna1-kunnr.
data: xxref1 type regup-xref1.
include structure regup.
data: end of itab.
loop at it_regup.
move-corresponding it_regup to itab.
move it_regup-kunnr to itab-xkunnr.
move it_regup-xref1 to itab-xxref1.
append itab.
endloop.
sort itab by xkunnr xxref1.
loop at itab.
at end of xkunnr.
move 'X' to v_flg.
endat.
at end of xxref1.
move 'X' to v_flg.
endat.
if itab-SHKZG eq 'S'.
v_total = v_total + itab-wrbtr.
else.
v_total = v_total - itab-wrbtr.
endif.
if v_flg eq 'X'.
move-corresponding itab to itab1.
move v_total to itab1-total.
append itab1.
clear:v_flg, v_total.
endif.
endloop.
a®
‎2011 Aug 22 10:47 AM
Try this way
data: begin of itab occurs 0.
data: xkunnr type kna1-kunnr.
data: xxref1 type regup-xref1.
include structure regup.
data: end of itab.
loop at it_regup.
move-corresponding it_regup to itab.
move it_regup-kunnr to itab-xkunnr.
move it_regup-xref1 to itab-xxref1.
append itab.
endloop.
sort itab by xkunnr xxref1.
loop at itab.
at end of xkunnr.
move 'X' to v_flg.
endat.
at end of xxref1.
move 'X' to v_flg.
endat.
if itab-SHKZG eq 'S'.
v_total = v_total + itab-wrbtr.
else.
v_total = v_total - itab-wrbtr.
endif.
if v_flg eq 'X'.
move-corresponding itab to itab1.
move v_total to itab1-total.
append itab1.
clear:v_flg, v_total.
endif.
endloop.
a®
‎2011 Aug 22 11:06 AM
‎2011 Aug 22 11:13 AM
no you can use workarea also i just given you an example with occurs 0
a®
‎2011 Aug 22 5:35 PM
thank you very much for your answers , just one final question , what is itab1?