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

Sum in Loop with condition is not functioning.

suityan98
Explorer
0 Likes
904

I try to applied loop with condition, but it dont functioning, not sure about what reason cause the where statement ignored by the program, any suggestion on it?

SELECT * FROM LIPS INTO CORRESPONDING FIELDS OF TABLE LT_LIPS
WHERE VGBEL = LT_BCODE_I-VGBEL
AND VGPOS = LT_BCODE_I-VGPOS.

LOOP AT LT_BCODE_I INTO LT_BCODE_I WHERE VGBEL = LT_LIPS-VGBEL AND VGPOS = LT_LIPS-VGPOS.
SUM.
LT_BCODE_I-MENGE = LT_BCODE_I-MENGE.
ENDLOOP.
1 ACCEPTED SOLUTION
Read only

venkateswaran_k
Active Contributor
847

Hi suityan98

The SUM will be working along with AT END of.. Example as below
LOOP AT itab INTO wa.
  AT END OF comp2.
    SUM.
    cl_demo_output=>write( wa ).
  ENDAT.
ENDLOOP.
So you need to modify your code as something like below
  LOOP AT LT_BCODE_I INTO LT_BCODE_I WHERE VGBEL = LT_LIPS-VGBEL AND VGPOS = LT_LIPS-VGPOS.
    AT END OF LT_LIPS-VGBEL
    SUM.
    your summ fields...
    ENDAT.
  ENDLOOP.
Regards,Venkat
2 REPLIES 2
Read only

venkateswaran_k
Active Contributor
848

Hi suityan98

The SUM will be working along with AT END of.. Example as below
LOOP AT itab INTO wa.
  AT END OF comp2.
    SUM.
    cl_demo_output=>write( wa ).
  ENDAT.
ENDLOOP.
So you need to modify your code as something like below
  LOOP AT LT_BCODE_I INTO LT_BCODE_I WHERE VGBEL = LT_LIPS-VGBEL AND VGPOS = LT_LIPS-VGPOS.
    AT END OF LT_LIPS-VGBEL
    SUM.
    your summ fields...
    ENDAT.
  ENDLOOP.
Regards,Venkat
Read only

0 Likes
847

Thank you. My problem fixed.