Skip to Content
0
Former Member
Aug 27, 2007 at 12:03 PM

Query takes long time

12 Views

hi experts,

I have made Purchase Requisition . User has to enetr plant, Date and Material. BUt it taks long time to execute. sometimes shows with Timeout. Below is my Code. can u plz send me the updations to make it more faster. iTs urgent

SELECT BADAT LFDAT BANFN MATNR TXZ01 MENGE MEINS EBELN EBELP WERKS INTO (IT_EKKO-BADAT, IT_EKKO-LFDAT, IT_EKKO-BANFN, IT_EKKO-MATNR_EB,

IT_EKKO-TXZ01_EB, IT_EKKO-MENGE_EB, IT_EKKO-MEINS_EB, IT_EKKO-EBELN_EB, IT_EKKO-EBELP_EB, IT_EKKO-WERKS)

FROM EBAN

WHERE EBAN~WERKS IN S_WERKS AND EBAN~BADAT IN S_DATE AND EBAN~MATNR IN S_MAT AND EBAN~LOEKZ = SPACE.

IF IT_EKKO-EBELN_EB <> SPACE.

SELECT EBELN EBELP AEDAT MATNR TXZ01 MENGE MEINS NETPR

INTO (IT_EKKO-EBELN, IT_EKKO-EBELP, IT_EKKO-AEDAT, IT_EKKO-MATNR, IT_EKKO-TXZ01_EP, IT_EKKO-MENGE, IT_EKKO-MEINS,

IT_EKKO-NETPR)

FROM EKPO

WHERE EKPO~EBELN = IT_EKKO-EBELN_EB AND EKPO~EBELP = IT_EKKO-EBELP_EB AND EKPO~LOEKZ = SPACE.

it_ekko-pend = IT_EKKO-MENGE_EB - IT_EKKO-MENGE.

SELECT single BEDAT RESWK INTO (IT_EKKO-BEDAT, IT_EKKO-RESWK)

FROM EKKO

WHERE EKKO~EBELN = IT_EKKO-EBELN.

  • ENDSELECT.

IF SY-SUBRC = 0 AND IT_EKKO-EBELN_EB <> SPACE.

SELECT ERDAT VBELN MATNR ARKTX LFIMG MEINS VGBEL INTO (IT_EKKO-ERDAT, IT_EKKO-VBELN, IT_EKKO-MATNR_LI,

IT_EKKO-ARKTX, IT_EKKO-LFIMG, IT_EKKO-MEINS_LI, IT_EKKO-VGBEL)

FROM LIPS

WHERE LIPS~VGBEL = IT_EKKO-EBELN AND LIPS~VGPOS = IT_EKKO-EBELP.

IF SY-SUBRC = 0.

n = 1.

LOOP AT IT_TRFRATE WHERE matnr_tr = it_ekko-matnr_li.

IF N = 1.

IT_EKKO-TRFRATE = IT_TRFRATE-TRFRATE.

select single umren from marm into vumren where marm~matnr = IT_EKKO-MATNR

and ( marm~meinh = 'L' or marm~meinh = 'KG' ).

  • endselect.

select single umrez from marm into vumrez where marm~matnr = IT_EKKO-MATNR

and ( marm~meinh = 'L' or marm~meinh = 'KG' ).

  • endselect.

compute vlfimg = ( IT_EKKO-LFIMG * vumren ) / vumrez.

IT_EKKO-NETPR = VLFIMG * IT_EKKO-TRFRATE.

CLEAR IT_EKKO-PEND_LI.

it_ekko-pend_li = IT_EKKO-MENGE_EB - IT_EKKO-LFIMG.

N = N + 1.

ENDIF.

ENDLOOP.

SELECT single WBSTK INTO (IT_EKKO-WBSTK)

FROM VBUK

WHERE VBUK~VBELN = IT_EKKO-VBELN.

  • ENDSELECT.

ELSE.

n = 1.

LOOP AT IT_TRFRATE WHERE matnr_tr = it_ekko-matnr_li.

IF N = 1.

IT_EKKO-TRFRATE = IT_TRFRATE-TRFRATE.

select single umren from marm into vumren where marm~matnr = IT_EKKO-MATNR

and ( marm~meinh = 'L' or marm~meinh = 'KG' ).

  • endselect.

select single umrez from marm into vumrez where marm~matnr = IT_EKKO-MATNR

and ( marm~meinh = 'L' or marm~meinh = 'KG' ).

  • endselect.

compute vlfimg = ( IT_EKKO-LFIMG * vumren ) / vumrez.

IT_EKKO-NETPR = VLFIMG * IT_EKKO-TRFRATE.

CLEAR IT_EKKO-PEND_LI.

it_ekko-pend_li = IT_EKKO-MENGE_EB - IT_EKKO-LFIMG.

N = N + 1.

ENDIF.

ENDLOOP.

SELECT single WBSTK INTO (IT_EKKO-WBSTK)

FROM VBUK

WHERE VBUK~VBELN = IT_EKKO-VBELN.

  • ENDSELECT.

ENDIF.

ENDSELECT.

IT_EKKO-PEND_LI = IT_EKKO-MENGE - IT_EKKO-LFIMG.

APPEND IT_EKKO.

CLEAR IT_EKKO.

ELSE.

IT_EKKO-PEND_LI = IT_EKKO-MENGE - IT_EKKO-LFIMG.

APPEND IT_EKKO.

ENDIF.

CLEAR IT_EKKO.

ENDSELECT.

IF SY-SUBRC <> 0.

it_ekko-pend = IT_EKKO-MENGE_EB.

APPEND IT_EKKO.

ENDIF.

ELSE.

it_ekko-pend = IT_EKKO-MENGE_EB.

APPEND IT_EKKO.

ENDIF.

ENDSELECT.

******************************************************************************************

THanks.

Khan