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

Regd Join

Former Member
0 Likes
688

Hi all,

The below statement is taking a very long time, can any one please suggest what can be done to reduce the time.

-


*read PO history from EKBE join EKKO

SELECT ekbeebeln ekbeebelp ekbe~vgabe

ekbegjahr ekbebelnr ekbebuzei ekbebewtp

ekbebwart ekbebudat ekbemenge ekbedmbtr

ekbewrbtr ekbewaers ekbearewr ekbeshkzg

ekbecpudt ekbexblnr ekbematnr ekkolifnr ekpo~meins

INTO TABLE l_tbl_ekbe

FROM ekbe JOIN ekko

ON ekbeebeln = ekkoebeln

JOIN ekpo

ON ekbeebeln = ekpoebeln

AND ekbeebelp = ekpoebelp

WHERE ekbe~ebeln IN s_ebeln

AND ekbe~ebelp IN s_ebelp

AND ekbe~vgabe IN r_vgabe

AND ekbe~gjahr IN r_gjahr

AND ekbe~budat IN s_budat

AND ekbe~matnr IN s_matnr

AND ekbe~werks IN r_werks

AND ekko~bukrs = p_bukrs

AND ekko~lifnr IN s_lifnr

AND ekko~bsart IN r_bsart.

-


*Select History per Purchasing Document: Delivery Costs (EKBZ)

REFRESH l_tbl_ekbz.

SELECT aebeln aebelp a~vgabe

agjahr abelnr abuzei abewtp

abudat amenge a~dmbtr

awrbtr awaers aarewr ashkzg

acpudt axblnr c~matnr

blifnr cmeins

a~belnr AS awkey

FROM ekbz AS a JOIN ekko AS b

ON aebeln = bebeln

JOIN ekpo AS c

ON aebeln = cebeln

AND aebelp = cebelp

INTO CORRESPONDING FIELDS OF TABLE l_tbl_ekbz

FOR ALL ENTRIES IN l_tbl_ebeln

WHERE a~ebeln = l_tbl_ebeln-ebeln

AND a~ebelp = l_tbl_ebeln-ebelp

AND a~budat IN s_budat.

APPEND LINES OF l_tbl_ekbz TO l_tbl_ekbe.

5 REPLIES 5
Read only

Former Member
0 Likes
648

Hi,

Dont use more joins in a single stmt.

Use only two tables in the first join.

Then, check the no. of records in the extracted internal table. If atleast one record exists, then use FOR ALL ENTRIES and extract records from the third table.

Hope this helps.

Regards,

SUbramanian

Read only

Former Member
0 Likes
648

Hi,

first get the data from both ekbe,ekko with select statemetns..if at least one record exits ...then get the data from thrid table based on above internal table by using for all entries.

dont use join stmt on third table...

regards,

venkat n

Read only

Former Member
0 Likes
648

Hi,

Use INNER JOIN rather than JOIN.

And change the join structure, first take on left EKKO, EKPO then EKBE.

Same way for second query EKKO, EKPO then EKBZ.

Hope this will increase performance.

Regards,

Ravi K

Read only

Former Member
0 Likes
648

Don't use join statement at all.Create separate internal tables say IT_EKKO, IT_EKPO,IT_EKBE and populate them one after another.Use 'for all entries' and finally club them together into another internal table IT_FINAL. This will improve performance.

Read only

Former Member
0 Likes
648

Hi ,

U can used 'for all entries' not Join.

Prepared Internal table for all indivisual database table & then fetch data from one table to another.

Finally prepared a Final Internal table.......

Regards,

Biswanth