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

Error while read table

Former Member
0 Likes
1,530

Hi,

This is my code

read table ALL_NVALS_TAB with KEY VAL = nvals_tab-val ID <> nvals_tab-id.

if sy-subrc = 0.

message i005 with node_val.

exit.

endif.

This is giving a syntax error on " = expected after ID"

on replacing the code with =

read table ALL_NVALS_TAB with KEY VAL = nvals_tab-val ID = nvals_tab-id.

if sy-subrc = 0.

message i005 with node_val.

exit.

endif.

this is giving no error and can be activated.But it is not solving my purpose . Can only ' = ' is used as a operator on read table with key.

Is there any other way in which I can do it ( preferable with READ statement)

7 REPLIES 7
Read only

dev_parbutteea
Active Contributor
0 Likes
971

Hi,

I think that you missed the equal to sign after the ID field....

read table ALL_NVALS_TAB

with KEY VAL = nvals_tab-val

ID = nvals_tab-id.

if sy-subrc = 0.

message i005 with node_val.

exit.

endif.

Regards.

Read only

Former Member
0 Likes
971

Hi,

With read you can use only Equalto '=' operator. If you want to use other operators the use

Loop AT <itab> Where <Condt>.

ENDLOOP>

Read only

GauthamV
Active Contributor
0 Likes
971

Hi,

There is nothing wrong in your coding using =.

Whats is your exact problem ?

Read only

Former Member
0 Likes
971

You have missed the ' = ' sign.

try this

read table ALL_NVALS_TAB with KEY VAL = nvals_tab-val

ID = nvals_tab-id.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
971

Hello Priya,

read table ALL_NVALS_TAB with KEY VAL = nvals_tab-val ID = nvals_tab-id.

if sy-subrc = 0.

message i005 with node_val.

exit.

endif.

this is giving no error and can be activated.But it is not solving my purpose . Can only ' = ' is used as a operator on read table with key.

READ TABLE is used to get a single, unique record from the internal table so '=' is the only operator allowed.

Debug your code and check if the table ALL_NVALS_TAB has entries with VAL = nvals_tab-val & ID = nvals_tab-id. If not then the sy-subrc <> 0.

Plz revert back with your observations.

BR,

Suhas

Read only

Former Member
0 Likes
971

Hi

Check out the syntax at[ Read|http://help.sap.com/abapdocu/en/ABAPREAD_TABLE.htm]

Also there is an [example|http://help.sap.com/abapdocu/en/ABENREAD_ITAB_USING_KEY_ABEXA.htm] you can check out.

Hope this helps

Regards,

Jayanthi.K

Read only

Former Member
0 Likes
971

Hi,

I think you have missed '=' operator after ID

read table ALL_NVALS_TAB with KEY VAL = nvals_tab-val

ID = nvals_tab-id.

if sy-subrc = 0.

message i005 with node_val.

exit.

endif.

Now it will work fine.

With Read table we can use only '=' operator . if you want to use other than '=' operator then use

Loop at ALL_NVALS_TAB where 'you can use the operator u want'