ERPClimb logoERPClimb

ABAP · Intermediate · Configuration

How to configure and use SAP ABAP application logs with SLG0 and SLG1

Define an application log object and subobject, write structured messages to one isolated log and verify persistence and retrieval with SLG1.

APPLICABILITY
SAP ECC and S/4HANA on-premise or Cloud Private Edition with classic Business Application Log function modules. ABAP Cloud uses released logging APIs instead; this example is not an ABAP Cloud code sample.
TOOLS / TRANSACTIONS
SLG0 · SE91 · SE37 · ADT or SE38 · SLG1 · BAL_LOG_CREATE · BAL_LOG_MSG_ADD · BAL_DB_SAVE

Your project assignment

A hypothetical interface checks inbound records in a sandbox. One synthetic record is rejected and a second passes validation. The report must write a structured application log with an external correlation ID so support can retrieve both messages later without exposing the inbound payload.

Where to start: URLs and transactions

Configuration
SLG0
Development
ADT or SE38, SE91, SE37
Support display
SLG1

Prerequisites

  • An approved ABAP development package and transport.
  • Authorization to maintain application log definitions and display the dedicated test log.
  • A test report and message class containing non-sensitive sample messages.

Configuration workflow

ABAP application logging lifecycle

All steps visible. Play or advance one stage at a time.

ABAP application logging lifecycleSLG0 definition: Object and subobject → BAL_LOG_CREATE: Return log handle → BAL_LOG_MSG_ADD: Structured success and error → BAL_DB_SAVE: Persist selected handle → SLG1: Retrieve after owning LUW commits. If it works: Log found, Both messages and correlation ID. If it fails: Log missing, Check save, commit and filters1SLG0 definitionObject and subobject2BAL_LOG_CREATEReturn log handle3BAL_LOG_MSG_ADDStructured success and error4BAL_DB_SAVEPersist selected handle5SLG1Retrieve after owning LUW commitsWORKSLog foundBoth messages andcorrelation IDFAILSLog missingCheck save, commit andfilters
The application owns the transaction boundary; log persistence is not a reason to commit inside an enhancement. ERPClimb original instructional diagram · not a live SAP screenshot.

Hands-on implementation — step by step

Follow the screen navigation, replace example values with approved project values, and mark each step after checking its result. The screens below are original teaching aids, not live SAP screenshots. Progress is local to this visit.

0/6 completed
  1. 1

    SLG0 → define log object

    Create or review the dedicated customer-namespace application log object and a meaningful subobject. Save the definitions under the approved transport process.

    SLG0 → define log objectERPClimb · illustrative screen
    Object
    ZTRAIN_IF (hypothetical)
    Subobject
    VALIDATE (hypothetical)

    Expected result: The application log object and subobject are available.

    Why this matters: Persistent logs need a valid classification so support can filter and manage them.

  2. 2

    SE91 → define messages

    Create a small test message class with meaningful parameterized success and error messages. Use record identifiers rather than full business payloads.

    SE91 → define messagesERPClimb · illustrative screen
    Message class
    ZTRAIN_LOG
    Messages
    001: Record &1 passed; 002: Record &1 rejected

    Expected result: The message class is active with approved non-sensitive texts.

    Why this matters: Structured T100 messages preserve type and parameters for later analysis.

  3. 3

    ABAP → create log header

    Populate BAL_S_LOG with object, subobject and an external correlation ID, then call BAL_LOG_CREATE and retain E_LOG_HANDLE. Handle exceptions before adding messages.

    ABAP → create log headerERPClimb · illustrative screen
    Header fields
    OBJECT, SUBOBJECT, EXTNUMBER
    External ID
    QA-RUN-001 (hypothetical)
    Function
    BAL_LOG_CREATE

    Expected result: A valid in-memory log handle is returned.

    Why this matters: The handle identifies the log instance within the running application.

  4. 4

    ABAP → append structured messages

    Populate BAL_S_MSG for each synthetic validation result and call BAL_LOG_MSG_ADD with the returned handle. Check exceptions and avoid sensitive values.

    ABAP → append structured messagesERPClimb · illustrative screen
    Message fields
    MSGTY, MSGID, MSGNO, MSGV1
    Function
    BAL_LOG_MSG_ADD
    Types
    S and E for the example

    Expected result: The in-memory log contains both validation outcomes.

    Why this matters: The log's message type describes the result but does not itself roll back business processing.

  5. 5

    ABAP → persist the intended log

    Pass the specific log handle in I_T_LOG_HANDLE to BAL_DB_SAVE. Check the function outcome and let the owning transaction control the commit; only the dedicated standalone test report may commit its own LUW.

    ABAP → persist the intended logERPClimb · illustrative screen
    Function
    BAL_DB_SAVE
    Scope
    Only the current test log handle
    Commit
    Owned by the standalone test transaction

    Expected result: The log is saved when the intended transaction successfully commits.

    Why this matters: Saving every in-memory log or committing inside an enhancement can interfere with unrelated business work.

  6. 6

    SLG1 → retrieve and diagnose

    Start a separate session and filter by object, subobject, external ID and time interval. Inspect both message types, then verify that the intended support role can read the log.

    SLG1 → retrieve and diagnoseERPClimb · illustrative screen
    Object / subobject
    ZTRAIN_IF / VALIDATE
    External ID
    QA-RUN-001
    Expected
    One success and one error

    Expected result: Both messages appear in the persisted log under the intended correlation ID.

    Why this matters: A separate session proves database persistence rather than merely an in-memory display.

Project acceptance checklist

Use this checklist to prepare evidence for your project lead.

0 of 4 checks marked. This does not certify the SAP configuration.

Validate your configuration

  • SLG1 retrieves the specific committed log from a separate session.
  • The log contains the expected message types and correlation ID without sensitive data.

Common errors and what to check

  • log missing in SLG1.

    Check: Check object/subobject, time filter, save result and transaction commit.

  • no message displayed.

    Check: Check returned handle and message-add exceptions.

  • unrelated logs saved.

    Check: Pass only the intended handle rather than save-all behavior.

  • authorization denied.

    Check: Review the appropriate application-log display permissions with Security.

ABAP application log lifecycle: define object in SLG0, create and save selected log with BAL APIs, and retrieve correlation ID in SLG1 after commit. If missing, check save outcome, transaction ownership and filters.
ABAP application log lifecycle: define object in SLG0, create and save selected log with BAL APIs, and retrieve correlation ID in SLG1 after commit. If missing, check save outcome, transaction ownership and filters. ERPClimb original illustration.

More in the SAP Library

Need help with a configuration error? Open ERPClimb Copilot.

Technical references & further reading