Application Development 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: 

at end of

Former Member
0 Kudos

hi experts

i have a problem with my code:

SORT i_data by lifnr grund.

  • loop for summing quantity for each vendor and reason

  • for movment:

LOOP at i_data INTO wa_data.

if i_data-shkzg = 'H'.

i_data-erfmg = i_data-erfmg * -1.

modify i_data.

ENDIF.

at END OF grund.

SUM.

flag = 1.

outtab-erfmg = wa_data-erfmg.

ENDAT.

if flag = 1.

outtab-lifnr = wa_data-lifnr.

outtab-name1 = wa_data-name1.

outtab-kvgr1 = wa_data-kvgr1.

outtab-bezei = wa_data-bezei.

outtab-stras = wa_data-stras.

outtab-ort01 = wa_data-ort01.

outtab-telef1 = wa_data-telf1.

outtab-kunnr = wa_data-kunnr.

outtab-grund = wa_data-grund.

outtab-preis = wa_data-preis.

outtab-bwaer = wa_data-bwaer.

outtab-peinh = wa_data-peinh.

outtab-bprme = wa_data-bprme.

APPEND outtab.

flag = 0.

endif.

ENDLOOP.

the statement at end of grund works only in the first time i.e.,

when i have for example three first rows with the same grund it takes the third row but in

the next three rows with the same grund it takes the first instead of third

what's the problem?

thanks

amit

1 ACCEPTED SOLUTION

franois_henrotte
Active Contributor
0 Kudos

probably they have a different value in LIFNR

when you do "AT END OF grund." the statement considers all fields up to the field "grund"

so if you want to break on this field only, you have to put it in front !

6 REPLIES 6

franois_henrotte
Active Contributor
0 Kudos

probably they have a different value in LIFNR

when you do "AT END OF grund." the statement considers all fields up to the field "grund"

so if you want to break on this field only, you have to put it in front !

Former Member
0 Kudos

Hi Amit,

It is because your i_data may not have GRUND as first field.

Show us the structure of I_DATA table.

Suppose if GRUND is the third field of I_DATA, then even if the second field changes - AT END OF will be triggered.

Keep GRUND as the first field in that table structure.then it will work as you want now

Cheers,

Kothand

0 Kudos

hi kothand

in continue to your reply, i want to sum all the rows in i_data with the same grund and lifnr

and to put the sum in other table how can i do this.

thanks

amit

Former Member
0 Kudos

In Your Internal Table

grund must be the First Field

Then and then only at End of grund

works

Regards,

Alpesh

Former Member
0 Kudos

Hi,

Use grund field as the first column of the internal table and apply the same logic.

Because at end of compi, the control breaks happens when the left field of compi changes.

Former Member
0 Kudos

Don't use AT END OF in the same LOOP as u r modifying the values it leads to inconsistency.

Finish this loop and sort the itab againg then use AT END OF statement it will give the correct results.