hello
my thired query get time 1:35 s, how to improve it?
TABLES :AFKO,AFRU.
DATA: BEGIN OF IT_ORR OCCURS 1000 ,
AUFNR TYPE AFKO-AUFNR,
VORNR TYPE AFVC-VORNR,
BUDAT TYPE AFRU-BUDAT,
END OF IT_ORR.
*parameters
SELECTION-SCREEN BEGIN OF BLOCK ORDER WITH FRAME TITLE text-t02.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-112.
SELECT-OPTIONS:ORDER for AFKO-AUFNR ."OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-113.
SELECT-OPTIONS:MATERIAL FOR AFKO-PLNBEZ .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-114.
SELECT-OPTIONS:BUDAT for AFRU-BUDAT ."OBLIGATORY .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK ORDER.
types: begin of ty_afko,
aufnr type afko-aufnr,
plnbez type afko-plnbez,
end of ty_afko.
types:begin of ty_aufk,
aufnr type aufk-aufnr,
objnr type aufk-objnr,
auart type aufk-auart,
end of ty_aufk.
types: begin of ty_jcds,
objnr type jcds-objnr,
UDATE type jcds-UDATE,
end of ty_jcds.
types: begin of ty_all_ord,
plnbez type afko-plnbez,
aufnr type afko-aufnr,
auart type aufk-auart,
objnr type jcds-objnr,
end of ty_all_ord.
types: begin of ty_final,
plnbez type afko-plnbez,
auart type aufk-auart,
co type int4,
end of ty_final.
data: it_afko type standard table of ty_afko.
data: it_jcds type standard table of ty_jcds.
data: it_aufk type standard table of ty_aufk.
data: it_all_ord type standard table of ty_all_ord.
data: it_final type standard table of ty_final.
data : wa_aufk like line of it_aufk.
data : wa_afko like line of it_afko.
data : wa_all_ord like line of it_all_ord.
data : wa_final like line of it_final.
data : co type int4.
FIELD-SYMBOLS: <lfs_jcd> LIKE LINE OF it_jcds.
FIELD-SYMBOLS: <lfs_all_ord> LIKE LINE OF it_all_ord.
select aufnr
plnbez
from afko
into table it_afko
where afko~aufnr like '1-%'
and AFKO~PLNTY IN ('N', 'R', 'S', 'M').
select aufnr
objnr
auart from aufk into table it_aufk
for all entries in IT_AFKO
where aufnr = it_afko-aufnr.
select objnr UDATE
from jcds
into table it_jcds
for all entries in it_aufk
where objnr = it_aufk-objnr and
( STAT = 'I0009' AND INACT = ' ' )." and
"( jcds~UDATE > budat-low and jcds~UDATE < BUDAT-HIGH ).
sort it_jcds by objnr .
sort it_aufk by objnr aufnr auart.
sort it_afko by aufnr plnbez.
delete adjacent duplicates from it_jcds.
loop at it_jcds assigning <lfs_jcd> where UDATE >= budat-low and UDATE <= BUDAT-HIGH .
read table it_aufk into wa_aufk with key objnr = <lfs_jcd>-objnr binary search .
read table it_afko into wa_afko with key aufnr = wa_aufk-aufnr binary search.
wa_all_ord-aufnr = wa_afko-aufnr.
wa_all_ord-plnbez = wa_afko-plnbez.
wa_all_ord-auart = wa_aufk-auart.
wa_all_ord-objnr = wa_aufk-objnr.
append wa_all_ord to it_all_ord.
endloop.
sort it_all_ord by plnbez aufnr.
loop at it_all_ord assigning <lfs_all_ord>.
co = co + 1.
at end of plnbez .
wa_final-plnbez = <lfs_all_ord>-plnbez.
wa_final-auart = <lfs_all_ord>-auart.
wa_final-co = co.
append wa_final to it_final.
clear co.
ENDAT.
endloop.