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: 

Query Billing

antonio_bruno
Participant
0 Kudos
146

Hi,

i've created a SAP Query, but i've a problem to join vbrp-aupos with ekpo-ebelp. How can i join the two fields?

Thank you in advance.

Antonio

4 REPLIES 4

Former Member
0 Kudos
81

as they have absoluteley NOTHING to do witheach others, you will NEVER be able to join them.

VBRP-AUPOS holds the SALES ORDER itemnumber, while EKPO.EBELP holds the PURCHASE ORDER tiemnumber.

0 Kudos
81

I'm agree with you, but my problem is reffered to the intercompany flow. The sales invoice is generated by purchase order.

So i want join the number of PO (VBRP-AUBEL) with the EKPO-EBELN (OK) and the related position number (VBRP-AUPOS) with EKPO-EBELP (not permitted).

I think the problem is the length of the field, but I do not know how I can make them equal.

Thank you.

Edited by: Antonio Bruno on Aug 4, 2011 11:16 AM

0 Kudos
81

ok, stating it a bit more detailed:

VBRP-AUBEL = Number of according related sales order.

VBRP-AUPOS = Number of according related sales order item .

Table EKPO holds Purchase order items. Even if there wouldnt be a problem in field length (SO items have char6 while PO items have char5), this join can never work from the logical view.

If you got a sales order number and an item number it makes no sense to search in table EKPO for them, since the according records are stored in table VBAP.

If you need the PO for your invoice i´d go via table VBFA.


data: lv_vbelv     type vbeln,
         lv_posnv    type pstvy.

select single vbelv posnv
from   vbfa
into    (lv_vbelv, lv_posnv)
where vbeln = vbrp-aubel
and    vbeln = vbrp-aupos
and    vbtyp_n = 'V'.

now you got the EBELN and EBELP in variables LV_VBELV and LV_POSNV.
with these you can goto table ekpo.

0 Kudos
81

Iu2019ve checked in the VBFA, but there isnu2019t these datas because the flow is:

PO --> Delivery intercompany & Goods issue --> Intercompany Billing

So I thought to join directly the data that Iu2019ve in the vbrp with ekpo.

Do you now how I can add the abap code to the SQ01?

Thanks.