2010 Aug 17 7:11 PM
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),
2010 Aug 17 7:54 PM
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.
2010 Aug 17 7:54 PM
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.