Application Development 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: 

Selection from VBFA table takes a long time

Former Member
0 Kudos
2,029

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.

SELECT VBELV
      FROM VBFA
      INTO TBL_VBRK-VBELV
             WHERE VBTYP_N = 'M'
                    AND VBELN   = TBL_VBRK-VBELN.
ENDSELECT.

Is there an alternate table I can use or some FM ?

Thanks for your reply.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
476

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

5 REPLIES 5

AntonFarenyk
Contributor
0 Kudos
476

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

0 Kudos
476

Cannot use VBRP-VGBEL/VGPOS since I want the original invoice number from the Cred.Note:Returns and not the delivery

Juwin
Active Contributor
0 Kudos
476

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

Former Member
0 Kudos
477

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

476

Thanks for your reply Rudra.

Function Module  ‘WB2_VBFA_READ_WITH_VBELN’  solved my problem