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

'FORMAT_MESSAGE'

Former Member
0 Likes
2,157

How to Use Std Function module 'FORMAT_MESSAGE' ?

What is the purpose of that ?

Regards,

pandu.

2 REPLIES 2
Read only

Former Member
0 Likes
1,490

call transaction <t_code> using <bdc_table> mode <A/E/N> update <A/S> messages into <it_messages>.

this it_messages has to be of type BDCMSGCOLL.

You can see the structure of the BDCMSGCOLL and read the messages accordingly.

Basically, the errors are logged automatically when we create a batch input session and execute the session, while in case of Call Transaction .. it is not so.. hence we use this method of storing the messages into the internal table.

After the call transaction ... You can loop on this internal table and see the messages.

It will give you all the details like the message type - Error, warning , Info or abend.

the message is split into 4 parts...

DATA: BDCDATA TYPE TABLE OF BDCDATA.

DATA: ITAB TYPE TABLE OF BDCMSGCOLL.

DATA: PROGRAM LIKE SY-REPID,

WA_BDCDATA TYPE BDCDATA.

WA_BDCDATA-PROGRAM = 'SAPMS38M'.

WA_BDCDATA-DYNPRO = '0100'.

WA_BDCDATA-DYNBEGIN = 'X'.

APPEND WA_BDCDATA TO BDCDATA.

CLEAR WA_BDCDATA.

WA_BDCDATA-FNAM = 'RS38M-PROGRAMM'.

WA_BDCDATA-FVAL = PROGRAM.

APPEND WA_BDCDATA TO BDCDATA.

...

CALL TRANSACTION 'SE38' USING BDCDATA MODE 'N'

MESSAGES INTO ITAB.

Now formatting messages:

loop at itab.

perform format_message USING itab-msgid itab-msgnr itab-msgv1 itab-msgv2 itab-msgv3 itab-msgv4.

endloop.

FORM FORMAT_MESSAGE USING P_MSGID LIKE SY-MSGID

P_MSGNO LIKE SY-MSGNO

P_MSGV1 LIKE SY-MSGV1

P_MSGV2 LIKE SY-MSGV2

P_MSGV3 LIKE SY-MSGV3

P_MSGV4 LIKE SY-MSGV4.

DATA: P_TEXT(100) TYPE C.

CLEAR: P_TEXT.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = P_MSGID

LANG = SY-LANGU

NO = P_MSGNO

V1 = P_MSGV1

V2 = P_MSGV2

V3 = P_MSGV3

V4 = P_MSGV4

IMPORTING

MSG = P_TEXT

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2.

IF SY-SUBRC EQ 0.

WRITE:/ P_TEXT.

ENDIF.

ENDFORM. " FORMAT_MESSAGE[/code]

Hope this helps.

Read only

Former Member
0 Likes
1,490
DATA: msg TYPE string.
CALL FUNCTION 'FORMAT_MESSAGE'
 EXPORTING
   ID              = 'V'
   LANG            = '-D'
   NO              = '550'
   V1              = 'Test Message'
   V2              = 'using'
   V3              = 'function module'
   V4              = SY-MSGV4
 IMPORTING
   MSG             = msg
 EXCEPTIONS
   NOT_FOUND       = 1
   OTHERS          = 2       .

write:/ msg.

V --> message class from SE91

550 --> message number which u would liek to display else choose nuber with &&&&

Then if the message number contains three & u can pass three text upto V3...

Output will be like

Test Message using function module.

Hope this solves ur query.