‎2010 Aug 09 2:50 PM
Hi,
I want to know is it possible to create Dynamic IF condition.
My requirement is
IF 'incomin_ph1' (ls_zsales_pln-PH1_OP) lt_ph_r1
ENDIF. Here ls_zsales_pln-PH1_OP will have values as IN or NOT IN but it gives me compilation error as it is not Supported.
Is there any other way we can bulit dynamic IF condition..
Regards,
Mayank
‎2010 Aug 09 3:27 PM
Hi mayank,
Is this what you meant ?
DATA:BEGIN OF wa,
matnr TYPE matnr,
END OF wa.
DATA:BEGIN OF wa1,
matnr TYPE matnr,
END OF wa1.
DATA:lv_string TYPE char255.
FIELD-SYMBOLS:<fs> TYPE ANY.
DO 2 TIMES.
IF sy-index = 1.
wa-matnr = 'A'.
lv_string = 'WA'.
CONCATENATE lv_string '-MATNR' INTO lv_string.
CONDENSE lv_string.
ASSIGN (lv_string) TO <fs>.
ELSE.
wa1-matnr = 'B'.
lv_string = 'WA1'.
CONCATENATE lv_string '-MATNR' INTO lv_string.
CONDENSE lv_string.
ASSIGN (lv_string) TO <fs>.
ENDIF.
IF <fs> = 'A'.
WRITE 'entered WA'.
ELSE.
SKIP 1.
WRITE 'entered WA1'.
ENDIF.
ENDDO.
‎2010 Aug 09 3:45 PM
Hi Keshav,
My requirement is i want to Bulit Relationship Operator Dynamically.
Like,
IF VAR1 IN it_tab1
endif.
IF VAR1 NOT IN it_tab1
endif.
here, i want to replace IN or NOT IN Operator with a variable which is giving syntax error.
‎2010 Aug 09 3:49 PM
Hi Mayank,
Instead of this you can just append 'NE' , 'EQ' , 'CP' into a range table and do it.
in the if condition always use in statement and build the others in range.
Hope you got it.
‎2010 Aug 09 4:13 PM
Hi Keshav,
Actaully , i will be getting these operator values IN,NOT IN from a Z table , at run time i dont know what
operator i am getting.
So i want to built this IF condition on the basis of whatever operator value i get from Z table.
And, also In Z table operator values can be IN and NOT IN only
Regards,
Mayank Verdia
‎2010 Aug 09 4:20 PM
Hi,
You can check this example.If the z table contains not in then build it with NE , if it contains in then build it with EQ
do 2 times.
wa1-field1 = 'B'.
clear rt1[].
if sy-index = 1.
ra-sign = 'I'.
ra-option = 'NE'. "<---
ra-low = 'A'.
append ra to rt1.
endif.
if sy-index = 2.
ra-sign = 'I'.
ra-option = 'EQ'. "<---
ra-low = 'B'.
append ra to rt1.
endif.
if wa1-field1 in rt1.
write 'True'.
skip 1.
else.
write 'false'.
endif.
enddo.
‎2010 Aug 09 3:52 PM
I think you shoul fill the range lt_ph_r1 according to your request:
lt_ph_r1-sign = 'I'. " including .... for IN lt_ph_r1 .
lt_ph_r1-sign = 'E'. " excluding .... for NOT IN lt_ph_r1.
.....
and your If should be
IF 'incomin_ph1' IN lt_ph_r1
ENDIF.