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

Join from header table and from item level

Former Member
0 Likes
885

From an invoice, I want to find the service order (IW33), and some extra information.

I start with the invoice no

Select VBELV from VBFA where VBELN = <invoice_no>

and here I get the VBELV (VBFA-VBELV and VBFA-POSNV).

Select AUFNR from VBAP where vbeln = <VBFA-VBELV>

and posnr = <VBFA-POSNV>

Finally we select from VBUK where VBELN = <VBFA-VBELV>

from where we need the value FKSTK and FKSAK.

My problem is how to select (prefer to use a join) when I have to select data from header tables, and also "item" data, so I can select above data

(VBFA-VBELV, VBFA-POSNV, VBAP-AUFNR, VBUK-FKSTK, VBUK-FKSAK),

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
576

First of all, you DON'T want to read VBFA backward...if you look at SAP Notes about VBFA, you'll see that the recommendation is to always read old to get new....rather than read backward, get the prior documents from VBAP, LIPS or VBRP.

If you have invoice number, use VBRP-AUBEL, AUPOS, if you can, to get your SO number/item. Simple to join to VBUK or VBUP on vbeln/posnr once you have order/item. And a read on VBAK with the primary key should be relatively inexpensive to get the Service Order Number.

From an invoice, I want to find the service order (IW33), and some extra information.

I start with the invoice no

Select VBELV from VBFA where VBELN = <invoice_no>

and here I get the VBELV (VBFA-VBELV and VBFA-POSNV).

Select AUFNR from VBAP where vbeln = <VBFA-VBELV>

and posnr = <VBFA-POSNV>

Finally we select from VBUK where VBELN = <VBFA-VBELV>

from where we need the value FKSTK and FKSAK.

My problem is how to select (prefer to use a join) when I have to select data from header tables, and also "item" data, so I can select above data

(VBFA-VBELV, VBFA-POSNV, VBAP-AUFNR, VBUK-FKSTK, VBUK-FKSAK),

1 REPLY 1
Read only

Former Member
0 Likes
577

First of all, you DON'T want to read VBFA backward...if you look at SAP Notes about VBFA, you'll see that the recommendation is to always read old to get new....rather than read backward, get the prior documents from VBAP, LIPS or VBRP.

If you have invoice number, use VBRP-AUBEL, AUPOS, if you can, to get your SO number/item. Simple to join to VBUK or VBUP on vbeln/posnr once you have order/item. And a read on VBAK with the primary key should be relatively inexpensive to get the Service Order Number.