cancel
Showing results for 
Search instead for 
Did you mean: 

If condition logic

Former Member
0 Kudos
83

Need ur help in writing a IF condition logic.

I have written a code like

IF itab-amt between 100 and 200.

Result = itab-sales.

endif.

Now i want to change the logic to

If itab-amt between 100 and 200 excluding 110 120 122 134.....

result = itab-sales.

endif.

can u give me the code with correct syntax

Regards..

Balaji

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

thanks..

Former Member
0 Kudos

Hello,

Try to do it using a range table:


* After the declaration of the data object itab.
DATA:
  lr_range LIKE RANGE TABLE OF itab-amt,
  ls_range LIKE LINE OF lr_range.

ls_range-sign = 'I'.
ls_range-option = 'BT'.
ls_range-low = '100'.
ls_range-high = '200'.
APPEND ls_range to lr_range.
 
ls_range-sign = 'E'.
ls_range-option = 'EQ'.

ls_range-low = '110'.
APPEND ls_range to lr_range.

ls_range-low = '120'.
APPEND ls_range to lr_range.

ls_range-low = '122'
APPEND ls_range to lr_range.

ls_range-low = '134'.
APPEND ls_range to lr_range.

IF itab-amt IN lr_range.

ENDIF.

Regards.

Former Member
0 Kudos

Hi,

you may also create a range for the numbers (r_numb) which are to be neglected and use the condition

IF itab-amt >= 100

AND itab-amt <= 200

AND itab-amt NOT IN r_numb.

" processing

endif.

regards,

teja.

Former Member
0 Kudos

Hi,

define a range for the values to exclude

ranges : r_amt for itab_amt

r_amt-sign = 'I'

r_amt-option = 'NE'

r_amt-low = 110

append r_amt.

r_amt-low = 120.

append r_amt... and so on for all the values.

If ( itab-amt between 100 and 200 )

and itab-amr in r_amt

result = itab-sales.

endif.

regards,

Advait

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
if ( itab-amt >= 100
  and itab-amt <= 200 )
 and ( itab-amt <> 110
     and itab-amt <> 120
     and itab-amt <> 122
     and itab-amt <> 134 ).


endif.

Regards,

Rich Heilman