Method : IF_RSPLS_LOGGING_ON_SAVE~LOG_DEFINED
method IF_RSPLS_LOGGING_ON_SAVE~LOG_DEFINED.
Check i_infocube_name = '<REAL_TIME_CUBE_NAME>' .
check sy-uname = '<USERID>' . // use your user id only during development,
**Comment user id restriction later once you are done.
r_log_defined = rs_c_true.
endmethod.
Method : IF_RSPLS_LOGGING_ON_SAVE~LOG_STRUCTURE
method IF_RSPLS_LOGGING_ON_SAVE~LOG_STRUCTURE.
data: l_s_map like LINE OF e_t_map,
l_s_map_proposal type IF_RSPLS_LOGGING_ON_SAVE=>TN_S_MAP_PROPOSAL.
data: l_dsonm type rsdodsobject,
l_t_iobj TYPE STANDARD TABLE OF BAPI6116IO,
l_s_iobj like line of l_t_iobj,
l_struc_name type TABNAME,
l_s_details type BAPI6108,
l_s_return type BAPIRET2.
** Here we need to update our InfoObject names which would be used for
logging
constants:
c_iobjnm_user type RSIOBJNM value 'ZUSERNM',
c_iobjnm_time type RSIOBJNM value '0TIME',
c_iobjnm_date type RSIOBJNM value '0DATE',
c_iobjnm_saveid type RSIOBJNM value 'ZSAVEID'.
** Plan Cube and Audit DSO Information.
case i_infocube_name.
when '<REAL_TIME_CUBE>'.
l_dsonm = '<DSO_NAME>'.
endcase.
** get the name of the structure for the DataStore object
CALL METHOD CL_RSD_ODSO=>GET_TABLNM
EXPORTING
I_ODSOBJECT = l_dsonm
IMPORTING
E_TABLNM = l_struc_name
EXCEPTIONS
NAME_ERROR = 1
INPUT_INVALID = 2
others = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
e_structure_name = l_struc_name.
clear e_t_map.
* get the structure from the dso
* get the list of info objects in the DataStore object
CALL FUNCTION 'BAPI_ODSO_GETDETAIL'
EXPORTING
OBJVERS = RS_C_OBJVERS-ACTIVE
ODSOBJECT = l_dsonm
TABLES
INFOOBJECTS = l_t_iobj.
* * we do not need the record mode (usually 0RECORDMODE)...
delete l_t_iobj where iobjtp = 'DPA'.
* also name, date, time, saveid, and requid come from the proposal
delete l_t_iobj where infoobject = c_iobjnm_user.
delete l_t_iobj where infoobject = c_iobjnm_date.
delete l_t_iobj where infoobject = c_iobjnm_time.
delete l_t_iobj where infoobject = c_iobjnm_saveid.
loop at l_t_iobj into l_s_iobj.
l_s_map-iobj_name = l_s_iobj-infoobject.
* get the field name in the dso structure
CALL FUNCTION 'BAPI_IOBJ_GETDETAIL'
EXPORTING
VERSION = RS_C_OBJVERS-ACTIVE
INFOOBJECT = l_s_iobj-infoobject
IMPORTING
DETAILS = l_s_details
RETURN = l_s_return.
if l_s_return is initial.
l_s_map-field_name = l_s_details-fieldnm.
append l_s_map to e_t_map.
endif.
endloop.
* get the user name
read table i_t_map_proposal into l_s_map_proposal
with key field_type = IF_RSPLS_LOGGING_ON_SAVE=>N_C_FIELD_TYPE-user.
if sy-subrc is initial.
l_s_map-iobj_name = l_s_map_proposal-iobj_name.
CALL FUNCTION 'BAPI_IOBJ_GETDETAIL'
EXPORTING
VERSION = RS_C_OBJVERS-ACTIVE
INFOOBJECT = c_iobjnm_user
IMPORTING
DETAILS = l_s_details
RETURN = l_s_return.
if l_s_return is initial.
l_s_map-field_name = l_s_details-fieldnm.
append l_s_map to e_t_map.
endif.
endif.
* get the date
read table i_t_map_proposal into l_s_map_proposal
with key field_type = IF_RSPLS_LOGGING_ON_SAVE=>N_C_FIELD_TYPE-date.
if sy-subrc is initial.
l_s_map-iobj_name = l_s_map_proposal-iobj_name.
CALL FUNCTION 'BAPI_IOBJ_GETDETAIL'
EXPORTING
VERSION = RS_C_OBJVERS-ACTIVE
INFOOBJECT = c_iobjnm_date
IMPORTING
DETAILS = l_s_details
RETURN = l_s_return.
if l_s_return is initial.
l_s_map-field_name = l_s_details-fieldnm.
append l_s_map to e_t_map.
endif.
endif.
* get the time
read table i_t_map_proposal into l_s_map_proposal
with key field_type = IF_RSPLS_LOGGING_ON_SAVE=>N_C_FIELD_TYPE-time.
if sy-subrc is initial.
l_s_map-iobj_name = l_s_map_proposal-iobj_name.
CALL FUNCTION 'BAPI_IOBJ_GETDETAIL'
EXPORTING
VERSION = RS_C_OBJVERS-ACTIVE
INFOOBJECT = c_iobjnm_time
IMPORTING
DETAILS = l_s_details
RETURN = l_s_return.
if l_s_return is initial.
l_s_map-field_name = l_s_details-fieldnm.
append l_s_map to e_t_map.
endif.
endif.
* get the save id
read table i_t_map_proposal into l_s_map_proposal
with key field_type = IF_RSPLS_LOGGING_ON_SAVE=>N_C_FIELD_TYPE-saveid.
if sy-subrc is initial.
l_s_map-iobj_name = l_s_map_proposal-iobj_name.
CALL FUNCTION 'BAPI_IOBJ_GETDETAIL'
EXPORTING
VERSION = RS_C_OBJVERS-ACTIVE
INFOOBJECT = c_iobjnm_saveid
IMPORTING
DETAILS = l_s_details
RETURN = l_s_return.
if l_s_return is initial.
l_s_map-field_name = l_s_details-fieldnm.
append l_s_map to e_t_map.
endif.
endif.
endmethod.
Method : IF_RSPLS_LOGGING_ON_SAVE~LOG_WRITE
method IF_RSPLS_LOGGING_ON_SAVE~LOG_WRITE.
*the log table has the same structure as the active table of DSO
DATA: l_dsonm type RSDODSOBJECT.
case i_infocube_name.
when '<REAL_TIME_CUBE>'.
l_dsonm = '<DSO_NAME>'.
endcase.
CALL FUNCTION 'RSDRI_ODSO_INSERT'
EXPORTING
I_ODSOBJECT = l_dsonm
I_T_INSERT = i_t_logging_data
* IMPORTING
* E_RECORDS =
EXCEPTIONS
DATA_TARGET_NOT_ODS = 1
ODS_TYPE_NOT_TRANSACTIONAL = 2
ACTIVE_TABLE_NAME_NOT_FOUND = 3
RECORD_KEY_ALREADY_EXISTS = 4
ARRAY_INSERT_FAILED = 5
INTERNAL_ERROR = 6
OTHERS = 7 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE sy-msgty NUMBER SY-MSGNO WITH SY-MSGV1 SY-
MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endmethod.
Method: IF_RSPLS_LOGGING_ON_SAVE~LOG_DEFINED_DB
method IF_RSPLS_LOGGING_ON_SAVE~LOG_DEFINED_DB.
e_log_defined_DB = rs_c_false.
endmethod.
Method : IF_RSPLS_LOGGING_ON_SAVE~LOG_WRITE_DB
method IF_RSPLS_LOGGING_ON_SAVE~LOG_WRITE_DB.
endmethod.