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

How do i get data when displaying error message in BDC

Former Member
0 Likes
1,680

hi,

I have generated one internal table for displaying error message using BDCMSGCOLL, i want the the error to display according to the field name,

Hw can i get it...

ex: <Material name> Error message as name already created or unit doesnt exit...

Pls reply,

Regards,

Divi.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,425

hi,

while displaying error message write your internal table filed also.

i.e. loop at itab.

performs...

call transaction ...

if sy-subrc <> 0.

write : itab-materialname.

LOOP AT bdcmsg.

WRITE: bdcmsg-DYNAME,

bdcmsg-DYNUMB,

bdcmsg-MSGTYP,

bdcmsg-MSGSPRA,

bdcmsg-MSGID,

bdcmsg-MSGNR,

bdcmsg-MSGV1,

bdcmsg-MSGV2,

bdcmsg-MSGV3,

bdcmsg-MSGV4.

ENDLOOP.

endif.

endloop.

if helpful reward points

10 REPLIES 10
Read only

Former Member
0 Likes
1,425

in some times , SAP will through the errors without field names.In this case u have to educate ur Users.

Regards

Prabhu

Read only

Former Member
0 Likes
1,425

you must be doing a call transaction within a loop of (for examples) materials internal table.

once you get the messages, after the call transaction statements, concatenate the material name (or whatever you want to concatenate) in the msgv1 field of the message structure...

should work through such a workaround. try it

regards,

Priyank

Read only

Former Member
0 Likes
1,426

hi,

while displaying error message write your internal table filed also.

i.e. loop at itab.

performs...

call transaction ...

if sy-subrc <> 0.

write : itab-materialname.

LOOP AT bdcmsg.

WRITE: bdcmsg-DYNAME,

bdcmsg-DYNUMB,

bdcmsg-MSGTYP,

bdcmsg-MSGSPRA,

bdcmsg-MSGID,

bdcmsg-MSGNR,

bdcmsg-MSGV1,

bdcmsg-MSGV2,

bdcmsg-MSGV3,

bdcmsg-MSGV4.

ENDLOOP.

endif.

endloop.

if helpful reward points

Read only

0 Likes
1,425

call transaction 'MI01' using itab_bdcdata mode 'A' MESSAGES INTO

ITAB_msg.

CLEAR itab_bdcdata[].

loop at itab_msg where msgtyp = 'S'. (u can give yiur msg type here)

break-point.

message i010(zmgs) with itab_msg-MSGV1.

docno = itab_msg-msgv1.

endloop.

Read only

0 Likes
1,425

Hi,

Thnk u i got it, but

I want along with the error message,

Now i am getting it field name seperate and error message seperate.

Read only

0 Likes
1,425

use FM 'MESSAGE_PREPARE'.

u will get it as error message itself...

Read only

Former Member
0 Likes
1,425

Hi Divya,

Go to the program BDCRECX1 and check for the code :

LOOP AT MESSTAB.

SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA

AND ARBGB = MESSTAB-MSGID

AND MSGNR = MESSTAB-MSGNR.

IF SY-SUBRC = 0.

L_MSTRING = T100-TEXT.

IF L_MSTRING CS '&1'.

REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ELSE.

REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ENDIF.

CONDENSE L_MSTRING.

WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).

ELSE.

WRITE: / MESSTAB.

ENDIF.

ENDLOOP.

Hope this will solve your problem.

Reward if it helps.

Regards,

Hemant.

Read only

Former Member
0 Likes
1,425

Hi,

just have a look at the table BDCMSGCOLL in SE11.

check the fields in that

data itab like BDCMSGCOLL occurs 0 with header line.

call transaction 'mk01' messages into itab.

loop at itab.

write : / itab-fldname.

endloop.

reward if useful

Regards,

Prajith

Read only

Former Member
0 Likes
1,425

Hi Divya,

Try the below

CALL TRANSACTION 'MM01'

USING bdcdata

MODE 'N'

MESSAGES INTO MSGTAB.

IF SY-SUBRC NE 0.

move itab-matnr to jtab-matnr.

append jtab.

PERFORM CHECK.

ENDIF.

FORM CHECK.

LOOP AT MSGTAB where msgtyp = 'E'.

read table jtab index sy-index.

write:/ jtab-matnr.

CALL FUNCTION 'MESSAGE_PREPARE'

EXPORTING

LANGUAGE = sy-langu

MSG_ID = MSGTAB-MSGID

MSG_NO = MSGTAB-MSGNR

MSG_VAR1 = MSGTAB-MSGV1(50)

MSG_VAR2 = MSGTAB-MSGV2(50)

MSG_VAR3 = MSGTAB-MSGV3(50)

MSG_VAR4 = MSGTAB-MSGV4(50)

IMPORTING

MSG_TEXT = L_MSG

EXCEPTIONS

FUNCTION_NOT_COMPLETED = 1

MESSAGE_NOT_FOUND = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

WRITE: L_MSG.

ENDLOOP.

ENDFORM.

- Satish

Read only

Former Member
0 Likes
1,425

Divya,

Take another field of lenght error message plus material name together. do the concatenation of those two fields into one field and displayt that field it will have all together in one field itself

Siva