‎2008 Feb 19 6:06 AM
How to Use Std Function module 'FORMAT_MESSAGE' ?
What is the purpose of that ?
Regards,
pandu.
‎2008 Feb 19 6:13 AM
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.
‎2008 Feb 19 6:16 AM
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.