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

Read FI Document efficiently

zheng_yingjie
Explorer
0 Likes
782

Hi,

I have a question here, I am now creating a report for Goods Receipt(GR) and Invoices Receipt(IR) based on PO selection. I know that from EKBE table we can get all the GR/IR history for each PO item, but I am required to get GR/IR amount/quantity from FI document, which is BSEG table, because I need to get the amount based on G/L account. May I know what is the efficient way in order to get this? I am currently using SAP R/3 v4.7

What I am doing now is:

1. looping in the PO data.

1. read EKBE data using FM 'ME_READ_HISTORY',

2. loop in the ekbe data returned from the FM,

3. read Material Document,

4. get accounting document by using FM 'FI_DOCUMENT_RECORD'

5. get amount and quantity from BSEG table.

And what I am doing now causing performance problem when transported to Testing Evironment, please tell me what is the efficient way.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
688

always avoid a select statement inside a loop.

first select from ekpo.

select from ekbe for all entries in it_ekpo.

select from mseg /mkpf for all entries in it_ekbe.

select from bseg for all entries in it_mseg.

now

loop at it_ekpo.

read table it_ekbe where ebeln = it_ekpo-ebeln and ebelp = it_ekpo-ebelp.

if sy-subrc = 0.

move this value to an in tab.

endif.

read table it_mseg..

read it_bseg..

modify intab...

endloop...

2 REPLIES 2
Read only

Former Member
0 Likes
689

always avoid a select statement inside a loop.

first select from ekpo.

select from ekbe for all entries in it_ekpo.

select from mseg /mkpf for all entries in it_ekbe.

select from bseg for all entries in it_mseg.

now

loop at it_ekpo.

read table it_ekbe where ebeln = it_ekpo-ebeln and ebelp = it_ekpo-ebelp.

if sy-subrc = 0.

move this value to an in tab.

endif.

read table it_mseg..

read it_bseg..

modify intab...

endloop...

Read only

alison_lloyd
Active Participant
0 Likes
688

BSEG is a cluster table. Make sure you are using full key to access.