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 with Single key with multiple values

Former Member
0 Likes
6,332

Dear Friends,

In ECC 4.6c, I wrote statement like this.

Read table message with key type = 'E' or 'S'.

if sy-subrc = 0.

Populated the message log to output internal table.

endif.

But when i transported to QA which is ECC 6.0, it is giving error.

Can any one help me in modifying this qurey.

Plse read my question thoroughly and reply me back.

Regards,

Santosh Kumar M

5 REPLIES 5
Read only

Former Member
0 Likes
1,814

> In ECC 4.6c, I wrote statement like this.

>

> Read table message with key type = 'E' or 'S'.

> if sy-subrc = 0.

>

> Populated the message log to output internal table.

>

> endif.

>

loop at message where key = 'E' or 
                                   key = 'S'.
"Populated the message log to output internal table. and now exit for first instance
exit.
endloop.

Read only

vinod_vemuru2
Active Contributor
1,814

Hi,

You can't use OR condition with READ table. it is always AND condition.

Here 2 ways for ur problem.

If u want to have just one message in the log then use multiple reads.

READ TABLE message WITH KEY type = 'E'.

If sy-subrc IS INITIAL.

populate log.

ELSE.

READ TABLE message WITH KEY type = 'S'.

If sy-subrc IS INITIAL.

populate log.

ENDIF.

ENDIF.

If u want all messages then u have to loop through and populate the log as sugested by Vijay but

Without exit in loop.(Since u need all the messages)

LOOP AT message into wa WHERE type = 'E' or type = 'S'.

populate log.

ENDLOOP.

Thanks,

Vinod.

Read only

Former Member
0 Likes
1,814

Hi,

try this....

Read table itab with key type = 'E' or type = 'S'.

if sy-subrc = 0.

*****

*****

*****

endif.

Read only

Former Member
0 Likes
1,814

hiii

you can use like below code..it will work as same as you want with both key conditions.

READ TABLE message WITH KEY type = 'E'.

If sy-subrc EQ 0.

READ TABLE message WITH KEY type = 'S'.

if sy-subrc EQ 0.

perform ....

endif.

endif.

regards

twinkal

Read only

matt
Active Contributor
0 Likes
1,814

>

> Dear Friends,

>

> In ECC 4.6c, I wrote statement like this.

>

> Read table message with key type = 'E' or 'S'.

> if sy-subrc = 0.

>

>

> Santosh Kumar M

Really? Are you sure? To the best of my 10+ years experience, this has never been part of the syntax of READ.