Tuesday, June 22, 2010

FREE_SELECTIONS_EX_2_WHERE


This FM helps to construct WHERE conditions of a select statement. This is useful if you have the requirement to  implement a dynamic select statement.

How to implement it?
You have to initiate Type Group RSDS by using TYPE-POOL keyword. After that, you need a internal table and structure of type RSDS_EXPR. This will store the expression of the selection:

RSDS_EXPR-TABLENAME -> Table Name
RSDS_EXPR-EXPR_TAB-> Itab stores the expressions
  • RSDS_EXPR-EXPR_TAB-LOGOP              -> Logical Operation ("AND", "OR", "NOT", only)
  • RSDS_EXPR-EXPR_TAB-ARITY                -> Priority of Logical Operation
  • RSDS_EXPR-EXPR_TAB-FIELDNAME     -> Table's field name for selection
  • RSDS_EXPR-EXPR_TAB-OPTION             -> Selection Option ("EQ", "BT", "CP", "GT", and etc.)
  • RSDS_EXPR-EXPR_TAB-LOW                   -> Value - Low
  • RSDS_EXPR-EXPR_TAB-HIGH                  -> Value - High
Note: If the intended WHERE condition is:
WHERE hvorg EQ '0600'
   AND ( tvorg EQ '0010'
        OR tvorg EQ '0011' )
   AND augst EQ ''
  AND augrd NE '05'.

RSDS_EXPR-EXPR_TAB shall be populated in this manner:

The result would be:

No comments:

Post a Comment