Application Log Creation


The following main transactions are used for application log: 

  • SLG0 : To create log ‘Object’ and ‘Sub Object’
  • SLG1  : To display the application log entries
  • SLG2  : To delete the application log entries
Creating Object and Sub Object:

 1.Go to T-code 'SLG0'.

2.Click on 'New Entries'.

3.Enter Object Name and Object text.

 

4.click on save.

5.select the object and click on 'Sub objects'.

6.Enter 'Sub object' and 'Sub Object Text'.

 

7.click on 'Save. 

 Create Message Class:T-Code SE91

 

 To create & Display the Application Log mostly 4 Function Modules are used

1. BAL_LOG_CREATE - Pass the Object and Subobject name for which message log is to be created.

2.BAL_LOG_MSG_ADD - Pass the message that needs to be shown. It just adds the messge to the memory not to the database table.

3.BAL_DB_SAVE - Saves the message to the database table BALHDR.

4.BAL_DSP_LOG_DISPLAY - Used to display the stored application log from the table on the UI.

 

Create ABAP program to populate the Application Log: *&---------------------------------------------------------------------*
*& Report ZVB_APPL_LOG
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zvb_appl_log.

TABLES:zap_emp.

DATA:lw_emp TYPE zap_emp.

DATA:ls_log TYPE bal_s_log,
     ls_hnd TYPE balloghndl,
     ls_msg TYPE bal_s_msg,
     lt_hnd TYPE bal_t_logh,
     lt_new TYPE bal_t_lgnm.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
  PARAMETERS:p_id   TYPE zap_emp-id,
             p_name TYPE zap_emp-name,
             p_desg TYPE zap_emp-desig,
             p_doj  TYPE zap_emp-doj,
             p_dept TYPE zap_emp-dept,
             p_sal  TYPE zap_emp-salary.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
  ls_log-object 'ZOBJ_EMP'.
  ls_log-subobject 'ZSOBJ_INS'.

  CALL FUNCTION 'BAL_LOG_CREATE'
    EXPORTING
      i_s_log                 ls_log
    IMPORTING
      e_log_handle            ls_hnd
    EXCEPTIONS
      log_header_inconsistent 1
      OTHERS                  2.

  lw_emp-id p_id.
  lw_emp-name p_name.
  lw_emp-desig p_desg.
  lw_emp-doj p_doj.
  lw_emp-dept p_dept.
  lw_emp-salary p_sal.

  INSERT INTO zap_emp VALUES lw_emp.
  IF sy-subrc 0.
    ls_msg-msgty 'S'.
    ls_msg-msgid 'ZMSG_CLS'.
    ls_msg-msgno  '000'.
    ls_msg-msgv1 lw_emp-id.
  ELSE.
    ls_msg-msgty 'E'.
    ls_msg-msgid 'ZMSG_CLS'.
    ls_msg-msgno  '001'.
    ls_msg-msgv1 lw_emp-id.
  ENDIF.

  CALL FUNCTION 'BAL_LOG_MSG_ADD'
    EXPORTING
      i_log_handle     ls_hnd
      i_s_msg          ls_msg
    EXCEPTIONS
      log_not_found    1
      msg_inconsistent 2
      log_is_full      3
      OTHERS           4.

  APPEND ls_hnd TO lt_hnd.

  CALL FUNCTION 'BAL_DB_SAVE'
    EXPORTING
      i_client         sy-mandt
      i_t_log_handle   lt_hnd
    IMPORTING
      e_new_lognumbers lt_new.

  IF sy-subrc 0.
    CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
      EXPORTING
        i_t_log_handle lt_hnd.
  ENDIF.
 

Input Screen:


 

 

We can analyze the Application Log through T-code SLG1 by giving the Object and sub object names. 

Delete Objects through T-code SLG2 by by giving the Object and sub object names. 

 

 

 


 

Comments

Popular posts from this blog

CDS Views: Table Functions with Example

Passing Dynamic Variables to SO10 TEXT

Adobe Form/PDF Form Introduction