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

calculate vendor balance code

Former Member
0 Likes
917

Hi guys,

I need help on calculating vendor balances grouped by vendor no. (lifnr) and and company code (bukrs).

Please see my code bellow... Gt_output contains all the vendor numbers that are requested and t_bsik is a table type of bsik.

LOOP AT gt_output INTO gwa_output.

LOOP AT t_bsik INTO w_bsik

WHERE lifnr = gwa_output-lifnr

AND bukrs = gwa_output-bukrs.

IF sy-subrc = 0.

AT END OF lifnr.

AT END OF bukrs.

SUM.

gwa_output-balance = w_bsik-dmbtr.

MODIFY gt_output FROM gwa_output.

ENDAT.

ENDAT.

ENDIF.

ENDLOOP.

endloop.

this code adds all the balances onto one vendor only even when the vendor numbers and company codes are different.

Please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
870

Hi

Try using

AT END OF lifnr.

AT NEW bukrs.

Regards

Sowbhagya

5 REPLIES 5
Read only

tanuja_wa
Explorer
0 Likes
870

Hi,

You can use COLLECT statement for this purpose

Read only

Former Member
0 Likes
870

Collect statement is giving me an error because collect works only for numbers, vendor number and company code are type c.

Read only

Former Member
0 Likes
871

Hi

Try using

AT END OF lifnr.

AT NEW bukrs.

Regards

Sowbhagya

Read only

0 Likes
870

I have tried it, but it is displaying incorrect results,

Please check my code:

LOOP AT gt_output INTO gwa_output.

LOOP AT t_bsik INTO w_bsik.

IF sy-subrc = 0.

AT END OF lifnr.

AT new bukrs.

sum.

gwa_output-pre_dmbtr = w_bsik-dmbtr.

MODIFY gt_output FROM gwa_output.

ENDAT.

ENDAT.

ENDIF.

ENDLOOP.

endloop.

Read only

Former Member
0 Likes
870

Thank you so much so your responses