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

performance about vbfa

Former Member
0 Likes
3,001

DATA: LT_VBFA TYPE STANDARD TABLE OF VBFA WITH HEADER LINE.

LT_VBFA-VBELN = '0086152431'.

LT_VBFA-POSNN = 10.

APPEND LT_VBFA.

LT_VBFA-POSNN = 20.

APPEND LT_VBFA.

LT_VBFA-POSNN = 30.

APPEND LT_VBFA.

LT_VBFA-POSNN = 40.

APPEND LT_VBFA.

LT_VBFA-POSNN = 50.

APPEND LT_VBFA.

LT_VBFA-POSNN = 60.

APPEND LT_VBFA.

select * into corresponding fields of table lt_vbfa

from vbfa

for all entries in lt_vbfa

where vbeln = lt_vbfa-vbeln and posnn = lt_vbfa-posnn and

      VBTYP_V = 'C'.

Dear: all.

in the prd system,i used t-code 'SE30‘ ,test the performance of vbfa  with previous code

i Excute the code a few times,the Runtime is about 2,300,000 microseconds, that is about 2 seconds

but actually, from i click the button "mesure runtime" , to the system show how much time spend, at least 2~3 Minutes gone

why?

should i create a index for vbfa using vbeln posnn and vbtyp_v?

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,536

Actually there is no delivered index on VBFA with key VBELN and POSNN (*), but primary keys start with VBELV and POSNV. So preceeding document is used to search for the subsequent document.

You could create an index BUT there are usually other solutions, depending on actual type of documents, you shoud access an other table, replacing a wrong SELECT vbelv FROM vbfa WHERE vbeln with either


SELECT vgbel FROM lips WHERE vbeln
SELECT vgbel FROM vbrp WHERE vbeln
SELECT aubel FROM vbrp WHERE vbeln

There is a reference note 185530 - Performance: Customer developments in SD

Regards
Raymond

(*) Business function JMPS_MODIF 'Media: Modifications Media Product Sales' contain such index, but not sure it is activated.

10 REPLIES 10
Read only

philipdavy
Contributor
0 Likes
2,536
  • I am not understanding your code, you are selecting into internal table lt_vbfa and using the 'for all entries in' statement with the same internal table lt_vbfa.
  • Are you missing any 'loop at it' statement here ?

Regards,

Philip

Read only

0 Likes
2,536

this is supported by abap

1. using condition in lt_vbfa to fetch data

2. move the result into lv_vbfa

Read only

Former Member
0 Likes
2,536

Hello,

While using For All entries statement, SAP will break down your entries in this section to a number 5 as default and will query the database that time of times.

for e.g if you have 1000 data in ur table, system will query the database 1000/5 times.

solution for this would be using range instead of for all entries.

it will fetch the data with only one database call.

Read only

0 Likes
2,536

yes, it is easy to get what you said using st05, "for e.g if you have 1000 data in ur table, system will query the database 1000/5 times."

my question is why the system report runtime is 2 seconds while the actually time spend to excute the code in se30 is 3 minutes

Read only

0 Likes
2,536
  • Why are you complicating the things ?
  • What you need is a range table with the some values for POSNN, for that try to create a range table.(rg_posnn)
  • Then build a select query for VBFA where POSNN in rg_posnn & vbeln = '0086152431' &    VBTYP_V = 'C'.

Regards,

Philip.

Read only

Former Member
0 Likes
2,536

Hi,

Please check your code!

- why you are reading and using the lt_vbfa in code. It is not required and remove the statement.

- Are you really looking for all fields in VBFA...try to avoid * and use required fields.

- You are already using the secondary index!

Check your code once again and there are FM's are available to read VBFA , please check.

BG,

Kiran

Read only

0 Likes
2,536

yes but the index is switch off

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,537

Actually there is no delivered index on VBFA with key VBELN and POSNN (*), but primary keys start with VBELV and POSNV. So preceeding document is used to search for the subsequent document.

You could create an index BUT there are usually other solutions, depending on actual type of documents, you shoud access an other table, replacing a wrong SELECT vbelv FROM vbfa WHERE vbeln with either


SELECT vgbel FROM lips WHERE vbeln
SELECT vgbel FROM vbrp WHERE vbeln
SELECT aubel FROM vbrp WHERE vbeln

There is a reference note 185530 - Performance: Customer developments in SD

Regards
Raymond

(*) Business function JMPS_MODIF 'Media: Modifications Media Product Sales' contain such index, but not sure it is activated.

Read only

0 Likes
2,536

I agreed, Thanks!

Read only

0 Likes
2,536

yes i created a secondary index to solve the performance of reading vbfa

and i also considered your solution before i asked the question

but the first doc is accounting document,then to business document,

such as sales doc, trading doc, even purchase doc.

if using this solution, i have to know where every accounting doc come from,

and what kind of document to be counted,

too much business sense involved, i need a sd consultant to help me

maybe, someday in the future,we will recheck the logic of this report, and overwrite it

Thanks~