Filter with filter table in ABAP
Refer - Introduction to filter in ABAP
Report-Normal
REPORT zab_rp_filter_table_new.
TABLES: vbak.
TYPES: BEGIN OF ls_vbak,
vbeln TYPE vbeln_va,
vbtyp TYPE vbtypl,
END OF ls_vbak.
TYPES: BEGIN OF ls_filter,
vbtyp TYPE vbtypl,
END OF ls_filter.
DATA: lt_vbak TYPE SORTED TABLE OF ls_vbak WITH NON-UNIQUE KEY vbtyp,
lt_filter TYPE SORTED TABLE OF ls_filter WITH UNIQUE KEY vbtyp,
lt_temp_data TYPE TABLE OF ls_vbak.
SELECT-OPTIONS : s_vbeln FOR vbak-vbeln.
IF s_vbeln IS NOT INITIAL.
SELECT vbeln vbtyp
FROM vbak
INTO TABLE lt_vbak
WHERE vbeln IN s_vbeln.
ENDIF.
lt_filter = VALUE #( ( vbtyp = 'A' ) ( vbtyp = 'C' ) ).
lt_temp_data = FILTER #( lt_vbak IN lt_filter WHERE vbtyp = vbtyp ).
cl_demo_output=>display( lt_temp_data ).
Input
Output
Report-Except
REPORT zab_rp_filter_table_new.
TABLES: vbak.
TYPES: BEGIN OF ls_vbak,
vbeln TYPE vbeln_va,
vbtyp TYPE vbtypl,
END OF ls_vbak.
TYPES: BEGIN OF ls_filter,
vbtyp TYPE vbtypl,
END OF ls_filter.
DATA: lt_vbak TYPE SORTED TABLE OF ls_vbak WITH NON-UNIQUE KEY vbtyp,
lt_filter TYPE SORTED TABLE OF ls_filter WITH UNIQUE KEY vbtyp,
lt_temp_data TYPE TABLE OF ls_vbak.
SELECT-OPTIONS : s_vbeln FOR vbak-vbeln.
IF s_vbeln IS NOT INITIAL.
SELECT vbeln vbtyp
FROM vbak
INTO TABLE lt_vbak
WHERE vbeln IN s_vbeln.
ENDIF.
lt_filter = VALUE #( ( vbtyp = 'A' ) ( vbtyp = 'C' ) ).
lt_temp_data = FILTER #( lt_vbak EXCEPT IN lt_filter WHERE vbtyp = vbtyp ).
cl_demo_output=>display( lt_temp_data ).
Input
Output
********************************Thank You*****************************
Comments
Post a Comment