Wednesday, January 6, 2016

Tricks of the action framework

Today’s article is about SAP CRM on Premise. In the past we had a number of blog posts on the Action framework. Today I will share some tricks of the Action Framework that were new to me. One of the things you will learn is how to schedule an action to start only during a full moon!

Trick 1: Use AET fields in Conditions

When you create additional fields with the AET you get a lot for free: The fields are automatically available in the Web UI, SAP GUI, reporting and other places.
But what if you also want to use an AET field in a Schedule Condition or Start Condition?
The Condition editor uses BOR objects and fortunately it is easy to add AET (and EEWB) fields to these objects. Suppose you have created the following field in the AET:

In order to use this field you have to add it to the relevant BOR object. Navigate to your (Schedule or Start) Condition to identify the correct BOR object type (in this case BUS2000126):

First, go to SWO1 and create a subtype of the given type with the button 'Subtype':

The newly created subtype is shown:

Go to the Change Mode, Click on Attributes and then on Create:

(Choose Yes)

Select the relevant table and field and confirm:

After release and activation, the attribute is available in the BOR object:

The final step is to mark the subtype ZTEST00126 as the default delegation type of the standard BUS2000126 object (see also

The end result is that the new attribute is now available in the Condition Editor:

Now you can use the new attribute in a condition

Trick 2: Using Condition Badi’s

The Workflow-style conditions as shown above give you a lot of tools to express your start and schedule conditions, especially if you correctly enhance it by adding new attributes, relations and methods. However sometimes you just *need* the power of some real ABAP. For example: You need to perform a complex query or you need to able to determine the moon phase (by using the AERIS Weather API  at

You can change the Rule Type on the action from Workflow Conditions to Conditions Using Business Addins:

There are two Badi definitions available:
  • EVAL_SCHEDCOND_PPF For schedule conditions
  • EVAL_STARTCOND_PPF For start conditions
Below is a sample implementation for a start condition that evaluates to true only during full moon:
  METHOD if_ex_eval_startcond_ppf~evaluate_start_condition.

IMPORTING client  DATA(lo_client)

->send( ).
->receive( ).

IF lo_client->response->get_cdata( ) CS 'full moon'.
0" Trigger condition
1" Do not trigger condition

->close( ).

This Badi can be assigned to the Condition set of an action:

When using Condition Badi's, there are two important considerations:
  1. The rule type can only be defined on the level of the Action Definition. This means that both the Schedule condition and Start condition of an action must be of the same type. They are both either Workflow conditions or Badi condition. So for example: you cannot use a Workflow condition for the schedule condition and a Badi condition for the Start condition within the same action
  2. Keep the performance of the Badi’s in mind: The badi’s are executed more often than you’d think (during viewing, editing and saving of transactions, during bulk editing of transactions, during execution of SPPFP). This means that doing an actual web service call as in the example probably isn’t the best idea ever.

No comments:

Post a Comment