07-04-2007 1:13 AM
Hi forum i have a really problem in the second query under the table
BKPF.. some body cans help me, please
*THIS IS THE QUERY UNDER MSEG
SELECT tmsegmblnr tmkpfbudat tmsegbelnr tmsegbukrs tmseg~matnr
tmsegebelp tmsegdmbtr tmsegwaers tmsegwerks tmseg~lgort
tmsegmenge tmsegkostl
FROM mseg AS tmseg JOIN mkpf AS tmkpf ON tmsegmblnr = tmkpfmblnr
INTO CORRESPONDING FIELDS OF TABLE it_docs
WHERE
tmseg~bukrs IN se_bukrs AND
tmkpf~budat IN se_budat AND
tmseg~mjahr = d_gjahr AND
( tmsegbwart IN se_bwart AND tmsegbwart IN (201,261) ).
IF sy-dbcnt > 0.
I CREATE AWKEY FOR CONSULTING BKPF
LOOP AT it_docs.
CONCATENATE it_docs-mblnr d_gjahr INTO it_docs-d_awkey.
MODIFY it_docs.
ENDLOOP.
THIS IS THE QUERY WITH BAD BAD PERFOMANCE
I NEED KNOW "BELNR" FOR GO TO THE BSEG TABLE
SELECT belnr awkey
FROM bkpf
INTO CORRESPONDING FIELDS OF TABLE it_tmp
FOR ALL ENTRIES IN it_docs
WHERE
bukrs = it_docs-bukrs AND
awkey = it_docs-d_awkey AND
gjahr = d_gjahr AND
bstat = space .
THNKS
07-04-2007 1:30 AM
If possible remove into corresponing
I NEED KNOW "BELNR" FOR GO TO THE BSEG TABLE
SELECT belnr awkey
FROM bkpf
INTO <b>CORRESPONDING FIELDS OF TABLE<b> it_tmp
FOR ALL ENTRIES IN it_docs
WHERE
bukrs = it_docs-bukrs AND
awkey = it_docs-d_awkey AND
gjahr = d_gjahr AND
bstat = space .
It will give little bit good performance and if you give full key in where condition,then you will get good performance but i know as per req we can't provide .
Thanks
Seshu
07-04-2007 1:19 AM
Hi Josue,
Change the code as,
IF it_docs[] IS NOT INITIAL>
SELECT <b>BUKRS belnr GJAHR awkey</b>
FROM bkpf
INTO CORRESPONDING FIELDS OF TABLE it_tmp
FOR ALL ENTRIES IN it_docs
WHERE
bukrs = it_docs-bukrs AND
awkey = it_docs-d_awkey AND
gjahr = d_gjahr AND
bstat = space .
ENDIF.
This can improve a performance a bit, but you can't get a very good performance as you don't have the whole key.
Regards,
Atish
07-04-2007 1:30 AM
If possible remove into corresponing
I NEED KNOW "BELNR" FOR GO TO THE BSEG TABLE
SELECT belnr awkey
FROM bkpf
INTO <b>CORRESPONDING FIELDS OF TABLE<b> it_tmp
FOR ALL ENTRIES IN it_docs
WHERE
bukrs = it_docs-bukrs AND
awkey = it_docs-d_awkey AND
gjahr = d_gjahr AND
bstat = space .
It will give little bit good performance and if you give full key in where condition,then you will get good performance but i know as per req we can't provide .
Thanks
Seshu
07-04-2007 1:56 AM
Hi Josue,
The bad performance is because you're not specifying the primary keys of the table BKPF in your WHERE condition; BKPF usually is a big table.
What you really need is to create a new index on database for table BKPF via the ABAP Dictionary on fields BUKRS, AWKEY, GJAHR & BSTAT. You'll find the performace of the program will significantly increase after the new index is activated. But I would talk to the Basis first to confirm they have no issues if you create a new index for BKPF on the database system.
Hope this helps.
Cheers,
Sougata.