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

FM for error messages

Former Member
0 Likes
959

Could anyone tell me which Function Module is used to retrieve error messages in BDC? Code samples will be helpful.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
923

Using function module 'FORMAT_MESSAGE' you can capture the messages.

Here is a sample of the program code for that:

LOOP AT it_messtab.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = it_messtab-msgid

lang = it_messtab-msgspra

no = it_messtab-msgnr

v1 = it_messtab-msgv1

v2 = it_messtab-msgv2

IMPORTING

msg = g_msg

EXCEPTIONS

OTHERS = 0.

IF it_messtab-msgtyp = 'S'.

it_sucess-sucess_rec = g_msg.

it_sucess-lifnr = it_header-lifnr." Based on your field

it_sucess-tabix = v_lines.

APPEND it_sucess.

ELSEIF it_messtab-msgtyp = 'E'.

it_error-error_rec = g_msg.

it_error-lifnr = it_header-lifnr.

it_error-tabix = v_lines.

APPEND it_error.

ELSE.

it_info-info_rec = g_msg.

it_info-lifnr = it_header-lifnr.

it_info-tabix = v_lines.

APPEND it_info.

ENDIF.

ENDLOOP.

Could anyone tell me which Function Module is used to retrieve error messages in BDC? Code samples will be helpful.

5 REPLIES 5
Read only

Former Member
0 Likes
923

format_message

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

for example...

data : v_message(100) type c.

call transaction NNNN mode A update S messages into it_messages.

loop at it_messages where msgty = 'E'.

call function 'format_message'

exporting

*it_messages details

importing

v_message.

write 😕 v_message.

clear v_message.

endloop.

Read only

former_member188829
Active Contributor
0 Likes
923

Hi,

FORMAT_MESSAGE

Read only

Former Member
0 Likes
924

Using function module 'FORMAT_MESSAGE' you can capture the messages.

Here is a sample of the program code for that:

LOOP AT it_messtab.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = it_messtab-msgid

lang = it_messtab-msgspra

no = it_messtab-msgnr

v1 = it_messtab-msgv1

v2 = it_messtab-msgv2

IMPORTING

msg = g_msg

EXCEPTIONS

OTHERS = 0.

IF it_messtab-msgtyp = 'S'.

it_sucess-sucess_rec = g_msg.

it_sucess-lifnr = it_header-lifnr." Based on your field

it_sucess-tabix = v_lines.

APPEND it_sucess.

ELSEIF it_messtab-msgtyp = 'E'.

it_error-error_rec = g_msg.

it_error-lifnr = it_header-lifnr.

it_error-tabix = v_lines.

APPEND it_error.

ELSE.

it_info-info_rec = g_msg.

it_info-lifnr = it_header-lifnr.

it_info-tabix = v_lines.

APPEND it_info.

ENDIF.

ENDLOOP.

Read only

former_member404244
Active Contributor
0 Likes
923

Hi,

u can use either "FORMAT_MESSAGE" OR "MESSAGE_TEXT_BUILD".

Regards,

nagaraj

Read only

Former Member
0 Likes
923

Hi Sneha,

the function modules that could be used are

FORMAT_MESSAGE

BUILD_TEXT_MESSAGE

Reward points if this helps,

Kiran