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

Creating log files

Former Member
0 Likes
457

Hi

I want the success and error messages returned by bapi to be recorded and viewed as a log file.Can anyone help me on this.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
414

HI Jayanth,

Please populate a internal table with the log entries, write a small program to write to the list using ALV if you like or download to the application server.

Regards,

George

2 REPLIES 2
Read only

Former Member
0 Likes
415

HI Jayanth,

Please populate a internal table with the log entries, write a small program to write to the list using ALV if you like or download to the application server.

Regards,

George

Read only

Former Member
0 Likes
414

Hello Jeyanth,

U can do like this


        DATA: G_S_LOG TYPE BAL_S_LOG,
              G_LOG_HANDLE TYPE BALLOGHNDL,
              G_DUMMY TYPE C.
        DATA: L_S_MSG TYPE BAL_S_MSG,
              LOGNUMBER TYPE BAL_T_LGNM,
              WA_LOGNUMBER LIKE BAL_S_LGNM,
              LT_BALLOGHNDL TYPE BAL_T_LOGH. "Log handle internal table
        DATA: LV_EXT LIKE G_S_LOG-EXTNUMBER.
* Define header data of this log
        CONCATENATE LT_EKPO-EBELN '/' LT_EKPO-EBELP SY-MSGID SY-MSGNO
        SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
        INTO LV_EXT SEPARATED BY SPACE.
        G_S_LOG-EXTNUMBER = LV_EXT.
        G_S_LOG-OBJECT = 'Z48MMIGO'.
        G_S_LOG-SUBOBJECT = 'ZKB11N'.
        G_S_LOG-ALDATE = SY-DATUM.
        G_S_LOG-ALTIME = SY-UZEIT.
        G_S_LOG-ALUSER = SY-UNAME.
        G_S_LOG-ALPROG = SY-REPID.
* Create a log
        CALL FUNCTION 'BAL_LOG_CREATE'
             EXPORTING
                  I_S_LOG      = G_S_LOG
             IMPORTING
                  E_LOG_HANDLE = G_LOG_HANDLE
             EXCEPTIONS
                  OTHERS       = 1.
        IF SY-SUBRC NE 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.

        CALL FUNCTION 'BAL_DB_SAVE'
             EXPORTING
                  I_CLIENT         = SY-MANDT
                  I_SAVE_ALL       = 'X'
                  I_T_LOG_HANDLE   = LT_BALLOGHNDL
             IMPORTING
                  E_NEW_LOGNUMBERS = LOGNUMBER
             EXCEPTIONS
                  LOG_NOT_FOUND    = 1
                  SAVE_NOT_ALLOWED = 2
                  NUMBERING_ERROR  = 3
                  OTHERS           = 4.

      ENDIF.
    ENDIF.

BUt for this u need to create a OBJECT & SUBOBJECT

If useful reward.

Vasanth