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 TABLE bdcmsg WITH KEY msgtyp = 'E' msgtyp = 'A'.

Former Member
0 Likes
3,058

In the ECC6.0 system,the following code is showing syntax error (msgtyp should be used only once)

READ TABLE bdcmsg WITH KEY msgtyp = 'E' msgtyp = 'A'.

Can anyone pls give me a solution.

Regards

Sajid

12 REPLIES 12
Read only

Former Member
0 Likes
2,038

HI,

you can read the table only with different keys.

e.g.

READ TABLE bdcmsg WITH KEY msgtyp = 'E' msgart = 'A'.

I think you need to work with an workingarea so that you can go over more then one msgtyp.

e.g.

DATA: spfli_tab TYPE SORTED TABLE OF spfli

WITH UNIQUE KEY carrid connid,

spfli_key LIKE LINE OF spfli_tab.

FIELD-SYMBOLS <spfli> TYPE spfli.

...

SELECT *

FROM spfli

INTO TABLE spfli_tab

WHERE carrid = 'LH'.

...

spfli_key-carrid = 'LH'.

spfli_key-connid = '0400'.

READ TABLE spfli_tab FROM spfli_key ASSIGNING <spfli>.

IF sy-subrc = 0.

...

ENDIF.

regards

Nicole

Edited by: Nicole Lorenz on Mar 18, 2008 5:44 AM

Edited by: Nicole Lorenz on Mar 18, 2008 5:45 AM

Read only

Former Member
0 Likes
2,038

Hi,

I think there is no gap between msgtyp.Put space .

READ TABLE bdcmsg WITH KEY msgtyp = 'E'

msgtyp = 'A'.

Reward if useful...

Read only

0 Likes
2,038

how will i write the code if i want to read the internal table with key = either E or A.

The following code does not work

READ TABLE bdcmsg WITH KEY msgtyp = 'E' or msgtyp = 'A'.

Read only

0 Likes
2,038

Hi

U can use the string relational operator CA which means contains any.

Thanks

Anon

Read only

0 Likes
2,038

read the table twice...

READ TABLE bdcmsg WITH KEY msgtyp = 'E' .

if sy-subrc = 0.

else.

READ TABLE bdcmsg WITH KEY msgtyp = 'A' .

endif.

Read only

0 Likes
2,038

The best way is

READ TABLE bdcmsg with key msgtyp = 'E'.

if sy-subrc ne 0.

read table bdcmsg with key msgid = 'A'.

endif.

Thanks 4 all.....

Read only

Former Member
0 Likes
2,038

With in read statement you can't use same key 2 times.

With in READ statement you can't use AND & OR.

Better use

LOOP AT <tab> WHERE <COND>.

ENDLOOP.

Read only

Former Member
0 Likes
2,038

Hi,

The same key cannot be used twice in the same read statement.

Instead you can try doing this.

READ TABLE bdcmsg with key msgtyp = 'E'.

if sy-subrc ne 0.

read table bdcmsg with key msgid = 'A'.

endif.

Regards.

Abhisek.

Read only

Former Member
0 Likes
2,038

Hi,

READ TABLE bdcmsg

WITH KEY msgtyp = 'E'

msgtyp = 'A'.

The above statement would try to read a record from table bdcmsg where msgtyp = 'E' and msgtyp = 'A'

This is incorrect as for the same record it is not possible to have two different message types.

If you want to get the records whose message type is 'E' or 'A' you could refer the code below

LOOP AT bdcmsg INTO ls_bdcmsg.

IF ls_bdcmsg-msgtyp = 'E' OR ls_bdcmsg-msgtyp = 'A' .

" This is a record with message type as Error or Abort

ENDIF.

ENDLOOP.

Hope this helps.

Regards,

Farheen.

Read only

Former Member
0 Likes
2,038

Hi,

The same key cannot be used twice in the same read statement.

Instead you can try doing this.

READ TABLE bdcmsg with key msgtyp = 'E'.

if sy-subrc ne 0.

read table bdcmsg with key msgid = 'A'.

endif.

Regards.

Abhisek.

Read only

edwin_romero
Discoverer
0 Likes
2,038

CLEAR flag_error.

LOOP AT bdcmsg TRANSPORTING NO FIELDS WHERE msgtyp CO 'EA'.

flag_error = 'X'.

EXIT.

ENDLOOP.

Read only

klausschaffer353
Newcomer
0 Likes
2,038

This is working, however if done with variables it's giving a syntax error.

READ TABLE mt_return
TRANSPORTING NO FIELDS

WITH KEY type = 'E''A'.