‎2016 Jul 20 5:30 PM
Hi, I need to get the VBRK data that corresponds to a particular VBAP record. The logical path would be accessing vbrk.vbeln using the VBRP table (vbrp.aubel = vbap.vbeln , vbrp.aupos = vbrp.posnr).
My problem is that, at least in our system, we don’t have an index with AUBEL/AUPOS, so a search as the above described results in a full table scan…
An additional issue is that I can have several vbrk.vbeln documents (cancelled or not) for a particular vbap.vbeln/vbap.posnr record, so the VBFA table is (I think) of not help here.
Any ideas?
Thanks in advance,
Luis
‎2016 Jul 20 5:39 PM
Hi,
Yes use VBFA, vbfa-vbelv = vbap-vbeln & vbtyp_n = 'M' & vbtyp_v = 'C.
You will get the invoice in VBFA-VBELN.
‎2016 Jul 20 5:46 PM
Sunil,
Thanks for your answer.
My problem is that I have two or more records with the same aubel/aupos in VBRP, corresponding to two or more VBRK(vbeln).
If I use VBFA I get only one record. In this case, the "valid" (not canceled) document. Nevertheless, I need to access all the vbeln records (canceled (fksto = 'X') ) or not.
Thanks again,
Luis
‎2016 Jul 20 5:43 PM
Hi
If you need to get the bills generated from a certain sales order, so your research needs to start from sales order, you need to use VBFA table (you can use fm RV_ORDER_FLOW_INFORMATION)
In VBFA table you should find cancelled bill too
Max
‎2016 Jul 20 6:44 PM
Max,
Thanks for your post. I'm afraid that, as far as I have been able to verify, the VBFA table shows only one record (the "valid" one).
For example, in VBAP I have:
VBELN = 6100627040, POSNR = 1
in VBFA I have:
VBELV = 6100627040, POSNV = 000001, VBELN = 8010100038, VBTYP_N = M
Nevertheless, if I check VBRP, I get two(2) differnt VBELNs for AUBEL = 6100627040 and AUPOS = 1
8010100035 (FKSTO = 'X')
8010100038 (FKSTO = space)
My problem is that VBRP is missing an AUBEL/AUPOS index, so the search is VERY slow.
Regards,
Luis
‎2016 Jul 20 7:07 PM
Hi
I don't know your flow, but I suppose it depends on how you're looking for in VBFA: try to check how bill 8010100035 is inserted in VBFA table
‎2016 Jul 20 7:22 PM
Hi Luis,
Not sure why you want to go to VBRP and fetch records from VBRP for sales order using AUBEL/SUPOS.
Fetch the billing documents from VBFA for both invoice and cancellation invoice (vbtyp_n = M, N) and validate those billing documents from VBRK and details from VBRP for entires in VBRK.
You also get cancelled invoices from VBFA as well so compare those from VBRK and get the corresponding details from VBRP for all entries in VBRK.
‎2016 Jul 20 7:44 PM
Sunil,
Our users want to query the sales documents (VBRK.VBELN) using the vbak.bstnk field (Customer purchase order number) . So far, so good...So we link these to the VBAP table (to check the sales document detail) and, as we need some additional data from the invoices (such as FKSTO (canceled status) and some Z-fields), we need the VBRK.VBELN value.
As I wrote before, if I check the VBFA table I get only one VBELN. If I use the VBRP table I may get two (or more). One (or more) of them may be canceled, a info that our users may find important.
Regards,
Luis
‎2016 Jul 20 7:53 PM
Max,
The bill 8010100035 appears in the VBELV table,pointing to the "canceling" bill (9910016265) , But the point here is that I need to get both 8* numbers from the single VBAP record, which I haven't been able to do without resorting to use the VBRP table (which is a big no-no in performance terms).
Regards,
Luis
‎2016 Jul 20 8:25 PM
HI Luis,
Yo should get all the invoices from VBFA , use VBTYP_N = (M & N) for single order and item if there are any cancellations you might get here as well.
‎2016 Jul 20 8:26 PM
‎2016 Jul 20 9:11 PM
Juwin,
Thanks for your post.
The problem is not extra entries from VBFA, is not ENOUGH entries. As I wrote in other posts, there are some vbrp.vbeln entries that do not appear in vbfa.
Googling around I have found several posts that advise against creating extra indexes for VBRP. In fact, our table is quite large, and I can understand the reasons for avoiding an additional index...
Regards,
Luis
‎2016 Jul 21 1:48 PM
Can post some screenshots of what you are seeing in VBFA vs VBRP?
Thanks,
Juwin
‎2016 Jul 21 2:00 PM
‎2016 Jul 21 2:46 PM
Juwin,
Thanks for ypur post. Here is (I hope 🙂 ) the data you requested...
Regards,
Luis
‎2016 Jul 21 2:50 PM
Thanks for your post.
I am aware of what SQVI is, and its functionality. Nevertheless, this is part of something that goes beyond of a simple query. Also, as I have posted before, the main problem here is that the VBRP query times are very slow where using only AUBEL/AUPOS.
Regards,
Luis
‎2016 Jul 21 3:00 PM
What were your selection parameters for VBFA select? Did you just input the order number? If yes, then I feel that, there is some issue with the document flow. Is this behavior specific to this document number or other cancelled documents also?
Can you also post a document flow diagram for this order, from VA03?
Thanks,
Juwin
‎2016 Jul 21 3:48 PM
Juwin,
VBFA was accessed using VBFA.VBELV = VBAP.VBELN and VBFA.POSNV = VBAP.POSNR.
If I check VA03 I get :
Order No. 6200206871 -> Delivery (sales inquiry) 7200214135 -> Billing No. 8010100038
And that's exactly what I would expect it to be for a valid order. The same results I get if I query the VBFA table using VBAP.VBELN.
There seem to be several other documents with the same behavior.
What bugs me is that the only references I can get to the canceled order are in VBRP and in VBAK..
I think I will have to bite the bullet and ask our DB people to create an index for VBRP.
Thanks for your help and interest in this case...
Regards,
Luis