Execute Actions or FMs in locked instances mode in SAP TM

SAP TM
Share on Facebook24Share on LinkedIn8Tweet about this on TwitterShare on Google+1
Please Share!!

In the previous post, we saw how to trigger PPF from stand along code in SAP TM. In this article we would see how to trigger an action from UI or from a BOPF.

1.0 Introduction

In SAP Transportation Management, we get many scenarios to trigger an action from UI or from a BOPF program, to carry out a function. It could be creating a document/changing some status of a document based on certain checks. When we execute these actions from BOBF framework within the same LUW ( Logical Unit of Work ) we are pretty safe in terms of lock handling / BO ( business object) modification and reporting the same in UI, so that user can carry out the same action again by removing the lock.

Imagine the action is being called from a different source ( ECC / CRM etc ) and they do not have the ability to trigger the function again, as it is one of many steps that they perform. So now the responsibility lies within SAP TM to somehow register that Trigger and the data packet that came along with it and then processing it subsequently by a re-trial mechanism. In order to handle this kind of situation we create separate tables to store that data and then re-process it.

But in SAP TM we have a very standard process of doing it. We will discuss how to do it. As of now standard SAP TM environment supports two kinds of updates. ( BO Action and Function Module ( Normal/RFC)).

2.0 Technical Design

The following design is based on a requirement in a project where an update is coming from ECC system via an RFC call into SAP TM box. Within the RFC call we are doing a BO action call on “Customer Freight Invoice Request (CFIR)” to update status on an invoice document.

The idea is to call the action in locked instance mode and if anything goes wrong with the update (BO being locked/update failed due to some data errors etc) we will register the lock, so that we will use standard SAP TM tool to re-process the lock.

A) Design involving an Action Call on a BO

Step 1) Create a Trigger ID ( Custom Trigger ) in a standard table /SCMTMS/I_TRIG

SAP has not given any maintenance view for this table yet. So we will create an entry in this table by SE16. Make sure you create an transport entry for this one directly in a TR.

SAP TM

Create an entry in this table with a custom trigger name. Since in here we will process a BO action we will use the Trigger Class as /SCMTMS/CL_TRIG_CONTROL_ACTION

/SCMTMS/CL_TRIG_CONTROL_ACTION

Step 2) Check if the BO Instance is locked or not?

Step 3) Execute the action directly for keys which are unlocked.

Step 4) Register the Trigger for the framework to process it later

Important Notes :

1. When a BO instance is locked and a Trigger is registered; the same should be seen in a standard table /SCMTMS/D_TRIGHD and the data in the action parameters are registered in table /SCMTMS/D_TRIGCX.

2. Once the Trigger is registered in these tables; we can run the standard program /SCMTMS/PROCESS_TRIGGER_BGD. By un checking the check box and putting the respective Trigger ID, we can just process the specific trigger.

/SCMTMS/PROCESS_TRIGGER_BGD

(If the selection screen of program /SCMTMS/PROCESS_TRIGGER_BGD does not look same then; please make sure you apply few SAP notes in your system; as sap has corrected few bugs in this program by these notes)

3. Once the process is complete and update is carried out, the tables entries are deleted. In case the LOCK is still there in the BO instance, the specific entry will not be processed and retained in the tables for later processing by the same standard program.

4. During action execution if we encounter any error during BO modification and we want to retain the Trigger in the table for later processing; then we just need to fill the FAILED key in the action.

[adToAppearHere]

B) Design involving a Function Call on a BO

Step 1) Create a Trigger ID ( Custom Trigger ) in a standard table /SCMTMS/I_TRIG

/SCMTMS/I_TRIG

Create an entry in this table with a custom trigger name. Since in here we will process BO update by a function call; we will use the Trigger Class as /SCMTMS/CL_TRIG_CONTROL_FM.

Step 2) Create a function module with the following signature

/SCMTMS/CL_TRIG_CONTROL_FM

You should have at least IT_KEY & IS_PARAMETER as input to the FM as standard frame work searched the FM signature for dynamic data filling with the same name. You can have additional parameters but the minimum is these two. Please do NOT even alter the parameters name. You can have IT_KEY as dummy and it may be even initial if you do not need it but it has to be there in the FM signature.

IT_KEY & IS_PARAMETER

SAP TM

Step 3) Check if the BO Instance is locked or not ?

Step 4) Execute the Function Module directly for keys which are unlocked.

Step 5) Register the Trigger for locked keys for the framework to process it later

SAP TM

Important Notes :

1. Unlike Action processing by Trigger if we encounter any error during BO modification and we want to retain the Trigger in the table for later processing; then we just need to handle it explicitly as there is no FAILED key here. We have to create entries in trigger table by code in the FM itself in case such situation occurs.

2. Personally, I would recommend to use Action Based Trigger processing as it involves less coding effort.

If you want to get such practical tweaks and tricks straight to your inbox, please SUBSCRIBE. We respect your privacy and take protecting it seriously.

If you liked this post, please hit the share buttons at the left side of your screen. Please like us at facebook and encourage us.

Thank you very much for your time!!

Share on Facebook24Share on LinkedIn8Tweet about this on TwitterShare on Google+1
Please Share!!

About the Author

Chinmaya Das
Chinmaya Das
Qualification: M.Tech from IIT Kharagpur, India. SAP ABAP Experience since 2006. Find more about him on LinkedIn.