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

Difficulty While reading Table....

Former Member
0 Likes
1,024

Hi All,

i trying to read data from table with multiple condition but it is giving me error,

my code is :

loop at struct.

ind = sy-tabix.

read table itabMAST with key matnr = struct-matnr and WERKS = company and stlan = '5'.

if sy-subrc = 0.

move itabMAST-stlnr to struct-stlnr.

endif.

modify struct index ind transporting stlnr.

endloop.

and error message is giving is

Unable to interpret "WERKS". Possible causes: incorrect Spelling or Comma error.

Pls Help...

Thanks in Advance,

Yunus

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
963

Hi Yunus,

You can not use logical conditions in the READ statement.

Remove the AND conditions from the READ statement and it will work. READ statement by default takes the condition as AND.

<b>Reward points if it helps.</b>

Regards,

Amit Mishra

Message was edited by: Amit Mishra

8 REPLIES 8
Read only

Former Member
0 Likes
964

Hi Yunus,

You can not use logical conditions in the READ statement.

Remove the AND conditions from the READ statement and it will work. READ statement by default takes the condition as AND.

<b>Reward points if it helps.</b>

Regards,

Amit Mishra

Message was edited by: Amit Mishra

Read only

0 Likes
963

hi,

try:


read table itabMAST with key matnr = struct-matnr 
                             WERKS = company 
                             stlan = '5'.

Andreas

Read only

Former Member
0 Likes
963

Hi,

Your problem is the field WERKS is not available in the internal table itabMAST.

Try to bring in the werks in the internal table itabMAST and then use the READ statement.

Also while using read statement there will not be any key word AND used.

Lakshminarayanan.

Please mark helpful answers for points.

Read only

0 Likes
963

but instead od and what can i use...bcoz i want to read table with multiple condition..

regards,

yunus

Read only

Former Member
0 Likes
963

Hi,

1. Chek your itabMAST table, is there WERKS fields ??

2. Remove "AND" statement from your "Read Table" statement.

Regards,

Read only

0 Likes
963

Hi, here is another example:

IF sy-subrc <> 0.

MOVE it_equz-hequi TO it_equz_dum2-hequi.

READ TABLE it_equz_dum1 WITH KEY equnr = it_equz-equnr

hequi = it_equz-hequi

BINARY SEARCH.

IF sy-subrc = 0.

SELECT SINGLE anlnr

shtxt

FROM itob

INTO (it_itob-anlnr, it_itob-shtxt)

WHERE equnr EQ it_equz_dum1-hequi.

IF sy-subrc = 0.

MOVE it_itob-anlnr TO it_finaltab-asset_dum.

MOVE it_itob-anlnr TO it_finaltab-asset.

MOVE it_itob-shtxt TO it_finaltab-description.

endif.

endif.

endif.

Read only

Former Member
0 Likes
963

Hi Yunus,

Please have a look at the following programs in SE38.

DEMO_INT_TABLES_READ_ASSIGNING

DEMO_INT_TABLES_READ_COMPARING

DEMO_INT_TABLES_READ_INDEX

DEMO_INT_TABLES_READ_INDEX_BIN

DEMO_INT_TABLES_READ_TRANSPORT

DEMO_INT_TABLES_READ_TRANSP_NO

<b>Reward points if it helps.</b>

Regards,

Amit Mishra

Read only

Former Member
0 Likes
963

Hi,

First of all i am not sure why you are using the statement <b>ind = sy-tabix</b>.

Your code should look like this:

loop at struct.

ind = sy-tabix.

read table itabMAST with key matnr = struct-matnr

WERKS = company

stlan = '5'.

if sy-subrc = 0.

move itabMAST-stlnr to struct-stlnr.

modify struct index ind transporting stlnr.

endif.

endloop.

Lakshminarayanan