‎2007 Sep 28 2:37 PM
Hi ABAP Gurus,
I am working on pricing routines for return orders.
in this return order i am getting reference docuemnt number .
now i need to find that this reference document is sales order or invoice .
how can i find this .
i know i need to use VBFA table . but i am confused in precedding and subsequent document.
please guide me how can i find this.
Thnaks,
Neo
‎2007 Sep 28 2:54 PM
Hi
In the routine write a single select to VBUK table
select single VBTYP from VBUK into v_vbtyp where vbeln = ref doc no.
this will give the doc type
Regards
Anji
‎2007 Sep 28 2:54 PM
Hi
In the routine write a single select to VBUK table
select single VBTYP from VBUK into v_vbtyp where vbeln = ref doc no.
this will give the doc type
Regards
Anji
‎2007 Sep 28 3:02 PM
If you have an example you should be able to work it out by looking at the values in SE16. With the fields in the normal order the reference document item are the first two, the subsequent ones are the next two.
Howver VBFA isn't the correct solution here. One, the order of fields given means it's optimised for tracking forward, not back. Second, if you haven't yet saved the new document it probably isn't updated yet.
Better to look for fields with names like VGBEL and VGPOS; if you find the document/item combination in VBRP it's an invoice, if you find it in VBAP it was an order.
‎2007 Sep 28 3:07 PM
If you have an example you should be able to work it out by looking at the values in SE16. With the fields in the normal order the reference document item are the first two, the subsequent ones are the next two.
Howver VBFA isn't the correct solution here. One, the order of fields given means it's optimised for tracking forward, not back. Second, if you haven't yet saved the new document it probably isn't updated yet.
Better to look for fields with names like VGBEL and VGPOS in structures like XVBAP, VBAP or KOMP; if you can find the document/item combination in VBRP it's an invoice, if you find it in VBAP it was an order.
‎2007 Sep 28 3:19 PM
VBAK-VGTYP will give you the document category and once you know which document category it is, you can go to either VBAK or VBRK with the number to get the document type (VBAK-AUART or VBRK-FKART).
‎2007 Sep 28 4:23 PM
> I am working on pricing routines for return
> orders.
> in this return order i am getting reference docuemnt
> number .
> now i need to find that this reference document is
> sales order or invoice .
> how can i find this .
> i know i need to use VBFA table . but i am confused
> in precedding and subsequent document.
Since you mention the pricing routines, I guess you are working on a VOFM routine or a user exit. I think that Anji gave the best universal solution for finding the document type by using VBUK table. VBFA table should not be used for this purpose IMHO.
Additionally, inside the VOFM routine or a user exit you might be able to use VBPA or XVBPA/YVBPA table - the field VGTYP will contain the reference document category for each line. C = order, M = invoice, there are several orders, which you can see in SE11.
Just FYI "preceding document" in VBFA is the document that was created first. For example, a sales order is a "preceding document" and the corresponding outbound delivery is a "subsequent document".
Hope this helps and good luck!