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

Select in VBFA Table

Former Member
0 Likes
2,048

Hello All,

We need to improve performance in a program that uses VBFA table in three ways. How can we avoid this table or what we have to do in select statements to improve the program performance.

1) select vbeln posnn vbelv posnv vbtyp_n vbtyp_v

into table it_vbfa1

from vbfa

where vbtyp_n = 'R'

and erdat in r_budat.

2) select vbeln posnn vbelv posnv vbtyp_n

appending table it_vbfa1

from vbfa

for all entries in it_mseg_vbfa_nf

where vbeln = it_mseg_vbfa_nf-vbeln

and posnn = it_mseg_vbfa_nf-posnn

and vbtyp_n = 'R'

3) select vbelv posnv vbeln posnn vbtyp_n

into table it_vbfa2

from vbfa

for all entries in it_vbfa1

where vbelv = it_vbfa1-vbelv

and posnv = it_vbfa1-posnv.

Points will be rewarded!

Thanks,

Michel Khouri

Mars, Inc

7 REPLIES 7
Read only

Sougata
Active Contributor
0 Likes
1,320

2) First check it_mseg_vbfa_nf[] is not initial before executing the 'Select'. This will speed up performance.

3) What's the use of the third select?? I think copying will do the trick and save a lot of runtime -> it_vbfa2[] = it_vbfa1[].

Cheers.

Read only

Former Member
0 Likes
1,320

what about create an index for first Open SQL? As vbfa is very big, full table scan will cost a lot of time.

two and three look like no problem, but if itab is very big FOR ALL ENTRIES IN may be not a good solution.

Regards,

-Tim

Read only

0 Likes
1,320

Tim,

Creating an index for this big table will duplicate it on the database? Probably our Basis will not allow us to do this.

Is it possible to use other tables instead of VBFA?

And how can we substitute "for all entries" option in order to optimize performance?

Thanks,

Michel Khouri

Read only

0 Likes
1,320

Hi,

Have you considered my suggestion above? Try that, I'm sure that'll improve the performance.

Also, it is not possible to replace any other table with VBFA and "FOR ALL ENTRIES" syntax was developed by SAP specifically to handle performance problems resulting from database selects.

Cheers.

Read only

Former Member
0 Likes
1,320

Michael,

SORT it_mseg_vbfa_nf BY vbeln posnn.

IF NOT it_mseg_vbfa_nf[] IS INITIAL.

select vbeln posnn vbelv posnv vbtyp_n

INTO table it_vbfa1

from vbfa

for all entries in it_mseg_vbfa_nf

where vbeln = it_mseg_vbfa_nf-vbeln

and posnn = it_mseg_vbfa_nf-posnn

and vbtyp_n = 'R'

ENDIF.

Don't forget to reward if useful....

Read only

former_member784222
Active Participant
0 Likes
1,320

Hi,

Try to use the following FM to read from VBFA.

SD_VBFA_ARRAY_READ_VBELV

SD_VBFA_READ_WITH_VBELV

SD_VBFA_SELECT

SD_VBFA_SINGLE_READ

SD_VBFA_TRANSFER_TO_BUFFER

Thanks and regards,

S. Chandra Mouli.

Read only

Madhurivs23
Participant
0 Likes
1,320

I want to take the delivery docs corresponding to the billing docs from table vbfa.

so i have given selection criteria as

vbfa-vbeln = BILL_DOC_NO

AND vbtyp_v = 'J'

and vbtyp_n = 'M'.

code IS LIKE THIS :

t_bill_list table contains the invoice nos.

code 1)

select distinct

vbelv

vbeln

into table t_bill_del_data

from vbfa

for all entries in t_bill_list

where vbeln eq t_bill_list-vbeln

and vbtyp_v = 'J'

and vbtyp_n = 'M'

the above query was taking time so i changed that to -->

code 2)

loop at t_bill_list into wa_bill_list.

select single

vbelv

vbeln

into wa_bill_del_data

from vbfa

where vbeln eq wa_bill_list-vbeln

and vbtyp_v = 'J'

and vbtyp_n = 'M'.

if sy-subrc = 0.

append wa_bill_del_data to t_bill_del_data.

clear wa_bill_del_data.

endif.

endloop.

but both the codes have poor performance.

Plus the index cannot be created on the table vbfa

please help.

rgds

Madhuri