Business Scenario
To monitor performance of the execution of planning functions and sequences in SAP Integrated Planning application, we needed to setup a mechanism to log generic messages with timestamps.
Solution
I created a Planning Function based on a ‘dummy’ Aggregation Level / Real Time Infoprovider that only processes 1 record and does nothing apart from logging a message in the SAP Application Log. This function can then be called within existing sequences to log execution duration of the complete sequence or of individual steps.
Implementation instructions
Creation of Objects and Cubes
- Info Object Char IIP_MSG / CHAR 3 / With MD (no attributes) + Text Short => Maintain at value ‘001’ in Master Data
- Need one KF (ex 0QUANTITY)
- Create Real Time Infocube IIP_LOG=> 1 dimension with Char IIP_MSG, 1 key figure (ex ICOUNT)
Creation of Planning Function Type and logging entries (SLG0)
- Create a Class for logging named Z_IP_LOG_TS by copying the example Planning Function Type class CL_RSPLFA_SRVTYPE_IMP.
- Edit method IF_RSPLFA_SRVTYPE_IMP_EXEC->INIT_EXECUTION
method if_rsplfa_srvtype_imp_exec~init_execution. " Enter a Log in SLG1 for Object ZIIP, SubObject ZIIP " The log message contains the TS + Calling PF name DATA: log_handle TYPE balloghndl, t_log_handle type BAL_T_LOGH, log TYPE bal_s_log, log_msg TYPE bal_s_msg. log-extnumber = 'Infrabel IP Logging'. log-object = 'ZIIP'. log-subobject = 'ZIIP'. log-aldate = sy-datum. log-altime = sy-uzeit. log-aluser = sy-uname. log-alprog = sy-repid. CALL FUNCTION 'BAL_LOG_CREATE' EXPORTING i_s_log = log IMPORTING e_log_handle = log_handle EXCEPTIONS OTHERS = 1. log_msg-msgty = 'I'. log_msg-msgid = 'ZIIP'. log_msg-msgno = '000'. log_msg-msgv1 = sy-msgv1. " set to Planning Function log_msg-msgv2 = sy-msgv2. " set to value of filter log_msg-msgv3 = sy-msgv3. " set to planning sequence if any log_msg-msgv4 = sy-msgv4. " planning function step CALL FUNCTION 'BAL_LOG_MSG_ADD' EXPORTING i_log_handle = log_handle i_s_msg = log_msg EXCEPTIONS log_not_found = 1 msg_inconsistent = 2 log_is_full = 3 OTHERS = 4. append log_handle to t_log_handle. CALL FUNCTION 'BAL_DB_SAVE' EXPORTING I_T_LOG_HANDLE = t_log_handle. endmethod.
- Create in RSPLF1 the Planning Function Type Z_IP_LOG_TS pointing to class Z_IP_LOG_TS / Without Blocks / Hide columns to be changed
- Create the Object ZIIP and Subobject ZIIP on SLG0
Creation of Aggregation Level, Filter and Planning Function
- Create Aggregation Level AG_LOG_01on IIP_LOG => Chars = IIP_MSG , KF = ICOUNT
- Use transaction RSINPUT to create 1 record in Real Time Infocube IIP_LOG
- Create a filter FL_LOG_01 on AG_LOG_01 => Set Char Selection on IIP_MSG = ‘001’
- Create a Planning Function of type Z_IP_LOG_TS on Aggregation Level AG_LOG_01
Using Logging in Planning Sequence
You can insert in your planning sequences a step on Aggregation Level AG_LOG_01, Filter FL_LOG_01 and Planning Function Z_IP_LOG_TS. When the step is called, a message is created in the Application Log (transaction SLG1).