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

how to get order type from reference document

Former Member
0 Likes
2,081

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,552

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

5 REPLIES 5
Read only

Former Member
0 Likes
1,553

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

Read only

Former Member
0 Likes
1,552

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.

Read only

Former Member
0 Likes
1,552

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.

Read only

Former Member
0 Likes
1,552

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).

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
1,552

> 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!