2008 Jun 12 6:05 AM
Hi all there,
I am using if condition like this
IF JTAB-AUART = 'ZODO' OR JTAB-AUART = 'ZNET' OR
JTAB-AUART = 'ZOID' OR JTAB-AUART = 'ZDRO' OR
JTAB-AUART = 'ZNFO' OR JTAB-AUART = 'ZNIP' OR
JTAB-AUART = 'ZPDO' OR JTAB-AUART = 'ZPFO'.
is there any options to make it short
Regards
Shashikant
2008 Jun 12 6:07 AM
Hi,
Its highly recommended that you make use of brackets. If your code requires these conditions then its unavoidable. It cant be made short.
Thanks
Nayan
Hi,
Its highly recommended that you make use of brackets. If your code requires these conditions then its unavoidable. It cant be made short.
Thanks
Nayan
2008 Jun 12 6:07 AM
Hi,
Its highly recommended that you make use of brackets. If your code requires these conditions then its unavoidable. It cant be made short.
Thanks
Nayan
2008 Jun 12 6:08 AM
Shashikant,
I think if you want to go only with IF than no way to do a short.but either you can you CASE statement instead if IF.It will look better also in coding.
Amit.
2008 Jun 12 6:22 AM
Instead you can write:
CASE JTAB-AUART.
WHEN 'ZODO' or 'ZNET' or 'ZOID' or.....
ENDCASE.
2008 Jun 12 6:29 AM
case JTAB-AUART.
when 'ZODO' or 'ZNET' or 'ZOID' or 'ZDRO' or 'ZNFO'
or 'ZNIP' or 'ZPDO' or 'ZPFO'.
-
endcase.
2008 Jun 12 6:30 AM
either use case statement but that wil not make your code shorter but if you want use if statement like this , please use braces .
2008 Jun 12 6:58 AM
i see in your if statement is checked 8 values beginning with 'Z***'.
you can make code shorter, if jtab-auart has maximum accepted values equals
to, for example, 9 (9 value is 'Z123'). Then you will write:
if not jtab-auart = 'Z123'.
*----
your logic
endif.
2008 Jun 12 7:09 AM
You can make it short by using Ranges.
Example:
ranges: r_range for vbak-auart.
data: w_auart type auart.
r_range-low = '1234'.
r_range-option = 'EQ'.
r_range-low = 'I'.
append r_range.
r_range-low = '5678'.
r_range-option = 'EQ'.
r_range-low = 'I'.
append r_range.
r_range-low = '9101'.
r_range-option = 'EQ'.
r_range-low = 'I'.
append r_range.
IF w_auart in r_range.
write 'hi'.
endif.
If the same condition need to be evaluated in multiple places, then you can build a range and use it in the IF statement.
Regards,
Lakshmi.
2008 Jun 12 7:12 AM
You can very well use in Operator to make this short and effective.
if JTAB-AUART in ( 'VAL1', 'VAL2', 'VAL3'... )
endif.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |