Introduction
In one of my blogs (Integrated Planning – how to activate/deactivate data slice) I described how to activate/deactivate data slice in Integrated Planning using customers Z function module called within FOX formula. This technique usefull only for key user and requres restart of planning application, which not always possible or suitable for planning process.
Goal
This blog describes how to activate/deactivate data slice at RUNTIME of planning function/sequence.
Scenario
Let us consider a scenario where we have records marked as LOCKED or UNLOCKED (with any infoobject) and data slice activated on locked records. At the beginning of planning process user updates data (this data marked as unlocked) and at the end he should lock this data by copying records to locked. The challenge is to make possible copying to locked, because data sclice activated on locked data and planning application will give an error. In this blog I’ll describe a solution that makes possible to deactivate data slice for specific steps in planning sequence.
General schema of implementation
1. Creating class which reads LOCK/UNLOCK command and according to this command our code will activate or deactivate data slice.
2. Creating custom function type in IP based on class.
3. Creating planning function based on our custom type. This function type will send command LOCK/UNLOCK to data slice.
4. Creating planning sequence with the next structure: Execute planning function for manipulation of locked records. -> Activate data slice.
5. Creating data slice based on class in IP Modeler. 
Detailed implementation  
Use TCode  SE24 to define a custom exit class. Set superclass to CL_RSPLS_DS_EXIT_BASE class.
    
Create your own method for implementing locking logic.
Define parameters to the MY_DATASLICE method.
1. I_S_DATA : input data
2. E_T_MESG: messages
3. E_NOINPUT: A Boolean flag. If you want to protect the cell, the set this parameter to X, otherwise leave the parameter blank.   
Example of custom logic: You want to lock all lines that have marked “Locked” by MD of InfoObject Z_LOCK_IND.
In method MY_DATASLICE apply following code:  
DATA: l_msg TYPE if_rspls_cr_types=>tn_s_mesg .  
IF i_s_data = ‘00001’.    
l_msg-msgid = ‘RSPLS_CR’.     l
_msg-msgty = ‘E’.    
l_msg-msgno = ‘019’.    
l_msg-msgv2 = ‘0001’.   
APPEND l_msg TO e_t_mesg.  
e_noinput = rs_c_true.  
i_s_data contains line value of IO Z_LOCK_IND. If line locked (value = 1) message appears and no input allowed (e_noinput = true). Redefine the standard method IF_RSPLS_DS_METHODS~IS_PROTECTED to include buffering and the data slice switch.
Add to this redefined method code in appendix A.Save the class and activate it.   For writing command LOCL/UNLOCK define class ZCL_MAINTAIN_DATASLICE for the switching function. Add the interface IF_RSPLFA_SRVTYPE_IMP_EXEC_REF to this class.
Redefine next methods without adding any code (just redefine and save): IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~INIT_EXECUTION IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~EXECUTE Redefine method IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~GET_REF_DATA_SEL and add code in appendix B. In this method you get the command from planning function (LOCK or UNLOCK) and store ti to SAP memory. This command will be read by IS_PROTECTED method as described above. Save the class and activate it.   Create InfoObject with master data LOCK and UNLOCK values:
Create function type for switching data slice. Use transaction RSPLF.Set the next properties in function type:
Go to the Parameter tab. Right-click the Parameter field to add an elementary parameter called COMMAND passed by InfoObject early created (with LOCK/UNLOCK master data).
Save and activate the function type.   Create planning function of type early created type for unlocking data slice.
In parameter COMMAND select UNLOCK.
This function will deactivate data slice. Planning sequence should have next structure:
1. Deactivate the data slice.
2. Execute your function for manipulating locked records.
3. Activate the data slice (build this function similarly to deactivation function but with LOCK parameter).
Create data slice based on you own class.  Open modeler and navigate to InfoProvider – > Data Slice. Press Cerate and choose in “Data Slice Based On” “for an exit class” parameter.
  
At “Exit Class” choose your early created custom class.
In “Characteristics that are restricted by the exit class” choose your characteristic(s).
Data slice should be active by default.

Save your data slice.

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !