Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
huzefasaifee
Explorer
It is useful to have a generic method to remove records off any internal table based on a certain field value, even when you don’t know the table structure at design time. The end result of this code would be a method call with a changing parameter in which you feed your internal table:

In this example, we're using PERNR as the field by which the filtering decision is made.
CLASS main DEFINITION.

PUBLIC SECTION.
METHODS: suppression_check IMPORTING iv_pernr TYPE persno
RETURNING value(rv_skipflag) TYPE flag,
filter_table_values CHANGING ct_values TYPE ANY TABLE.

ENDCLASS. "main DEFINITION

CLASS main IMPLEMENTATION.

METHOD suppression_check.
"logic to check if the record must be suppressed or not
"using the field value and returning the skip flag
ENDMETHOD. "suppression_check

METHOD filter_table_values.

FIELD-SYMBOLS: <fs_record> TYPE ANY,
<fs_pernr> TYPE ANY.

LOOP AT ct_values ASSIGNING <fs_record>.
ASSIGN COMPONENT 'PERNR' OF STRUCTURE <fs_record> TO <fs_pernr>.
IF me->suppression_check( <fs_pernr> ).
DELETE TABLE ct_values[] FROM <fs_record>.
ENDIF.
ENDLOOP.

ENDMETHOD.
ENDCLASS.

While using this in the program:
lo->filter_table_values( lt_table ).

I hope this helps, and please do suggest improvements.
7 Comments