Application Development 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: 

BDC: Diffrence between Format_message and Write_message

Former Member
0 Kudos
244

hi abapers can u please explain format_message and write_message.

if i use call transaction syntax like

call transaction 'mk01' using bdctab mode 'N' update 's' messages into bdc_msg.

shall i take format_message or write_message and wht parametrs we should pass in that.

if i put mode 'E' error screen mode wht should i do.

please guide me.

3 REPLIES 3

Former Member
0 Kudos
110

when the messages are stored in bdc_msg it has various paramaeters like message type/message no/ message...

U can use directly to write this message or else u can do a formatting to the message using format_message and use it.

it depends on ur requirement.

Former Member
0 Kudos
110

I understand that u r trying to collect errors from call transaction. u dont actually require BDCMSGCOLL to collect errors . Just FORMAT_MESSAGE will give u the error text.

Follow the code below.

call transaction 'mk01' using bdctab mode 'N' update 's' .

If sy-subrc ne 0 . " Incase of error on BDC.

data : lv_msgtext(250).

clear lv_msgtext.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = SY-MSGID

LANG = sy-langu

NO = SY-MSGNO

V1 = SY-MSGV1

V2 = SY-MSGV2

V3 = SY-MSGV3

V4 = SY-MSGV4

IMPORTING

MSG = lv_msgtext

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

    • Now this variable lv_msgtxt will hold the error text for that particular run. just

    • write code below to move this error text to error internal table .

ENDIF.

hope this will help. Reward points if it helps.

regards,

Barath.

Former Member
0 Kudos
110

HI,

Format_message Takes a message id and number, and puts it into a variable. Works better than WRITE_MESSAGE, since some messages use $ as a place holder, and WRITE_MESSAGE does not accommadate that, it only replaces the ampersands (&) in the message.

Regards

Sudheer