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

READ STATEMENT

Former Member
0 Likes
1,044

hi friends,

i am using read statement as per my requirement follws

READ TABLE ITAB INTO WA_TAB WITH KEY

VBTYP_N = 'H' OR

VBTYP_N = 'O' OR

VBTYP_N = 'P'.

BUT ITS GIVING ERROR MESSAGE.

PLZ HELP MW HOW CAN I GIVE CORRECT READ STATEMENT

REGARDS,

SIREESHA

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,004

Hi,

Try the following :

read table itab into wa_tab transporting vbtyp.

CHECK VBTYP_N = 'H' OR

VBTYP_N = 'O' OR

VBTYP_N = 'P'.

****Now use ur logic here.

This should solve ur problem, reward points.

Regards

10 REPLIES 10
Read only

Former Member
0 Likes
1,004

Hi,

Check whether your itab is a sorted itab, otherwise sort before read statement. Use statements separately.

Regards

Senthil

Message was edited by: senthil kumar

Read only

Former Member
0 Likes
1,004

you cant us or statement in your read.

YOu hasve to do separate statments for every condition.

BR, JAcek

(read salp help about read statement - there are examples)

Read only

Former Member
0 Likes
1,004

U can't use OR option with READ statament, so

READ TABLE ITAB INTO WA_TAB WITH KEY VBTYP_N = 'H'.

IF SY-SUBRC <> 0

READ TABLE ITAB INTO WA_TAB WITH KEY VBTYP_N = 'O'.

IF SY-SUBRC <> 0

READ TABLE ITAB INTO WA_TAB WITH KEY VBTYP_N = 'P'.

ENDIF.

ENDIF.

or

V_VBTYP = 'H'.

DO 3 TIMES.

READ TABLE ITAB INTO WA_TAB WITH KEY VBTYP_N = V_VBTYP.

IF SY-SUBRC = 0. EXIT. ENDIF.

CASE V_VBTYP.

WHEN 'H'. V_VBTYP = 'O'.

WHEN 'O'. V_VBTYP = 'P'.

ENDCASE.

ENDDO.

Max

Read only

0 Likes
1,004

read table statment not support logivcal opration .

like or ,and

Read only

Former Member
0 Likes
1,005

Hi,

Try the following :

read table itab into wa_tab transporting vbtyp.

CHECK VBTYP_N = 'H' OR

VBTYP_N = 'O' OR

VBTYP_N = 'P'.

****Now use ur logic here.

This should solve ur problem, reward points.

Regards

Read only

Former Member
0 Likes
1,004

read do not support 'OR' operators

u can try following

loop at itab into WA_TAB where VBTYP_N = 'H' OR

VBTYP_N = 'O' OR

VBTYP_N = 'P'.

endloop.

regards

Atul

Read only

former_member404244
Active Contributor
0 Likes
1,004

Hi Sireesha,

U have to declare the READ statement as

for example

READ TABLE ITAB WITH KEY matnr = <<some variable>>

werks = <<some variable>>

U can't use 'OR' or 'AND' statements.

Regards,

Nagaraj

Read only

Former Member
0 Likes
1,004

hi,

You cannot use OR key word with read statement.

as per your requiremetn you can write three different read statement.

READ TABLE ITAB INTO WA_TAB WITH KEY VBTYP_N = 'H' .
if sy-subrc <> 0.
 READ TABLE ITAB INTO WA_TAB WITH KEY VBTYP_N = 'O'. 
 if sy-subrc <> 0.
  READ TABLE ITAB INTO WA_TAB WITH KEY VBTYP_N = 'P'.
  if sy-subrc <> 0.
   *record not found
  endif.
 endif. 
endif.

Regards,

Richa

Read only

Former Member
0 Likes
1,004

hi,

We can not use logical operators when specifying conditions after WITH KEY.

Even, we can not use any operator other than <b>=</b>. we can not even use <b>EQ</b> with READ statement.


  data: v_cnt type i.
  clear itab.
  read table itab into wa_tab with key vbtyp_n = 'H'.
  if sy-subrc = 0.
    v_cnt = v_cnt + 1.
  endif. 

  clear itab.
  read table itab into wa_tab with key vbtyp_n = 'H'.
  if sy-subrc = 0.
    v_cnt = v_cnt + 1.
  endif. 

  clear itab.
  read table itab into wa_tab with key vbtyp_n = 'H'.
  if sy-subrc = 0.
    v_cnt = v_cnt + 1.
  endif. 

  if v_cnt > 1.
    //your code
  endif.

Regards,

Sailaja.

Read only

Former Member
0 Likes
1,004

Hi,

You can also loop through the internal table thus reading the entire table..

Loop at itab into wa_itab with the log. expression.

Regards