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 capture errors which is generated in SLG1 tcode.

former_member421418
Participant
0 Likes
1,706

Hi experts,

I am implementig  one interface program , concept of program is it will read file from application server and post in FB01 tcode for GL postings.

it will  run in background Here i need to capture log number which is generated in slg1 for this program. and  i have to give the messege format also in this slg1 transaction.

For example : 100000 document is posted in FB01.

i should show the messege in slg1 for this document like/.

Creation date|username|posted document no|staus.

04.16.2012|xyz|100000|document posted successfully.------>i should display messege like this.

I am new to SLG1 transaction can any one help me how to do the above requirement.

Thanks & REgards

Kiran.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
997

Hi,

For creating and displaying the LOG in SLG1 transaction you need to call three Function Modules as given below:

***Open Log

  CALL FUNCTION 'BAL_LOG_CREATE'

    EXPORTING

      i_s_log                 = ls_log

    IMPORTING

      e_log_handle            = ls_log_handle

    EXCEPTIONS

      log_header_inconsistent = 1

      OTHERS                  = 2.

***Create message

    ls_msg-msgty = lc_type.      "Message type

    ls_msg-msgid = lc_msgid.    "Message ID

    ls_msg-msgno = lc_msgno.  "Message number

    ls_msg-msgv1 = lv_message1.

    ls_msg-msgv2 = lv_message2.

    ls_msg-msgv3 = lv_message3.

    ls_msg-msgv4 = lv_message4.

    ls_msg-probclass = 2.

Note: You can pass the texts to ls_msg-msgv1,ls_msg-msgv2,ls_msg-msgv3,ls_msg-msgv4 the way you want your log to be displayed.For example in your case:

ls_msg-msgv1 = sy-datum.

ls_msg-msgv2 = sy-uname.

ls_msg-msgv3 = document number.

ls_msg-msgv4 = success message.

Then,

CALL FUNCTION 'BAL_LOG_MSG_ADD'

      EXPORTING

       i_log_handle              = ls_log_handle

        i_s_msg                   = ls_msg

* IMPORTING

*   E_S_MSG_HANDLE            =

*   E_MSG_WAS_LOGGED          =

*   E_MSG_WAS_DISPLAYED       =

     EXCEPTIONS

       log_not_found             = 1

       msg_inconsistent          = 2

       log_is_full               = 3

       OTHERS                    = 4.

    IF sy-subrc NE 0.

      "Do nothing

    ENDIF.

INSERT ls_log_handle INTO TABLE li_log_handle.

***Save message
    CALL FUNCTION 'BAL_DB_SAVE'
     EXPORTING
       i_client               = sy-mandt
*   I_IN_UPDATE_TASK       = ' '
       i_save_all             = 'X'
       i_t_log_handle         = li_log_handle
* IMPORTING
*   E_NEW_LOGNUMBERS       =
     EXCEPTIONS
       log_not_found          = 1
       save_not_allowed       = 2
       numbering_error        = 3
       OTHERS                 = 4.
    IF sy-subrc EQ 0.
      REFRESH: li_log_handle.
    ENDIF.

Hope it serves useful to you.

1 REPLY 1
Read only

Former Member
0 Likes
998

Hi,

For creating and displaying the LOG in SLG1 transaction you need to call three Function Modules as given below:

***Open Log

  CALL FUNCTION 'BAL_LOG_CREATE'

    EXPORTING

      i_s_log                 = ls_log

    IMPORTING

      e_log_handle            = ls_log_handle

    EXCEPTIONS

      log_header_inconsistent = 1

      OTHERS                  = 2.

***Create message

    ls_msg-msgty = lc_type.      "Message type

    ls_msg-msgid = lc_msgid.    "Message ID

    ls_msg-msgno = lc_msgno.  "Message number

    ls_msg-msgv1 = lv_message1.

    ls_msg-msgv2 = lv_message2.

    ls_msg-msgv3 = lv_message3.

    ls_msg-msgv4 = lv_message4.

    ls_msg-probclass = 2.

Note: You can pass the texts to ls_msg-msgv1,ls_msg-msgv2,ls_msg-msgv3,ls_msg-msgv4 the way you want your log to be displayed.For example in your case:

ls_msg-msgv1 = sy-datum.

ls_msg-msgv2 = sy-uname.

ls_msg-msgv3 = document number.

ls_msg-msgv4 = success message.

Then,

CALL FUNCTION 'BAL_LOG_MSG_ADD'

      EXPORTING

       i_log_handle              = ls_log_handle

        i_s_msg                   = ls_msg

* IMPORTING

*   E_S_MSG_HANDLE            =

*   E_MSG_WAS_LOGGED          =

*   E_MSG_WAS_DISPLAYED       =

     EXCEPTIONS

       log_not_found             = 1

       msg_inconsistent          = 2

       log_is_full               = 3

       OTHERS                    = 4.

    IF sy-subrc NE 0.

      "Do nothing

    ENDIF.

INSERT ls_log_handle INTO TABLE li_log_handle.

***Save message
    CALL FUNCTION 'BAL_DB_SAVE'
     EXPORTING
       i_client               = sy-mandt
*   I_IN_UPDATE_TASK       = ' '
       i_save_all             = 'X'
       i_t_log_handle         = li_log_handle
* IMPORTING
*   E_NEW_LOGNUMBERS       =
     EXCEPTIONS
       log_not_found          = 1
       save_not_allowed       = 2
       numbering_error        = 3
       OTHERS                 = 4.
    IF sy-subrc EQ 0.
      REFRESH: li_log_handle.
    ENDIF.

Hope it serves useful to you.