Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Totals internal table without header.

Former Member
0 Likes
851

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

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
781

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®

4 REPLIES 4
Read only

former_member194669
Active Contributor
0 Likes
782

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®

Read only

0 Likes
781

The only way is using internal tables with occurs 0?

Read only

0 Likes
781

no you can use workarea also i just given you an example with occurs 0

a®

Read only

0 Likes
781

thank you very much for your answers , just one final question , what is itab1?