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

Perf Tuning using BAPI_AR_ACC_GETBALANCEDITEMS & BAPI_AR_ACC_GETOPENITEMS

Former Member
0 Likes
1,780

Hi All,

Need your help/advice on a report which extracts data for open items and balanced items for all customers by calling std BAPI's BAPI_AR_ACC_GETOPENITEMS & BAPI_AR_ACC_GETBALANCEDITEMS inside the loop for customers.

The data retrieval is taking quite a long time (~60K ms), request you to let me know if we can enhance this report by any means.

Would creating indexes for BSID & BSAD table be of any help? Coz BAPI_AR_ACC_GETOPENITEMS selects data from BSID based on BUDAT, BUKRS, KUNNR & BSTAT, and BAPI_AR_ACC_GETBALANCEDITEMS queries BSAD based on AUGDT, BUKRS, KUNNR, BSTAT.

The trace analysis for the same also shows that majority of the time is taken for fetching data.

Please share your thoughts on the same.

Regards,

Narendra.

7 REPLIES 7
Read only

ThomasZloch
Active Contributor
0 Likes
1,318

Normally the access inside such BAPIs is optimized, and also looking at the fields you are mentioning that are used for accessing BSID and BSAD, I see no need for new indexes.

"60K ms" is 1 minute, depending on how many entries you are reading, this might be normal runtime.

You can maybe look at replacing the BAPI calls by your own data retrieval logic for a range of customers instead of one by one.

Thomas

Read only

0 Likes
1,318

Sorry Thomas, there is a typo in my thread. The time taken is ~600K ms which is approximately10 minutes. So I believe this can be considered for performance tuning. Please advice.

Regards,

Narendra.

Read only

0 Likes
1,318

What is the number of records in BSID and BSAD. When you say "all items for all customers", do you really mean for all company codes and irrespective of posting date?

As I mentioned, you should replace the function module calls by your own code, especially reading only the fields from the database that you really require for further processing.

The BAPIs are designed to obtain all potentially relevant items data for one customer, and your scenario is a bit different.

Thomas

Read only

0 Likes
1,318

Hi Thomas,

The company code is fixed and the data for open items/balanced items is fetched where posting date is <= to the month end date entered by the user in the selection screen.

In this scenario we have customers around ~15000 and the number of entries is as below:

BSID - 466500; BSAD - 8875933

Ideally I require only the amount in LC_AMOUNT, doc_type, pstng_date & post_key from the table returned by the BAPI which is of type BAPI3007_2.

So would you advise that instead of using the BAPI calls retrieve the data directly from the database tables instead which would prevent the unnecessary code in the std BAPI's?

Regards,

Narendra.

Read only

0 Likes
1,318

> So would you advise that instead of using the BAPI calls retrieve the data directly from the database tables instead which would prevent the unnecessary code in the std BAPI's?

In this case, yes. BAPIs are generally a good thing to encapsulate coding logic, but for mass processing the overhead can be too large. Here, you need only four fields, whereas the BAPIs read more than 100. I'm sure you can save some processing time and a lot of memory by selecting only those four fields, and for a range of customers instead of one by one. But there will still be some runtime, because it is quite a lot of data, which cannot be read in just a few seconds.

Try it out and compare.

Thomas

Read only

0 Likes
1,318

Thomas - Yeah even I was thinking about the same to extract just the 4 required fields. Shall try out the same and let you know. Thanks for your suggestion.

Regards,

Narendra.

Read only

Former Member
0 Likes
1,318

Modified code to improve perf.