Application Development and Automation 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: 
Read only

Internal table multiple condition

Former Member
0 Likes
560

Dear experts,

In internal table , the following syntax whether correct or not.

IF( WS_CHANNEL IN ( '10','11') or ( ws_channel in ('50','60') and itab-loc = '4058')).

Please do the needful

Regards

R.Rajendran

5 REPLIES 5
Read only

Former Member
0 Likes
531

It depends on what you want to do.

Currently the if statement is true for the following 4 scenarios.

- if ws_channel = 10

- if ws_channel = 11

- if ws_channel = 50 AND itab-loc = 4058

- if ws_channel = 60 AND itab-loc = 4058

Is that what you intend to do? If not please give a little more details on what your exact requirements are.

Thanks,

Michael

Read only

0 Likes
531

Dear michel,

i want to do the following two condition in the internal after population from the table.

1) ws_channel = 10 or 11 or 12 or 40

( without any other checking )

2) the above condition or

itab-loc = 4058 and ws_channel = 50 or 60

the above two condition should come in the single statement.

please do the needful.

Regards

R.Rajendran

Read only

Former Member
0 Likes
531

Hello,

It's incorrect. The IN form that you used is valid only in SELECT commands.

You need to do like follows:


DATA:
  lr_ws_channel LIKE RANGE OF ws_channel,
  ls_ws_channel LIKE LINE OF lr_ws_channel.

  ls_ws_channel-option = 'I'.
  ls_ws_channel-sign = 'EQ'.
  ls_ws_channel-low = '10'.
  APPEND ls_ws_channel to lr_ws_channel.

  ls_ws_channel-low = '20'.
  APPEND ls_ws_channel to lr_ws_channel.

  IF ( WS_CHANNEL IN LR_WS_CHANNEL )...

In you case you'll need two range tables.

I suggest you the following:


IF ( WS_CHANNEL = '10' OR WS_CHANNEL = '11' ) OR 
  ( ( WS_CHANNEL = '50' OR WS_CHANNEL = '60' ) AND ITAB-LOC = '4058' ).

Regards.

Read only

Former Member
0 Likes
531

Hi Rajender,

Yes this cannot be possible with the workarea. IN Operator is not allowd in the internal table.

Instead of passing the hardcoded value why dont you try with the Ranges.

Below is the sample program for you.


REPORT  ZCC_TEST.


data:  begin of it_final occurs 0,
  matnr type mara-matnr,
end of it_final.


it_final-matnr = '101'.
append it_final.
it_final-matnr = '102'.
append it_final.

it_final-matnr = '103'.
append it_final.

it_final-matnr = '104'.
append it_final.
ranges: r_matnr for mara-matnr.

r_matnr-option = 'EQ'.
r_matnr-sign = 'I'.
r_matnr-low  = '101'.
append r_matnr.

r_matnr-option = 'EQ'.
r_matnr-sign = 'I'.
r_matnr-low  = '10'.
append r_matnr.

loop at it_final.
 if it_final-matnr in r_matnr.
  write:/ 'Found'.
 endif.
endloop.

&******** Reward Point if helpful***********&

Read only

Former Member
0 Likes
531

hi,

do this way ...


IF( ( WS_CHANNEL = '10' or  WS_CHANNEL = '11' ) or 
 ( ( ws_channel = 50 or ws_channel = '60') and itab-loc = '4058') ) ).

ENDIF.