Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Operator in a if statement

Former Member
0 Kudos

Hi Guys,

I have a scenario where the Relational Operator is coming from a table and i need to use it in my IF ENDIF condition.

IF VARIABLE1 DYNAMIC OPERATOR VARIABLE2.

endif.

DYNAMIC OPERATOR is coming from a table and can get GE, LE , EQ , LT etc...

Apologies if this is asked before but i know about dynamic SELECT , Loop and not IF clause.

If someone can suggest.

Thanks

Bhanu

1 ACCEPTED SOLUTION

former_member202818
Active Contributor
0 Kudos

Hi Malik,

This can be done with range or select option.

http://scn.sap.com/thread/1757917

Regards

Sreekanth

4 REPLIES 4

former_member191761
Active Participant
0 Kudos

Hi Bhanu,

Please check if this helps:

Fetch your operator from table to VAR1.

    CASE VAR1 .    " no need for this to be a field symbol

             WHEN 'EQ'.

               IF var1 EQ var2.

                 PERFORM things_i_want_for_EQ.

               ENDIF.

             WHEN 'NE'.

               IF var1 NE var2.       " changed to NE

                 PERFORM things_i_want_for_NE.

               ENDIF.

             WHEN 'LT'.

               IF var1 LT var2.     " changed to LT

                 PERFORM things_i_want_for_LT.

               ENDIF.

          ENDCASE.



Thanks

Sri

former_member202818
Active Contributor
0 Kudos

Hi Malik,

This can be done with range or select option.

http://scn.sap.com/thread/1757917

Regards

Sreekanth

Former Member
0 Kudos

You can best achieve this by using returning parameters in local classes.

Read the abap documentation for returning.

Former Member
0 Kudos

Hi Guys,

It actually turned out to be a very simple and small code to deal with this scenario.

Sreekanth: Your referance worked and all i had to do was a simple routine passing my variable1 and variable 2 and operator in a range.

Chinmay: Not sure if you are referring to a local class which calls ranges.

Srilakshmi: I never wanted to write all that code.

Thanks everyone i am marking this as answereed