内表的过滤条件为(物料群组=01,工厂=1000) 或 (物料群组=01,工厂=3000)
*… FILTER type( itab [EXCEPT] [IN ftab] [USING KEY keyname]
* WHERE c1 op f1 [AND c2 op f2 […]] )
TYPES:BEGIN OF ty_filter,
matkl TYPE ekpo-matkl,
werks TYPE ekpo-werks,
END OF ty_filter,
ty_filter_tab TYPE SORTED TABLE OF ty_filter
WITH UNIQUE KEY matkl werks.
DATA lt_ekpo TYPE STANDARD TABLE OF ekpo.
SELECT * FROM ekpo INTO TABLE lt_ekpo.
DATA lt_ekpo_sorted TYPE SORTED TABLE OF ekpo WITH UNIQUE KEY ebeln ebelp.
SELECT * FROM ekpo INTO TABLE lt_ekpo_sorted ORDER BY ebeln ebelp.
"1.直接用where条件去过滤
DATA(lt_ekpo_filter_01) = FILTER #( lt_ekpo_sorted WHERE ebeln = '4500000048' ).
"Output filtered records
cl_demo_output=>display( lt_ekpo_filter_01 ).
"制作过滤条件table,过滤条件一定要有key值
DATA(lt_filter) = VALUE ty_filter_tab(
( matkl = '01' werks = '1000' )
( matkl = '01' werks = '3000' )
).
"2.按照过滤条件table过滤数据,
DATA(lt_ekpo_filter_02) = FILTER #( lt_ekpo IN lt_filter
WHERE matkl = matkl
AND werks = werks ).
"Output filtered records
cl_demo_output=>display( lt_ekpo_filter_02 ).
"3.排除过滤
DATA(lt_ekpo_filter_03) = FILTER #( lt_ekpo EXCEPT IN lt_filter
WHERE matkl = matkl
AND werks = werks ).
"Output filtered records
cl_demo_output=>display( lt_ekpo_filter_03 ).
2.过滤出(物料群组=01,工厂=1000) 或 (物料群组=01,工厂=3000)的数据
3.过滤排除掉(物料群组=01,工厂=1000) 或 (物料群组=01,工厂=3000)的数据
END