2015 Jul 16 11:58 AM
Hello all,
I want to select the original invoice number from the Cred.Note:Returns.
For this I am querying table VBFA, but it is taking a long time.
Is there an alternate table I can use or some FM ?
Thanks for your reply.
2015 Jul 16 2:26 PM
Hi Virginia,
It is not recommended to do query on VBFA on the subsequent doc. For that normal Item tables are sufficient.
I am not sure your process flow here.
I am guessing : Original Invoice ->Return Order->Return->Return Delivery->Credit Note: Returns?
Get AUBEL AUPOS from VBRP for Credit Note(VBRP-VBELN). VBRP-AUBEL will be your Return Order,
Query VBAP by passing VBELN = VBRP-AUBEL and POSNR = VBRP-AUPOS and get VGBEL .
VBAP-VGBEL will be your Original Billing Doc provided the Return Order was created with reference to the Original Billing Doc.
In this way you will ensure you hit the Primary Index key all the time which will definitely be faster.
OR,
You can try FM SD_DOCUMENT_FLOW_GET. I never used it but by seeing the code it is trying from VBFA. So may not be good in this case.
R
2015 Jul 16 2:15 PM
Hello,
You may want to narrow your select with POSNN or check which indexes you have for VBFA and adjust your select accordingly to improve performance, but this technique is still somewhat doubtful.
Why don’t you simply take it from VBRP-VGBEL/VGPOS?
Regards
2015 Jul 16 3:05 PM
Cannot use VBRP-VGBEL/VGPOS since I want the original invoice number from the Cred.Note:Returns and not the delivery
2015 Jul 16 2:26 PM
Selection using succeeding document is slow in VBFA.
Options:
1. Create an index for the fields VBTYP_N, VBELN, POSNN
2. Select the preceeding document from VBRP-VGBEL/ AUBEL, instead of using VBFA.
Thanks,
Juwin
2015 Jul 16 2:26 PM
Hi Virginia,
It is not recommended to do query on VBFA on the subsequent doc. For that normal Item tables are sufficient.
I am not sure your process flow here.
I am guessing : Original Invoice ->Return Order->Return->Return Delivery->Credit Note: Returns?
Get AUBEL AUPOS from VBRP for Credit Note(VBRP-VBELN). VBRP-AUBEL will be your Return Order,
Query VBAP by passing VBELN = VBRP-AUBEL and POSNR = VBRP-AUPOS and get VGBEL .
VBAP-VGBEL will be your Original Billing Doc provided the Return Order was created with reference to the Original Billing Doc.
In this way you will ensure you hit the Primary Index key all the time which will definitely be faster.
OR,
You can try FM SD_DOCUMENT_FLOW_GET. I never used it but by seeing the code it is trying from VBFA. So may not be good in this case.
R
2015 Jul 16 3:06 PM
Thanks for your reply Rudra.
Function Module ‘WB2_VBFA_READ_WITH_VBELN’ solved my problem