05-24-2011 2:19 PM
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
05-24-2011 2:46 PM
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
05-24-2011 2:46 PM
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
05-24-2011 6:50 PM
Hi Marcin Pciak,
thanks for your anwser, and that was my problem... boolean expressions....
My condition it didnt make sense, like you said...
Anyway i solved by inserting the logic operador in the string argument , and checking the operador in the macro.
"Macro definition
DEFINE checkif_cond.
case &2.
when 'EQ'.
if &1 eq &3.
&4 = 'X'.
endif.
when 'NE'.
if &1 ne &3.
&4 = 'X'.
endif.
endcase.
END-OF-DEFINITION.
.....
ASSIGN (str_1) TO <fs_value1>.
"Now condition goes like this:
"<fs_value> - value.. X or space
"str_2 - operator EQ or NE
"str_3 - valor to compare X or space
checkif_cond <fs_value1> str_2 str_3 lv_result.
IF lv_result IS INITIAL.
EXIT.
ENDIF.
Thanks
Best Regards
João Martins