cancel
Showing results for 
Search instead for 
Did you mean: 

Joining table VBEP and VBAP

former_member620734
Participant
0 Kudos

I am creating a report for BOL. My requirement

If u201CFixed date and qtyu201D field in checked and line NOT confirmed in Schedule line tab in the sales order, my report should display that line item. In my report I am using these table VBAP, VBUP, VBAK, VBUK.

Here is the code for schedule line confirmed qty in my report

data: lv_ETENR like VBEP-ETENR.

CLEAR: ZCONFQTY, lv_ETENR.

SELECT SINGLE BMENG MAX( ETENR )

into (ZCONFQTY, lv_ETENR)

from VBEP

where VBELN = VBAP-VBELN

and POSNR = VBAP-POSNR

GROUP BY BMENG.

My report working fine if a line item is confirmed fully. HOWEVER, it is not working if a line items qty splits into two different schedule lines and one is confirmed and others are unconfirmed. For example: Sales order line item qty is for 60. Two schedule line

Delivery Order qty Rounded qty confirmed qty

05/10/2010 10 10 0

05/15/2010 50 50 50

Do I need to change my code to catch multiple schedule line? If yes, can you please give me the code? Thank you so much....

VBEP (ETENR, POSNR, BMENG) VBAP-VBELN

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member620734
Participant
0 Kudos

Thank you so much for the answer. I really appreciated. I am not a developer; I am kind of confused here. Since, I am creating a new field called ZCONFQTY that is where my confirmed qty will be populated in the output. In your code, I donu2019t see that field, so I am not sure how is it going to work. If you donu2019t mind can you please be more specific in the code. Like DATA, CLEAR etc

Your code:

data: it_vbep, is_vbep.

CLEAR: ZCONFQTY, it_vbep, is_vbep.

Select vbeln posnr BMENG ETENR

into Table it_VBEP

where vbeln = vbap-vbeln

and posnr = vbap-posnr.

loop at it_vbep into is_vbep.

collect is_vbep into it_vbep_tmp.

endloop.

read table it_vbep_tmp into is_vbep index 1.

if vbap-menge = is_vbep-bmeng.

endif.

My code:

data: lv_ETENR like VBEP-ETENR.

CLEAR: ZCONFQTY, lv_ETENR.

SELECT SINGLE BMENG MAX( ETENR )

into (ZCONFQTY, lv_ETENR)

from VBEP

where VBELN = VBAP-VBELN

and POSNR = VBAP-POSNR

GROUP BY BMENG.

As always, thanks so much for your help

Former Member
0 Kudos

Types : Begin of ts_vbep,
             vbeln type vbep-vbeln,
             posnr type vbep-posnr,
             bmeng type vbep-bmeng,
             etenr   type vbep-etenr,
           end of ts_vbep.

data: it_vbep type table of ts_vbep,
        is_vbep type ts_vbep,
        it_vbep_tmp type table of ts_vbep.
data: ZCONFQTY type vbep-bmeng.

Clear : ZCONFQTY.
Select vbeln posnr BMENG ETENR
into Table it_VBEP
where vbeln = vbap-vbeln
and posnr = vbap-posnr.
loop at it_vbep into is_vbep.
ZCONFQTY = ZCONFQTY + is_vbep-bmeng.
endloop.

if vbap-menge = ZCONFQTY.
write: 'Completely Confiremed',ZCONFQTY.
else.
write: 'Completely Not Confiremed', ZCONFQTY.
endif.

Please post again if any problem.

Regards,

Srinivas.

Former Member
0 Kudos

Hi,

Try this Code.


Select vbeln posnr BMENG ETENR
into Table it_VBEP
where vbeln = vbap-vbeln
and posnr = vbap-posnr.
loop at it_vbep into is_vbep.
collect is_vbep into it_vbep_tmp.
endloop.
read table it_vbep_tmp into is_vbep index 1.

if vbap-menge = is_vbep-bmeng.
endif.

In above code if condition is successful means quantity is completely confirmed other wise not.

Regards,

Srinivas.