Using ABAP enhancement for copy of process chain
I often copy process chains, for example an existing chain for european data to a new chain with changed infopackages or different source System infopackages for asia.
In BW 7.3 or later systems one option to coyp a chain is to use the wizard. With the wizard you can choose which DTP, InfoPackages should be changed in the copied chain. Here you can also define a new start process. The wizard will create a new start process for the copied chain. If you check and activate the chain, everything is fine.
If you choose “simple copy”, the chain is copied 1:1. All steps are copied to the new chain, also the start process. But each process chain needs to have a unique start process. Check or activation of the new chain will fail in this case. So you delete manually the copied start process in the new chain and insert a new start process.Then you connect it to the other process types as before. If you save and check the process chain, process chain will be green. This blog describes, how you can enhance the method for copying process chain. This enhancement will create a new start process of type ‘TRIGGER’ with technical Name “<technical Name of process chain>_START”.
I investigated how copy of process chain is implemented. Fortunately it is implemented in class ‘CL_RSPC_CHAIN’ in private instance method ‘_copy’.
First create an enhancement of class ‘CL_RSPC_CHAIN’..
Then you put the cursor in the method ‘_copy’ and insert post-method.
Insert following code in the post-exit method:
DATA: l_trigger TYPE rspc_variant,
l_trigger_text TYPE rstxtlg,
ls_chain TYPE rspc_s_chain.
LOOP AT core_object->p_t_chain INTO ls_chain WHERE type = ‘TRIGGER’.
CONCATENATE ls_chain-chain_id ‘_START’ INTO l_trigger.
CALL FUNCTION ‘RSPC_TRIGGER_DELETE’ EXPORTING i_variant = l_trigger
* I_NO_TRANSPORT =
* FAILED = 1
* OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
CALL FUNCTION ‘RSPC_TRIGGER_MAINTAIN’
EXPORTING i_variant = l_trigger
e_variant = l_trigger
e_variant_text = l_trigger_text.
ls_chain-variante = l_trigger.
MODIFY core_object->p_t_chain FROM ls_chain.
Check, save and activate the method. This post-exit method will create a new start process named <technical name of process chain>_START.
Now you can copy your process chain and it will create a new unique start process variant for each new process chain.
But please make sure that no one is creating or changing process chains, when you activate this enhancement. With activation a recompilation of the whole Transaction RSPC is necessary and user may wonder about some sudden dumps!
If you like this idea, you can also promote my idea on SAP Idea place: Copy of process chain creates new start process also
Maybe the simplest solution in BW 7.3 or later systems is to hide / disable the button “simple copy”. Then you’re forced to use the wizard and there you can define a newstart process.Hopefully this very small feature can be implemented with one of the next service packs.
I hope you like this blog. Feel free to comment.