Skip to Content
0

No log is created in transaction SLG1

Jan 27, 2017 at 07:38 PM

52

avatar image

I am trying to create a log from a thirdparty webservice, that service call my program inside through submit. Example: My Program is executed like this:

 submit ZSD_MOTORPEDIDOS_LPUSH
                    With p_idgg Eq 1
                    With lv_port Eq 3002
                      And Return.

Inside a have method that build the logs.

Here i post the method code:

DATA: ls_log          TYPE bal_s_log.
DATA: lv_log_handle   TYPE balloghndl.
DATA: lt_log_handle   TYPE bal_t_logh,
      lt_log_num      TYPE bal_t_lgnm.
*DATA: lt_msg          TYPE STANDARD TABLE OF bal_s_msg.
DATA: ls_msg          LIKE LINE OF log_msg.

ls_log-object    = object.
ls_log-subobject = subobject.
ls_log-aldate    = sy-datlo.
ls_log-altime    = sy-timlo.
ls_log-aluser    = sy-uname.
ls_log-almode    = sy-batch.
ls_log-alprog = sy-cprog.
ls_log-del_before = 'X'.
ls_log-aldate_del = sy-datlo + 3.

CALL FUNCTION 'BAL_LOG_CREATE'
  EXPORTING
    i_s_log                 = ls_log
  IMPORTING
    e_log_handle            = lv_log_handle
  EXCEPTIONS
    log_header_inconsistent = 1
    OTHERS                  = 2.
 IF sy-subrc <> 0.
*    RAISE EXCEPTION TYPE zcx_idoc_app_log_error.

ELSE.
  LOOP AT log_msg INTO ls_msg.

    CALL FUNCTION 'BAL_LOG_MSG_ADD'
      EXPORTING
        i_log_handle              = lv_log_handle
        i_s_msg                   = ls_msg
*    IMPORTING
*      E_S_MSG_HANDLE            = E_S_MSG_HANDLE
*      E_MSG_WAS_LOGGED          = E_MSG_WAS_LOGGED
*      E_MSG_WAS_DISPLAYED       = E_MSG_WAS_DISPLAYED
     EXCEPTIONS
       log_not_found             = 1
       msg_inconsistent          = 2
       log_is_full               = 3
       OTHERS                    = 4
              .
    IF sy-subrc <> 0.
*      WRITE: / 'Error while adding message to Log'.
    ENDIF.

   CLEAR:ls_msg.
  ENDLOOP.

 INSERT lv_log_handle INTO lt_log_handle INDEX 1.

 CALL FUNCTION 'BAL_DB_SAVE'
    EXPORTING
      i_client         = sy-mandt
      i_save_all       = 'X'
      i_t_log_handle   = lt_log_handle
    IMPORTING
      e_new_lognumbers = lt_log_num
    EXCEPTIONS
      log_not_found    = 1
      save_not_allowed = 2
      numbering_error  = 3
      OTHERS           = 4.
  IF sy-subrc <> 0.
*    WRITE: / 'Error while Saving Log to DB'.
  ELSE.
*    WRITE: / 'Log Generated'.
    COMMIT WORK.
  ENDIF.

ENDIF.

The situation is: When i executed the program as a report, the log is created succesfully and i can see t in slg1.

Any idea.. Regards

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers