2016 Jul 25 12:55 PM
Hi mates,
i have a configuration table where i'll read some values like Contains, Contains Any, Begins With, etc...
now i want to construct an if statement based on that table entries like:
CONCATENATE var_1 var_operator var_2
INTO lv_condition SEPARATED BY space.
and then use:
if (lv_condition)
in this case, somthing like "if (var_1 CA var_2)."
is it possible? Simple?
Maybe i'll have to quit this solution and try case/endcase...
any help would be great.
thanks!
2016 Jul 25 1:11 PM
Hi Bruno,
Unfortunately this dynamic condition will not work.
But what is your proper requirement.?
Regards
Ashish
2016 Jul 25 1:11 PM
Hi Bruno,
Unfortunately this dynamic condition will not work.
But what is your proper requirement.?
Regards
Ashish
2016 Jul 25 1:37 PM
Well, i have a ZTAB1 (transparent table) where i need to check some conditions (EQ, NE, CA, CS...) and some description/value in other field.
Depending on the selection to that table, i'll get different results so my if can be:
if var1 EQ '1' or if var_1 CS 'S103' etc etc
Anyway, i can manage to have the variables more or less dynamic but not the logic expressions... i cannot do if(lv_condition)
where the condition is, for instance, 'var_1 CS 'F409''...
I guess i'll have to hardcode a CASE condition with the logic expressions.
(sorry if it's not so clear, my english is not perfect) thanks a lot
2016 Jul 25 1:48 PM
hi,
As far as I have used, dynamic condition works in where condition for loop and select queries.
you can do a loop and inside it put the condition according to the your need.
Regards
Ashish
2016 Jul 25 1:55 PM
We'll maybe i can try and check if i can do a logic where i use a loop instead of an if.
I know that the WHERE statement let's you put a condition based on a concatenate. Thanks.
2016 Jul 25 4:03 PM
I've sorted it out with a CASE condition.
Not dynamic but it's working for now. In the meantime, maybe i could change this part of the code to be dynamic.
Thanks mates!
2016 Jul 25 1:38 PM
Kindly search before posting.
Have a look at this discussion: http://scn.sap.com/community/abap/blog/2016/02/29/dynamic-if-condition
Thanks,
Juwin
2016 Jul 25 1:57 PM
Thanks mate. Will read. Seems a bit complex (for my experience). And i'll get it will be easier for me to do the CASE statement but it's always great to have such opinions and learn new stuff. thanks!