‎2022 Apr 19 8:22 AM
Hi All,
My requirement is to filter internal table using multiple fields.
CONTANTS:lc_star TYPE C VALUE '*'.
DATA:LIT_X_all TYPE STANDARD TABLE OF ZTT WITH NON-UNIQUE KEY EXTSYSTEM CCODE EKORG WERKS MATKL .
DATA: LIT_FILTER_E TYPE SORTED TABLE OF ZTT-EXTSYSTEM WITH NON-UNIQUE KEY TABLE_LINE ,
LIT_FILTER_o TYPE SORTED TABLE OF ZTT-EKORG WITH NON-UNIQUE KEY TABLE_LINE ,
LIT_FILTER_c TYPE SORTED TABLE OF ZTT-ccode WITH NON-UNIQUE KEY TABLE_LINE ,
LIT_FILTER_w TYPE SORTED TABLE OF ZTT-werks WITH NON-UNIQUE KEY TABLE_LINE .
SELECT * FROM ZTT WHERE A = @i_A<br> INTO TABLE @LIT_X_ALL.
LOOP AT i_pit_input INTO DATA(lwa_input).
"filter to avoid select statement in loop
lit_filter_e = VALUE #( ( CONV #( lc_star ) ) ( lwa_input-extsystem ) ).
DATA(lit_final_e) = FILTER #( LIT_APPROVER_ALL IN lit_filter_e WHERE extsystem = table_line ).
lit_filter_o = VALUE #( ( CONV #( lc_star ) ) ( lwa_input-ekorg ) ).
DATA(lit_final_o) = FILTER #( lit_final_e IN lit_filter_O WHERE ekorg = table_line ).
lit_filter_c = VALUE #( ( CONV #( lc_star ) ) ( lwa_input-ccode ) ).
DATA(lit_final_c) = FILTER #( lit_final_o IN lit_filter_c WHERE ccode = table_line ).
lit_filter_w = VALUE #( ( CONV #( lc_star ) ) ( lwa_input-werks ) ).
DATA(lit_final_w) = FILTER #( lit_final_c IN lit_filter_w WHERE werks = table_line ).
APPEND LINES OF lit_filter_w TO lit_FINAL.
ENDLOOP.<br>
currently i am using above code with filter for each field . can we achieve same requirement with single filter instead of multiple filters.ThanksPhani
‎2022 Apr 19 8:41 AM
Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!
‎2022 Apr 19 9:13 AM
Hi phanikumar_y,
do you mean something like this:
select a~*
from @LIT_APPROVER_ALL as a
where exists(
select @abap_true
from ztt as b
where b~extsys = a~extsys
and b~ekorg = a~ekorg
and ...
)
into table @data(lt_result)
or
select a~*
from @LIT_APPROVER_ALL as a
inner join ztt as b
on b~extsys = a~extsys
and b~ekorg = a~ekorg
and ....
into table @data(lt_result)
‎2022 Apr 19 10:30 AM
No. My requirement is check particular combination exists or not .
‎2022 Apr 19 11:47 AM
It seems your code is incomplete as I don't understand the goal: why do you loop at I_PIT_INPUT, because final result will only consider last line of I_PIT_INPUT...
‎2022 Apr 19 12:56 PM
‎2022 Apr 19 12:57 PM
Hello,
perhape can you use standard function
LVC_FILTER_APPLY ...
Check it !
SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
‎2022 Apr 19 1:11 PM
and why didn't you use directly the i_pit_input to filter the value of your table ?
FILTER #( lit_x_all IN i_pit_input
WHERE extsystem = extsystem
AND ekorg = ekor ....(and I don't understand the usage of the * )
‎2022 Apr 19 3:25 PM
Hi Fredric,
i cannot use directly because i have use OR operation . check value or '*' exits or not ?
Thanks,
Phani