SAP FS-PM: Schedule BTS generically
One might have encountered scenarios where the requirement is to schedule BTS generically within a program. It is good to have a single method that does this irrespective of the business transaction (BTX). Obviously, the next question would be, how to achieve that?
Before deciding the algorithm, let us first consider the input required to schedule the BTX. The following would be the least needed information:
- Business Transaction ID
- For example P_B_S_XRF_AMD for BTX Change External Reference
- Policy Number
- Policy number on which the BTS needs to be scheduled
- Effective Date
- Date on which BTS needs to be scheduled
- Relevant entities affected and its input data passed using DA entity
- Let us consider the example of BTX Change External Reference (P_B_S_XRF_AMD). As per the SE43 developer customizing for BTX P_B_S_XRF_AMD, it requires entity /PM0/ABDAEXREF and the input fields for this entity are Reference Company (REFCOM_CD), Reference Number (REFNUMBER_TT), Reference Type (REFTYP_CD), and Template ID (PM_ID). Hence, the four field names and its field values have to be passed using the structure /PM0/ABDAEXREF.
- BTX Execution Key (Policy ID, Policy Product ID etc.)
The following are the major steps to of the algorithm:
- Initialize the registry
- This is the obvious step where one needs to initialize the registry, get the instance of service data composite container etc.
- Transform the DA entity data to name value pairs
- One receives the data in input (4) in the form of DA entity (in our example it is of structure type /PM0/ABDAEXREF).
- This has to be converted to internal table of name value pairs.
- Set the data container
- This is the most critical part. The challenge here is to perform this in a generic way. Let us take an example of BTX Change External Reference (P_B_S_XRF_AMD).
- In this case to set the data container values for BTX P_B_S_XRF_AMD, one needs to call the following method (where LR_DCC is of type Component Controller Class /PM0/CL_DC_SVC_XREF_CC): lr_dcc->/pm0/if_abp_btx_dc_xref~set_exref(
it_add_exref = lt_add_exref
it_add_fm_exref = lt_add_fm_exref ).
- To make the above code snippet generic, it will have to look like the following: CALL METHOD lr_dcc->(lv_methodname)
- The composite container class name can be retrieved in SE43 customizing.
- The LV_METHODNAME has two parts: Interface Name and Method Name. The interface name can be again retrieved in the SE43 customizing as shown below. And then the method name is nothing but the list of methods of the interface. The LR_DCC-> (LV_METHODNAME) will have to be called for every method in the interface.
- The parameter table can be generically filled by following the rule: IT_ADD_<ENTITY_NAME>, IT_MOD_<ENTITY_NAME>. Here, <ENTITY_NAME> can be derived from entity name /PM0/ABDAEXREF (highlighted in red).
- Save BTS Date
- This will save the BTS date using the method /PM0/CL_ABP_BC_BTSDATE_BASE->/PM0/IF_ABP_BC_BTSDATE_SRVC~PLAN_BTSDATE_BTX.
- Update Job
- This will persist the job data in the job table /PM0/ABDUPPJOB, using the method /PM0/CL_ABP_BC_BTSJOB_TOOL=>CREATE_JOB4BTS or /PM0/CL_ABP_BC_BTSJOB_TOOL=>UPDATE_JOB4BTS.
- Commit Data
- This will commit changes to the data container, BTS and Job.