01-29-2008 5:23 PM
please explain what is this subsequent(VBELN) and precendent(VEBLV) documents in VBFA.
How they are related to each other.
I also didn't understand the following code related to VBFA:
LOOP AT it_so.
SELECT SINGLE name1 FROM kna1 INTO v_name
WHERE kunnr = it_so-kunnr.
SELECT SINGLE vbeln FROM vbfa INTO v_delnum
WHERE vbelv = it_so-vbeln
AND vbtyp_n = 'J'.
IF sy-subrc = 0.
SELECT SINGLE vbeln FROM vbfa INTO v_invnum
WHERE vbelv = v_delnum
AND vbtyp_n = 'M'.
ENDIF.
01-29-2008 5:33 PM
VBFA is the table where the document flow is stored. This table is VERY usefull. Imagine that you have a Sales Order and you want to know which deliveries it's realted to. You go to VBFA with VBELV (Preceding document) = SALES ORDER and VBTYP_N (Type of subsecuent document) = 'J'. The result are the deliveries (VBELN) related to that sales document.
Here is stored a lot of document relationships, not only the one I've mentioned, check field VBTYP_N for more detail. The use of this table is that if you need to go backwards in the document flow, you just check the content of the related document fields (LIPS-VGBEL in our example), but when going forewards, you would need to change the sales order to store the delivery number and furthermore, more than one delivery could be related to the sales order, hence the need of this table.
Last but not least, remember that this table is for going FORWARDS in the document flow. Never us it to go backwards, because it has low performance (the table is not indexed in that way). You should check the reference fields as I said before.
I hope I've been clear, <REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Jan 29, 2008 2:08 PM
01-29-2008 6:00 PM
Hi Pablo,
Thank you for the detailed explanation. I still have one doubt in this. We can get delivery number by comparing POSNR in LIPS with VBELN in VBAK or VBAP accordingly. Then why we should go with VBLV which is a preceeding document in VBFA.
01-29-2008 6:09 PM
You can get the delivery if you do:
SELECT vbeln FROM lips
INTO lv_vbeln
WHERE vgbel EQ vbap-vbeln
AND vgpos EQ vbap-posnr.
That works, but LIPS is not indexed by vgbel and vgpos (in fact it doesn't have any index at all) so the query will take ages.
On the other hand, using VBFA as I said before, you may access the delivery in no time. SAP adds redundancy to increase performance. Try it yourself in the SE16 in a client with a lot of data in LIPS and you will understand better.
Regards!
Pablo
01-29-2008 5:44 PM
It's looking for deliveries (vbtyp_n = 'J') for the sales order.
Rob