08-17-2011 11:20 AM
Hi,
I am linking RSEG and BKPF but there is no direct link between these two tables except AWKEY but that is only first 16 char AWKEY of BKPF.
so i need to pick all entries from BKPF where BLART = 'RE' and BUDAT in DATE. Thus all the entries are coming in one internal table and then i loop through each entry and pick first 16 char of AWKEY and then link both the tables . But it is making the performance very low.
i want to select only those entries from BKPF which are related to my Purchase orders. is there any indirect way?
following is the code :
SELECT
matnr
werks
ebeln
belnr
gjahr
lfbnr
FROM rseg INTO TABLE itab11 FOR ALL ENTRIES IN it1 WHERE werks = it1-werks AND
matnr = it1-matnr AND ebeln = it1-ebeln.
SELECT "*ALL THE ENTRIES FROM BKPF ARE PICKED.*
awkey
gjahr
belnr
FROM bkpf INTO TABLE itab13 WHERE blart = 'RE' AND budat IN s_date.
LOOP AT itab13 .
itab14-awkey = itab13-awkey(16) . " *All the entries selected are looped through and first 16 char's are selected.*
itab14-gjahr = itab13-gjahr.
itab14-belnr = itab13-belnr.
APPEND itab14.
ENDLOOP.
SORT itab11 BY belnr gjahr.
SORT itab14 BY awkey gjahr.
LOOP AT itab11.
READ TABLE itab14 TRANSPORTING NO FIELDS WITH KEY awkey = itab11-belnr.
IF sy-subrc = 0.
tabix = sy-tabix.
LOOP AT itab14 FROM tabix WHERE awkey = itab11-belnr AND gjahr = itab11-gjahr .
itab15-matnr = itab11-matnr.
itab15-belnr = itab14-belnr. "* LOOPING THROUGH RSEG and SELECTING ENTRIES WHERE AWKEY = BKPF-AWKEY*
itab15-werks = itab11-werks.
itab15-ebeln = itab11-ebeln.
itab15-gjahr = itab11-gjahr.
itab15-awkey = itab14-awkey.
itab15-lfbnr = itab11-lfbnr.
APPEND itab15.
ENDLOOP.
ENDIF.
ENDLOOP.
how to link these two tables efficiently so tht performance can be improved ?
Edited by: VimalSharma on Aug 17, 2011 12:21 PM
<Added code tags>
Edited by: Suhas Saha on Aug 17, 2011 4:55 PM
08-18-2011 10:05 AM
Hi,
You can also try use RBKP to link RSEG.
Regards,
Ravi.
08-17-2011 12:11 PM
Hi,
use function AC_DOCUMENT_RECORD. This will return all documents related to the invoice, including BKPF.
Import parameters
I_AWTYP ='RMRP'
I_AWREF = <your invoice>
I_AWORG = <year>
I_AWSYS = <system>
Set X_DIALOG to space.
Roy
08-17-2011 1:48 PM
Hi,
I wrote:
=========
use function AC_DOCUMENT_RECORD. This will return all documents related to the invoice, including BKPF.
Import parameters
I_AWTYP ='RMRP'
I_AWREF = <your invoice>
I_AWORG = <year>
I_AWSYS = <system>
Set X_DIALOG to space.
==========
If you add another parameter:
I_AWTYP_INCL = 'BKPF'
You will only get BKPF documents.
This will speed up your development significantly.
Roy
08-23-2011 7:17 AM
Hi,
I am not able to find the records related to BKPF through function AC_DOCUMENT_RECORD. I have passed the necessary parameters but it gives me error of no document found for related invoice rather i could find related records through selec statement .
And do you think it will improve the performance because i have to call this function in a loop for each of the invoices.
Please suggest.
Thanks,
08-17-2011 12:11 PM
Hi
All account documnent generated by MIRO has the type equal to RMRP
BKPF-AWTYP = RMRP
Max
08-17-2011 12:40 PM
Hello Vimal,
In addition to what has been mentioned regarding SELECT i see a nested loop as well. Try to optimise its performance as well. There are many discussions in the forums regarding nested loops, please go through them!
BR,
Suhas
08-18-2011 10:05 AM
Hi,
You can also try use RBKP to link RSEG.
Regards,
Ravi.
08-19-2011 12:11 PM
Hi Vimal,
You can avoid LOOP part in below code:
SELECT "*ALL THE ENTRIES FROM BKPF ARE PICKED.*
awkey
gjahr
belnr
FROM bkpf INTO TABLE itab13 WHERE blart = 'RE' AND budat IN s_date.
LOOP AT itab13 .
itab14-awkey = itab13-awkey(16) . " *All the entries selected are looped through and first 16 char's are selected.*
itab14-gjahr = itab13-gjahr.
itab14-belnr = itab13-belnr.
APPEND itab14.
ENDLOOP.
BY changing itab13 internal table declaration:
types: begin of t_bkpf,
awkey(16),
gjahr type bkpf-gjahr,
belnr type bkpf-belnr,
end of t_bkpf.
data : itab13 type standard table of t_bkpf with header line.
Hope this helps.
BR
Dep
Edited by: DeepakNandikanti on Aug 19, 2011 1:12 PM
08-23-2011 7:19 AM
Hi Deepak,
I want to avoid using BKPF. so even if i change the defination of itab13, it will be slower.
Any suggestions.
Thanks,
Vimal