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

How to find errors from BDC log

Former Member
0 Likes
5,753

I use BDC session method to upload data. But during upload some error records are found which are stored in LOG file.

My requirement is how to get these error records from the session log file and again I want to store these error records in a z table.

Please suggest me how to solve this requirement ?

Regards,

Ajit

1 ACCEPTED SOLUTION
Read only

Former Member

I use BDC session method to upload data. But during upload some error records are found which are stored in LOG file.

My requirement is how to get these error records from the session log file and again I want to store these error records in a z table.

Please suggest me how to solve this requirement ?

Regards,

Ajit

9 REPLIES 9
Read only

gouravkumar64
Active Contributor
0 Likes
3,622

Hi ,

In session method I have no IDEA, But if you use Call transaction It can achieved.

In that when you write

CALL TRANSACTION 'CR01' USING I_BDCDATA

    MODE W_MODE

    UPDATE 'S'

    MESSAGES INTO I_MSG.

then sy-subrc check.

After this Loop in I_msg.

LOOP AT I_MSG INTO WA_MSG WHERE MSGTYP EQ 'E'.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

       EXPORTING

         MSGID               = WA_MSG-MSGID

         MSGNR               = WA_MSG-MSGNR

         MSGV1               = WA_MSG-MSGV1

         MSGV2               = WA_MSG-MSGV2

         MSGV3               = WA_MSG-MSGV3

         MSGV4               = WA_MSG-MSGV4

       IMPORTING

         MESSAGE_TEXT_OUTPUT = W_MSG1.

     WA_OUTPUT-MSG_ERR = W_MSG1.

     WA_OUTPUT-LINE_NO = GV_INDEX.


     MODIFY WA_OUTPUT TO ZABDC. "Your ztable name.

In case of internal table you can use APPEND / MODIFY.


APPEND WA_OUTPUT TO I_OUTPUT.

In this way you can store that error file.

You also download that one Using GUI_DOWNLOAD.

Search in web for other help.

Hope it helps.

Thanks

Gourav.




Read only

Former Member
0 Likes
3,622

Hi Ajit,

Declare the internal table that is used to finally collect the error records from the BDC session log.

TYPES : BEGIN OF ty_s_error,
msg_err(
60) TYPE c,
END OF ty_s_error.

it_output type table of ty_s_error,
wa_output
like line of it_output.

To create Log for the Error Message in BDC, we use structure BDCMSGCOLL.

DATA:
t_msg
TYPE TABLE OF bdcmsgcoll,   " Collecting Error messages
w_msg
TYPE bdcmsgcoll,
w_msg1(
51).

w_mode    TYPE c.

* Mode 'A' = Foreground mode
* Mode 'N' = Background mode

w_mode = 'A'.


CALL TRANSACTION 'ME51' USING t_bdcdata
MODE w_mode
UPDATE 'S'
MESSAGES
INTO t_msg.

IF sy-subrc EQ 0.
*    Uploaded into the database
WRITE 😕 'DATA UPLOADED IN TABLE EBAN...' .
ELSE.
*    Error Found
LOOP AT t_msg INTO w_msg WHERE msgtyp EQ 'E'.
*     Format Message
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid               = w_msg-msgid
msgnr               = w_msg-msgnr
msgv1               = w_msg-msgv1
msgv2               = w_msg-msgv2
msgv3               = w_msg-msgv3
msgv4               = w_msg-msgv4
IMPORTING
message_text_output = w_msg1.


wa_output-msg_err = w_msg1.

* Add any additional details if required
data:
wa_string(
10) type c.

wa_string = fs_field-matnr.

concatenate wa_string wa_output-msg_err into wa_output-msg_err separated by space.

APPEND wa_output-msg_err TO it_output.


ENDLOOP.

ENDIF.

Now you can used this table it_output to update your database table with the messages.

Regards,

Susmitha


Read only

0 Likes
3,622

in bdc program i am getting message output for all screen , where as i want only success and failure message ..

bdc recording for mm01

my code is \

    CALL TRANSACTION 'MM01'

               USING bdcdata

               MODE bmode

               MESSAGES  INTO messtab .

    CLEAR bdcdata.

    REFRESH bdcdata.

    CLEAR: IT_FINAL,g_msg.

    LOOP AT messtab.

      CLEAR: g_msg.

      CALL FUNCTION 'FORMAT_MESSAGE'

        EXPORTING

          ID        = messtab-msgid

          LANG      = messtab-msgspra

          NO        = messtab-msgnr

          V1        = messtab-msgv1

          V2        = messtab-msgv2

          V3        = messtab-msgv3

          V4        = messtab-msgv4

        IMPORTING

          MSG       = g_msg

        EXCEPTIONS

          NOT_FOUND = 1

          OTHERS    = 2.

      WRITE:/ G_MSG.

    ENDLOOP.

    CLEAR: messtab,G_MSG.

    REFRESH:messtab.

  ENDLOOP.

Read only

Former Member
0 Likes
3,622

Hi @ Gaurav and @ Susmita,

Thank you for your response.

But My requirement is not for BDC call transaction error records, its for BDC session method. The errors are inside log file of SM35 transaction code. So I want to fetch data from the log file and save in database.

Regards,

Ajit

Read only

0 Likes
3,622

H Ajit,

It is better to use CALL TRANSACTION to get the error.

However if you want to get the error from the session log, use this method.

http://wiki.scn.sap.com/wiki/display/ABAP/Get+log+of+batch+input+session

Thanks,

Susmitha

Read only

Former Member
0 Likes
3,622

This message was moderated.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,622

Use the search tool, there are already some sample in wiki section of the site with reports that extract session log.

Regards,

Raymond

Read only

Former Member
Read only

Former Member
0 Likes
3,622

Thanks to all for your response...

Regards,

Ajit