hello
it is my report ,the last query is very slowly, I used index in AUFK, for objnr field and AFVC for Objnr field, but in last query that use is very slowwllyy.
REPORT ZSK_TEST.
TYPE-POOLS: slis,kkblo,
vrm.
TABLES : AFKO,AUFK.
*parameters
SELECTION-SCREEN BEGIN OF BLOCK ORDER WITH FRAME TITLE text-t02.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-113.
SELECT-OPTIONS:MATERIAL FOR AFKO-PLNBEZ ."obligatory .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK ORDER.
types:begin of ty_all_ord,
aufnr type CAUFV-aufnr,
end of ty_all_ord.
types:begin of ty_all_ord_pcnf,
aufnr type CAUFV-aufnr,
end of ty_all_ord_pcnf.
types:begin of ty_all_ord_link,
aufpl type afko-aufpl,
APLZL type afvc-APLZL,
end of ty_all_ord_link.
types:begin of ty_all_obj,
vornr type afvc-vornr,
end of ty_all_obj.
types:begin of ty_all_op,
"aufnr type CAUFV-aufnr,
vornr type afvc-vornr,
"objnr type afvc-objnr,
end of ty_all_op.
types:begin of ty_all_ord_grnk,
aufnr type CAUFV-aufnr,
end of ty_all_ord_grnk.
data: it_all_ord type standard table of ty_all_ord .
data: it_all_ord_pcnf type standard table of ty_all_ord_pcnf .
data: it_all_ord_grnk type standard table of ty_all_ord_grnk .
data: it_all_ord_link type standard table of ty_all_ord_link .
data: it_all_obj type standard table of ty_all_obj .
data: it_all_op type standard table of ty_all_op .
data :wa_last_op_cnf type afvc-vornr.
data :wa_last_op_pcnf type afvc-vornr.
data :wa_last_st type jest-stat.
FIELD-SYMBOLS: <lfs_all_ord_grnk> LIKE LINE OF it_all_ord_grnk.
FIELD-SYMBOLS: <lfs_all_ord_link> LIKE LINE OF it_all_ord_link.
"get all orders for materials
select afpo~aufnr
from afpo
into table it_all_ord
where afpo~matnr in material.
if it_all_ord is not initial.
"get PCNF orders
select aufk~aufnr
from aufk join jest on aufk~objnr = jest~objnr
into table it_all_ord_pcnf
for all entries in it_all_ord
where inact eq ' ' and stat eq 'I0010' and
aufk~aufnr = it_all_ord-aufnr.
if it_all_ord is not initial.
"get GRNK orders
select aufk~aufnr
from aufk join jest on aufk~objnr = jest~objnr
into table it_all_ord_grnk
for all entries in it_all_ord_pcnf
where inact eq ' ' and stat eq 'E0001' and
aufk~aufnr = it_all_ord_pcnf-aufnr.
endif.
endif.
select aufpl
from afko
into table it_all_ord_link
for all entries in it_all_ord_grnk
where aufnr = it_all_ord_grnk-aufnr.
select afvc~vornr
from afvc join jest on afvc~objnr = jest~objnr
into table it_all_op
for all entries in it_all_ord_link
where inact eq ' ' and stat eq 'I0009' and
afvc~aufpl = it_all_ord_link-aufpl.