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: 

How to store BDC error messages into oracle database table?

Former Member
0 Kudos

Hello Experts,

I have a peculier requirement wherein I need to store the error messages occured while executing the transaction using BDC (Call Transaction Method) in an Oracle Database table format. Is that possible, if yes, how?

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

While doing call transaction, if an error occurs in updation, we declare bdcmsgcoll and store our messages in it, but how to retreive error message from it

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.

Once you get it in itab , u can use normal open sql statements to update that into oracle DB from tht itab.

Hope this is useful, Do reward.

3 REPLIES 3

Former Member
0 Kudos

Hi Radhika,

creat a z-table of structure BDCMSGCOLL

Insert the error messages to that table

Former Member
0 Kudos

Hi,

Structure of BDCMSGCOLL.

TCODE -> BDC Transaction code

DYNAME -> Batch input module name

DYNUMB -> Batch input screen number

MSGTYP ->Batch input message type

MSGSPRA -> Language ID of a message

MSGID -> Batch input message ID

MSGNR -> Batch input message number

MSGV1 -> Variable part of a message

MSGV2 -> Variable part of a message

MSGV3 -> Variable part of a message

MSGV4 -> Variable part of a message

FLDNAME -> Field name

Ex :

DATA : BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE,

BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.

CALL TRANSACTION 'MM01' USING BDCDATA MODE N UPDATE S MESSAGES INTO BDCMSGCOLL.

IF SY-SUBRC 0.

PERFORM ERR.

CLEAR I_MSG.

REFRESH I_MSG.

ENDIF.

&----


*& Form ERR

&----


text

-


--> p1 text

<-- p2 text

-


form ERR .

DATA V_MSG(255) TYPE C.

READ TABLE I_MSG WITH KEY MSGTYP = 'E'.

IF SY-SUBRC = 0.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = I_MSG-MSGID

LANG = 'E'

NO = I_MSG-MSGNR

V1 = I_MSG-MSGV1

V2 = I_MSG-MSGV2

V3 = I_MSG-MSGV3

V4 = I_MSG-MSGV4

IMPORTING

MSG = V_MSG

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.

WRITE V_MSG. " Error Message Displayed Here.

CLEAR V_MSG.

ENDIF.

endform. " ERR

hope this will help you.

Reward if found helpfull,

Cheers,

Chaitanya.

Former Member
0 Kudos

hi,

While doing call transaction, if an error occurs in updation, we declare bdcmsgcoll and store our messages in it, but how to retreive error message from it

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.

Once you get it in itab , u can use normal open sql statements to update that into oracle DB from tht itab.

Hope this is useful, Do reward.