‎2006 Oct 06 1:46 PM
Hi Forum!
I want to know if it's possible to build a dynamic logical expression for IF or CASE instructions and get it evaluated.
For example:
data: LogExp type string.
LogExp = 'Sy-subrc eq 0'.
IF (LogExp).
Endif.
Or
data: Var type string,
LogExp type i.
LogExp1 = 0.
LogExp2 = 4.
Var = 'Sy-subrc'.
Case (Var).
When (LogExp1).
When (LogExp2).
...
When others.
Endcase.
Thanks in advance.
John.
‎2006 Oct 06 1:55 PM
Hi John,
in general your idea of dynamic logical expression is not possible in ABAP.
But you can use the operator IN in combination with range tables. You have define all variables in your statement. Empty range tables will be treated as true.
See this example:
data lt_r_subrc type range of sy-subrc.
data ls_r_subrc like line of lt_r_subrc.
ls_r_subrc-sign = 'I'.
ls_r_subrc-option = 'EQ'.
ls_r_subrc-low = 0.
insert ls_r_subrc into table lt_r_subrc.
if sy-subrc in lt_r_subrc.
" do something
endif.Just modify the range tables for different conditons.
Regards,
Axel
‎2006 Oct 06 1:50 PM
hi,
Dynamic If conditions are not possible.
Try with subroutine pools instead..
Regards,
Sailaja.
‎2006 Oct 06 1:55 PM
Hi John,
in general your idea of dynamic logical expression is not possible in ABAP.
But you can use the operator IN in combination with range tables. You have define all variables in your statement. Empty range tables will be treated as true.
See this example:
data lt_r_subrc type range of sy-subrc.
data ls_r_subrc like line of lt_r_subrc.
ls_r_subrc-sign = 'I'.
ls_r_subrc-option = 'EQ'.
ls_r_subrc-low = 0.
insert ls_r_subrc into table lt_r_subrc.
if sy-subrc in lt_r_subrc.
" do something
endif.Just modify the range tables for different conditons.
Regards,
Axel