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

Problem with loop at end of ...

former_member431874
Participant
0 Likes
394

Dear experts,

I am trying to sum a value in an internal table with the following code:

  sort it_vbrp by matnr.

  loop at  it_vbrp.

    at new matnr.

      clear it_sqty.

    endat.

    it_sqty-matnr =  it_vbrp-matnr.

    it_sqty-slqty = it_sqty-slqty +  it_vbrp-FKIMG.

    at end of matnr.

      append it_sqty.

    endat.

  endloop.

The problem is that it goes to the statement "append it_sqty." in every loop even though matnr is still the same.

Would you please let me know how to correct it?

Sincerely,

VT

Moderator Message: It is explained in SAP documentation, read it once. Thread Locked.

Message was edited by: Kesavadas Thekkillath

2 REPLIES 2
Read only

Former Member
0 Likes
353

MATNR should be the first field in it_vbrp for this to work.

In your internal table say, if you have VBELN VBPOS MATNR, then AT END OF MATNR will be trigerred when one of these 3 fields change.

Check the documentation for At END of

Thanks,

Shambu

Read only

madhu_vadlamani
Active Contributor
0 Likes
353

Hi,

When you keep the fields in a group the sort fields should be the first.Just check in debug mode.

Regards,

Madhu.