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: 

format_message

Former Member
0 Kudos

Hi all,

i m using FM format_message to trace the error as well as success messages from th messtab. hw to use this FM with using and changing parameters. please help me out

Thanks & Regards

Ashu Singh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Anshu,

Please refer the following.

The code here collects all messgages from BDC and displayes them.

call transaction 'MM01' using itab1 mode v_mode update 'S' messages into it_messages.

LOOP AT it_messages INTO wa_messages.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = wa_messages-msgid

lang = 'en'

no = wa_messages-msgnr

v1 = wa_messages-msgv1

v2 = wa_messages-msgv2

v3 = wa_messages-msgv3

v4 = wa_messages-msgv4

IMPORTING

msg = wa_messages-msgv1

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.

  • modify it_messages from wa_messages index sy-tabix.

ENDLOOP.

Let me know if you need any further help on this.

Kind Regards,

Raj

5 REPLIES 5

GauthamV
Active Contributor
0 Kudos

hi,

use this sample code.

data:v_text(80).

call function 'FORMAT_MESSAGE'

exporting

id = sy-msgid

lang = 'EN'

no = sy-msgno

v1 = sy-msgv1

v2 = sy-msgv2

v3 = sy-msgv3

v4 = sy-msgv4

importing

msg = v_text

exceptions

not_found = 1

others = 2.

Former Member
0 Kudos

Hi Ashu,

[format_message|http://www.sap-img.com/abap/retreive-error-message-from-bdc.htm]

Regards,

Sravanthi

former_member181995
Active Contributor
0 Kudos

Track where-used list for this FM.

former_member585060
Active Contributor
0 Kudos

Hi,

Try this way

*******************************************************************

CALL TRANSACTION 'XD01' USING i_bdcdata MODE 'N' UPDATE 'S' MESSAGES INTO i_bdcmsgcoll.

IF sy-subrc EQ 0

PERFORM get_success_messages.

WRITE 😕 i_upload-kunnr, v_msg.

ELSE.

PERFORM get_error_messages.

WRITE 😕 i_upload-kunnr, v_msg.

ENDIF.

FORM get_success_messages.

READ TABLE i_bdcmsgcoll WITH KEY msgtyp EQ 'S'.

IF sy-subrc EQ 0.

CALL FUNCTION 'FORMAT_MESSAGE'

Exporting

id = i_bdcmsgcoll-msgid

lang = sy-langu

no = i_bdcmsgcoll-msgnr

v1 = i_bdcmsgcoll-msgv1

v2 = i_bdcmsgcoll-msgv2

Importing

msg = v_msg.

ENDIF.

ENDFORM.

FORM get_error_messages.

READ TABLE i_bdcmsgcoll WITH KEY msgtyp EQ 'E'.

IF sy-subrc EQ 0.

CALL FUNCTION 'FORMAT_MESSAGE'

Exporting

id = i_bdcmsgcoll-msgid

lang = sy-langu

no = i_bdcmsgcoll-msgnr

v1 = i_bdcmsgcoll-msgv1

v2 = i_bdcmsgcoll-msgv2

Importing

msg = v_msg.

ENDIF.

ENDFORM.

*********************************************************************

Regards

Bala Krishna

Former Member
0 Kudos

Anshu,

Please refer the following.

The code here collects all messgages from BDC and displayes them.

call transaction 'MM01' using itab1 mode v_mode update 'S' messages into it_messages.

LOOP AT it_messages INTO wa_messages.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = wa_messages-msgid

lang = 'en'

no = wa_messages-msgnr

v1 = wa_messages-msgv1

v2 = wa_messages-msgv2

v3 = wa_messages-msgv3

v4 = wa_messages-msgv4

IMPORTING

msg = wa_messages-msgv1

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.

  • modify it_messages from wa_messages index sy-tabix.

ENDLOOP.

Let me know if you need any further help on this.

Kind Regards,

Raj