Is there a way to search the application log (SLG1) for a particular message?

77 Views Asked by At

Is there a function module (or any other way) that searches the SLG1 application log for a particular message? I.e. the inputs are the message class and ID and maybe a date range.

1

There are 1 best solutions below

2
Xavier Salomone On

Yes, search for BAL_* functions. In general you might need this sequence of functions:

  • search on DB for these logs

    CALL FUNCTION 'BAL_DB_SEARCH'
      EXPORTING
        i_s_log_filter = g_s_log_filter    "here are the selection filters
      IMPORTING
        e_t_log_header = g_t_log_header
      EXCEPTIONS
        OTHERS         = 0.
    
  • load logs from DB

    CALL FUNCTION 'BAL_DB_LOAD'
      EXPORTING
        i_t_log_header = g_t_log_header
      IMPORTING
        e_t_log_handle = g_t_log_handle
        e_t_msg_handle = g_t_msg_handle
      EXCEPTIONS
        OTHERS         = 0.
    
  • display logs: get variant which creates hierarchy according to field DETLEVEL

    CALL FUNCTION 'BAL_DSP_PROFILE_DETLEVEL_GET'
      IMPORTING
        e_s_display_profile = g_s_display_profile
      EXCEPTIONS
        OTHERS              = 1.
    
  • create a display profile

  • use grid for display if wanted

    g_s_display_profile-use_grid = p_grid.
    
  • define up to which level the tree should be expanded

    g_s_display_profile-exp_level = 1.
    
  • set title of dynpro

    g_s_display_profile-title     = TEXT-004.
    g_s_display_profile-head_text = g_s_display_profile-title.
    
  • set report to allow saving of variants

    g_s_display_profile-disvariant-report = sy-repid.
    
  • when you use also other ALV lists in your report,please specify a handle to distinguish between the display variants of these different lists, e.g:

    g_s_display_profile-disvariant-handle = 'LOG'.
    
  • call display function module: We do not specify any filter (like S_LOG_FILTER, ...,T_MSG_HANDLE) since we want to display all logs available

    CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
      EXPORTING
        i_s_display_profile = g_s_display_profile
        i_t_log_handle      = g_t_log_handle
        i_t_msg_handle      = g_t_msg_handle
      EXCEPTIONS
        OTHERS              = 1.