2010 May 17 4:42 AM
Hi All,
Tried getting the zuonr of bsas and bsis using bseg but got
Run time error long text. Exceeded the permitted time.
My condition is c_sales_pdc type bseg-hkont value u20180000102120u2019.
Need your advise on program optimization and rephrasing my program statements especially the case statements.
below is the code
Many thanks,
Aashta
SELECT bukrs
hkont
gjahr
belnr
budat
waers
blart
shkzg
wrbtr
dmbtr
augdt
xragl
FROM bsis
INTO TABLE it_bsis
WHERE hkont EQ c_sales_pdc
AND bukrs IN s_bukrs
AND belnr IN s_belnr
AND budat LE p_budat.
DELETE it_bsis WHERE blart NE 'DZ'
AND blart NE 'PD'.
DELETE it_bsis WHERE xragl NE ''.
SELECT augbl belnr bukrs gjahr buzei bschl
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bsis
WHERE zuonr NE space
AND buzei = '01'
AND gjahr = it_bsis-gjahr
AND bschl IN ('01', '15')
AND qsskz = 'XX'
AND bukrs IN s_bukrs
AND zuonr IN s_zuonr
AND augbl IN s_belnr
AND augbl = it_bsis-belnr.
LOOP AT it_bseg.
CLEAR: it_bseg2-belnr, it_bseg2-zuonr, it_bseg2-kunnr.
CASE it_bseg-bschl.
WHEN '01'.
SELECT augbl zuonr kunnr
FROM bseg
INTO TABLE it_bseg2
FOR ALL ENTRIES IN it_bseg
WHERE augbl = it_bseg-augbl
AND augbl IN s_belnr
AND zuonr IN s_zuonr
AND kunnr IN s_kunnr.
WHEN '15'.
SELECT belnr zuonr kunnr
FROM bseg
INTO TABLE it_bseg2
FOR ALL ENTRIES IN it_bseg
WHERE belnr = it_bseg-belnr
AND belnr IN s_belnr
AND zuonr IN s_zuonr
AND kunnr IN s_kunnr.
WHEN OTHERS.
EXIT.
ENDCASE.
ENDLOOP.
SELECT zuonr prctr
FROM zfspbu
INTO TABLE it_zfspbu
FOR ALL ENTRIES IN it_bseg2
WHERE zuonr = it_bseg2-zuonr
AND zuonr IN s_zuonr.
2010 May 17 1:10 PM
that SQL taking longer execution time.
Pl. note following changes in sql
SELECT augbl belnr bukrs gjahr buzei bschl
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bsis
WHERE zuonr NE space
AND buzei = '01'
AND gjahr = it_bsis-gjahr
AND bschl IN ('01', '15')
AND qsskz = 'XX'
AND bukrs IN s_bukrs
AND zuonr IN s_zuonr
AND augbl IN s_belnr
AND augbl = it_bsis-belnr.
Write as
SELECT augbl belnr bukrs gjahr buzei bschl
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bsis
WHERE buzei = '01'
AND bschl IN ('01', '15')
AND qsskz = 'XX'
AND zuonr IN s_zuonr
AND gjahr = it_bsis-gjahr
AND augbl = it_bsis-belnr.
delete it_bseg where zuonr NE space.
company code and belnr your reading checking from first sql and there is not need to read again.
Try above it will work.
Rgds
Ravi Lanjewar
2010 May 17 1:41 PM
Hi Aasta,
Obviously it will take the long time, because the fields you are retrieving in the select query are not in the proper order as of database fields and the same case in the where condition. Therefore I have corrected and kept in order. please check.
Select bukrs
hkont
gjahr
augdt
belnr
budat
waers
blart
shkzg
dmbtr
wrbtr
xragl
FROM bsis
INTO TABLE it_bsis
WHERE bukrs IN s_bukrs
AND hkont EQ c_sales_pdc
AND belnr IN s_belnr
AND budat LE p_budat.
Also please put the initial check before using for all entries.
i.e., if not it_bsis[] is initial.
SELECT bukrs
belnr
gjahr
buzei
augbl
bschl
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bsis
WHERE bukrs IN s_bukrs
AND gjahr = it_bsis-gjahr
AND buzei = '01'
AND augbl = it_bsis-belnr
AND bschl IN ('01', '15')
AND qsskz = 'XX'
AND zuonr IN s_zuonr.
endif.
Please do the changes, hope will work fine.
Regards,
Md Ziauddin.
2010 May 18 3:59 AM
Ravi ,
thank you for your reply, i tried your suggestions but time processing is the same.
According to runtime error list, the problem is in the case statement, your ideas are great help.
Regards,
Aashta
Edited by: aashta dj888 on May 18, 2010 5:01 AM
2010 Jun 10 4:32 AM