‎2007 Apr 24 1:44 AM
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
‎2007 Apr 24 2:34 AM
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.
‎2007 Apr 24 2:45 AM
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
‎2007 Apr 24 12:53 PM
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
‎2007 Apr 25 2:00 AM
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.
‎2007 Apr 24 3:54 AM
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....
‎2007 Apr 25 5:51 AM
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.
‎2007 Sep 16 10:22 AM
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