‎2007 May 09 5:56 PM
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.
‎2007 May 09 6:23 PM
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...
‎2007 May 09 6:23 PM
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...
‎2007 May 10 4:37 PM
BSEG is a cluster table. Make sure you are using full key to access.