09-09-2008 3:09 PM
How to capture error message like below in to the string?
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Regards
Ronny
09-09-2008 3:13 PM
Hello Ronny,
try
Data:
wa_error(150) type C.
Call Function/BAPI
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = wa_err
EXCEPTIONS
not_found.
If wa_err is not initial.
Write:/ 'This error occurred: ', wa_err.
endif.
Regards,
C
09-09-2008 3:13 PM
Hello Ronny,
try
Data:
wa_error(150) type C.
Call Function/BAPI
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = wa_err
EXCEPTIONS
not_found.
If wa_err is not initial.
Write:/ 'This error occurred: ', wa_err.
endif.
Regards,
C
09-09-2008 3:16 PM
even easier:
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno INTO lf_string
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Thomas
09-09-2008 3:20 PM
call transaction 'XK01' using i_bdcdata
mode 'N'
update 'S'
messages into i_bdcmsgcoll.
if sy-subrc <> 0.
perform get_error.
write:/ itab , v_text.
endif.
*****************************************
*Form
*****************************************
form get_error.
loop at i_bdcmsgcoll.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = i_bdcmsgcoll-MSGID
LANG = sy-langu
NO = i_bdcmsgcoll-MSGNr
V1 = i_bdcmsgcoll-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = v_text
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.
endloop.
endform. " get_error
Edited by: Bala Krishna on Sep 9, 2008 7:50 PM