‎2008 Mar 18 9:40 AM
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
‎2008 Mar 18 9:41 AM
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
‎2008 Mar 18 9:45 AM
Hi,
I think there is no gap between msgtyp.Put space .
READ TABLE bdcmsg WITH KEY msgtyp = 'E'
msgtyp = 'A'.
Reward if useful...
‎2008 Mar 18 9:55 AM
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'.
‎2008 Mar 18 9:58 AM
Hi
U can use the string relational operator CA which means contains any.
Thanks
Anon
‎2008 Mar 18 10:00 AM
read the table twice...
READ TABLE bdcmsg WITH KEY msgtyp = 'E' .
if sy-subrc = 0.
else.
READ TABLE bdcmsg WITH KEY msgtyp = 'A' .
endif.
‎2008 Mar 18 10:17 AM
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.....
‎2008 Mar 18 9:54 AM
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.
‎2008 Mar 18 9:57 AM
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.
‎2008 Mar 18 9:58 AM
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.
‎2008 Mar 18 9:59 AM
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.
‎2019 Oct 13 6:10 AM
CLEAR flag_error.
LOOP AT bdcmsg TRANSPORTING NO FIELDS WHERE msgtyp CO 'EA'.
flag_error = 'X'.
EXIT.
ENDLOOP.
‎2022 Aug 10 9:52 AM
This is working, however if done with variables it's giving a syntax error.
READ TABLE mt_returnWITH KEY type = 'E''A'.