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

Calculation

Former Member
0 Likes
734

I have an internal table with vbelns from table vbak. Now I want to go to vbpa and calculate number of partners for these sales orders with partner functions 'ME', 'BU' or 'GS'. Can you provide a sample code for this ?

Thanks a lot.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
704

Hi,

Please try this.


data: l_count type i.

loop at itab.
  select count(*) 
  into l_count
  from vbpa 
  where vbeln = itab-vbeln 
    and parvw in ('ME','BU',GS').

  write: / itab-vbeln, 'total records:', l_count.
endloop.

Hope this will help.

Regards,

Ferry Lianto

5 REPLIES 5
Read only

Former Member
0 Likes
704

select count(*) into lcnt

from vbpa

where partner function in ('ME','BU','GS')

and vbeln = itab-vblen.

Read only

Former Member
0 Likes
704

data: v_count type i.

if not it_vbak[] is initial.

Select count(*) into v_count

from vbpa

for all entries in it_vbak

where vbeln = it_vbak-vbeln and

parvw in ('ME','BU',GS').

endif.

Read only

Former Member
0 Likes
704

Hi Krishen,

DATA IT_VBAK TYPE STANDARD TABLE OF VBAK OCCURS 0 WITH HEADER LINE.

DATA:

BEGIN OF IT_VBPA OCCURS 0,

VBELN TYPE VBPA-VBELN,

NO_PARTNERS TYPE I,

END OF IT_VBPA.

IF IT_VBAK[] IS NOT INITIAL.

SELECT VBELN COUNT( * )

FROM VBPA

INTO TABLE IT_VBPA

FOR ALL ENTRIES IN IT_VBAK

WHERE VBELN = IT_VBAK-VBELN

AND PARVW IN ( 'ME', 'BU', 'GS' )

GROUP BY VBELN.

ENDIF.

Thanks,

Vinay

Read only

Former Member
0 Likes
705

Hi,

Please try this.


data: l_count type i.

loop at itab.
  select count(*) 
  into l_count
  from vbpa 
  where vbeln = itab-vbeln 
    and parvw in ('ME','BU',GS').

  write: / itab-vbeln, 'total records:', l_count.
endloop.

Hope this will help.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
704

Hi,

tables : vbak, vbpa.

data : begin of it_vbak occurs 0,

vbeln like vbak-vbeln,

end of it_vbak.

data : begin of it_vbpa occurs 0,

vbeln like vbpa-vbeln,

parvw like vbpa-parvw,

end of it_vbpa.

select-options : s_vbeln for vbak-vbeln.

start-of-selection.

select vbeln

from vbak

into table it_vbak

where vbeln in s_vbeln.

select vbeln

parvw

from vbpa

into table it_vbpa

for all entries in it_vbak

where vbeln = it_vbak-vbeln and

parvw in ('ME', 'BU', 'GS') .

if sy-subrc = 0.

endif.

end-of-selection.

Regards,

Azaz.