Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dynamic logic expression

Hi Experts,

Iu2019m trying to build a routine with dynamic logical expressions but it's now working...

Basically Iu2019m building a string with the expression, a and after the string it's completed Iu2019m calling a macro that consist in a if.

if expression eq true

return true value

but the value returned by the macro it's always false, even when the logical expression it's true...

i already tried the logical function BOOLC but apparently my version, ECC 6, doesnu2019t recognize it....

Below goes the code, if anyone could help me Iu2019ll be appreciated.



"Macro definition
DEFINE check_condition.
IF &1 EQ ABAP_TRUE.
    move 'X' to &2.
  endif.
END-OF-DEFINITION.


LOOP AT tab_regras."Rules 
    CLEAR: str_cond, lv_result.
    LOOP AT dfies_tab WHERE fieldname CS 'ARGUMENTO'.

      CLEAR: lw_string, str_1, str_2, str_3.
      ASSIGN COMPONENT dfies_tab-fieldname OF STRUCTURE tab_regras TO <fs_field>.
      CHECK <fs_field> IS NOT INITIAL.
      SPLIT <fs_field> AT '/' INTO  str_1 str_2 str_3.
      ASSIGN (str_1) TO <fs_value1>.
"     ASSIGN (str_2) TO <fs_value2>.
"      ASSIGN (str_3) TO <fs_value3>.

      IF str_cond IS INITIAL..
        CONCATENATE <fs_value1> str_2 str_3 INTO str_cond SEPARATED BY space.
        CONTINUE.
      ENDIF.

      CONCATENATE str_cond 'and' <fs_value1> str_2 str_3 INTO str_cond SEPARATED BY space."string condition

    ENDLOOP.
    check_condition str_cond lv_result.
    CHECK lv_result EQ 'X'.



Thanks in advance,

Best Regards

João Martins

Former Member
replied

It would be helpful if you show us what is the example content of str_cond .

Anyhow your check looks like you want to compare some condition with value X which abap_true denotes i.e.

if field_1 = 10 and field_2 = 20 EQ 'X'.  
endif.

This doesn't make sense for me or maybe I am missing something which is hidden behid this str_cond . Your left hand side expression value must however be equal to right hand side value. So the conditon will only be true if

if 'X' = 'X'.
...
endif.

Regards

Marcin

-


PS: please note that in ABAP there is no real boolean value, so you can't have condition like in JAVA or C

if (true_condition)
{
 //do something
}

you always have to compare two values (here abap_true which is X if fact).

Edited by: Marcin Pciak on May 24, 2011 3:59 PM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question