2010 Feb 25 10:08 AM
Hi Experts,
In my object, i am working an inbound interface. Using proxy, i am getting the data . After getting the data, i have to call one function module . it will upload the data for VK11,vk12 and fv50 based on the condition type .
if if it is error data, i want to store the data in table BALDAT & BALHDR . using the t code SLG1, they will check the log file.
I dont know how to pass the data to this table. somebody said that u have to activate the application log for vk11, vk12 and fv50. can anyone explain clearly ?
Thanks & Regards,
Varadarajan.R
2010 Feb 25 10:15 AM
Hello VARADARAJAN R ,
Carry out the following steps,
1. Create your object and sub Object in SLG0
2. Using the below function module Create Log handler add messeges to log and then write the LOG to data base
The function modules are as follows
1. BAL_LOG_CREATE (creates a log handle and returns it in program )
2.BAL_LOG_MSG_ADD ( addes message to LOG passing parameter will be the log hadle you have created you can add as many as possible....)
3.BAL_DB_SAVE ( will save your log to data base...!)
( You can have your own messge class for the messages go to SE91 and create and use them in your program add them to log...)
4. Do commit work
Check in SLG1 for your log...!
HOPE it helps...
2010 Feb 25 10:16 AM
sample code...!
REPORT ZTEST_ERROR_LOG.
data: temp1 type werks.
DATA: gv_log_handle TYPE balloghndl. "Application Log: Log Handle
data : MSG TYPE BAL_S_MSG.
DATA : LOG TYPE BAL_S_LOG.
DATA: LOG_HANDLE TYPE BALLOGHNDL.
data: log_handle_table TYPE BAL_T_LOGH.
data: log_header_table type BALHDR_T.
data : Error_log_number TYPE BALNREXT.
*MESSAGE e000(zmymsg) WITH '111' 'adf' sy-datum sy-uzeit DISPLAY LIKE 'I'.
BREAK-POINT.
CONCATENATE '000' sy-datum sy-uzeit INTO error_log_number SEPARATED BY space.
move :
error_log_number to log-EXTNUMBER,
'ZMAT_INTR' to log-OBJECT,
'ZERRLOG' to log-SUBOBJECT,
sy-cdate to log-ALDATE,
sy-uzeit to log-ALTIME,
sy-uname to log-ALUSER,
*log-ALTCODE
sy-repid to log-ALPROG,
'B' to log-ALMODE.
*log-ALCHDATE
*log-ALCHTIME
*log-ALCHUSER
*log-ALDATE_DEL
*log-DEL_BEFORE
*log-ALSTATE
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
I_S_LOG = LOG
IMPORTING
E_LOG_HANDLE = LOG_HANDLE
EXCEPTIONS
LOG_HEADER_INCONSISTENT = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE: 'I' TO MSG-MSGTY,
'ZMYMSG' TO MSG-MSGID,
'000' TO MSG-MSGNO,
'111' TO MSG-MSGV1 ,
'ADF' TO MSG-MSGV2,
SY-DATUM TO MSG-MSGV3,
SY-UZEIT TO MSG-MSGV4.
*MSGV4
*MSGV1_SRC
*MSGV2_SRC
*MSGV3_SRC
*MSGV4_SRC
*DETLEVEL
*PROBCLASS
*ALSORT
*TIME_STMP
*MSG_COUNT
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
I_LOG_HANDLE = LOG_HANDLE
I_S_MSG = MSG
* IMPORTING
* E_S_MSG_HANDLE =
* E_MSG_WAS_LOGGED =
* E_MSG_WAS_DISPLAYED =
EXCEPTIONS
LOG_NOT_FOUND = 1
MSG_INCONSISTENT = 2
LOG_IS_FULL = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE: 'I' TO MSG-MSGTY,
'ZMYMSG' TO MSG-MSGID,
'001' TO MSG-MSGNO,
'999' TO MSG-MSGV1 ,
'aaa' TO MSG-MSGV2,
SY-DATUM TO MSG-MSGV3,
SY-UZEIT TO MSG-MSGV4.
*MSGV4
*MSGV1_SRC
*MSGV2_SRC
*MSGV3_SRC
*MSGV4_SRC
*DETLEVEL
*PROBCLASS
*ALSORT
*TIME_STMP
*MSG_COUNT
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
I_LOG_HANDLE = LOG_HANDLE
I_S_MSG = MSG
* IMPORTING
* E_S_MSG_HANDLE =
* E_MSG_WAS_LOGGED =
* E_MSG_WAS_DISPLAYED =
EXCEPTIONS
LOG_NOT_FOUND = 1
MSG_INCONSISTENT = 2
LOG_IS_FULL = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE: 'W' TO MSG-MSGTY,
'ZMYMSG' TO MSG-MSGID,
'001' TO MSG-MSGNO,
'999' TO MSG-MSGV1 ,
'aaa' TO MSG-MSGV2,
SY-DATUM TO MSG-MSGV3,
SY-UZEIT TO MSG-MSGV4.
*MSGV4
*MSGV1_SRC
*MSGV2_SRC
*MSGV3_SRC
*MSGV4_SRC
*DETLEVEL
*PROBCLASS
*ALSORT
*TIME_STMP
*MSG_COUNT
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
I_LOG_HANDLE = LOG_HANDLE
I_S_MSG = MSG
* IMPORTING
* E_S_MSG_HANDLE =
* E_MSG_WAS_LOGGED =
* E_MSG_WAS_DISPLAYED =
EXCEPTIONS
LOG_NOT_FOUND = 1
MSG_INCONSISTENT = 2
LOG_IS_FULL = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE: 'E' TO MSG-MSGTY,
'ZMYMSG' TO MSG-MSGID,
'001' TO MSG-MSGNO,
'999' TO MSG-MSGV1 ,
'aaa' TO MSG-MSGV2,
SY-DATUM TO MSG-MSGV3,
SY-UZEIT TO MSG-MSGV4.
*MSGV4
*MSGV1_SRC
*MSGV2_SRC
*MSGV3_SRC
*MSGV4_SRC
*DETLEVEL
*PROBCLASS
*ALSORT
*TIME_STMP
*MSG_COUNT
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
I_LOG_HANDLE = LOG_HANDLE
I_S_MSG = MSG
* IMPORTING
* E_S_MSG_HANDLE =
* E_MSG_WAS_LOGGED =
* E_MSG_WAS_DISPLAYED =
EXCEPTIONS
LOG_NOT_FOUND = 1
MSG_INCONSISTENT = 2
LOG_IS_FULL = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE: 'I' TO MSG-MSGTY,
'ZMYMSG' TO MSG-MSGID,
'001' TO MSG-MSGNO,
'999' TO MSG-MSGV1 ,
'aaa' TO MSG-MSGV2,
SY-DATUM TO MSG-MSGV3,
SY-UZEIT TO MSG-MSGV4.
*MSGV4
*MSGV1_SRC
*MSGV2_SRC
*MSGV3_SRC
*MSGV4_SRC
*DETLEVEL
*PROBCLASS
*ALSORT
*TIME_STMP
*MSG_COUNT
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
I_LOG_HANDLE = LOG_HANDLE
I_S_MSG = MSG
* IMPORTING
* E_S_MSG_HANDLE =
* E_MSG_WAS_LOGGED =
* E_MSG_WAS_DISPLAYED =
EXCEPTIONS
LOG_NOT_FOUND = 1
MSG_INCONSISTENT = 2
LOG_IS_FULL = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
APPEND log_handle to log_handle_table.
*APPEND log to log_header_table.
*CALL FUNCTION 'BAL_DB_SAVE_PREPARE'
* EXPORTING
* I_REPLACE_IN_ALL_LOGS = ' '
** I_T_REPLACE_IN_THESE_LOGS =
** I_T_REPLACE_MESSAGE_VARIABLES =
** I_T_REPLACE_CONTEXT_FIELDS =
** EXCEPTIONS
** LOG_NOT_FOUND = 1
** OTHERS = 2
* .
**IF SY-SUBRC <> 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_IN_UPDATE_TASK = 'X'
* I_SAVE_ALL = ' '
I_T_LOG_HANDLE = log_handle_table
* IMPORTING
* E_NEW_LOGNUMBERS =
* EXCEPTIONS
* LOG_NOT_FOUND = 1
* SAVE_NOT_ALLOWED = 2
* NUMBERING_ERROR = 3
* OTHERS = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
commit WORK.
BREAK-POINT.
2010 Feb 25 11:17 AM
Hi,
in SE38 look up the programs SBAL_DEMO* . You can see how the log is created, updated, deleted, etc.
They are in SZAL package.