Skip to Content

This blog is designed to help you understand and configure correlations in SAP Business Workflow. It does not describe the set-up of correlations in XI.

Correlations have been present in SAP Business Workflow since release 6.40 (NW04) and are intended to allow your workflow to wait for an event from a specific object for which it does not know the key. The example to be worked through was set up using the SAP on Linux Test-Drive (with the Windows SAPGUI hosted by a Virtual Machine) so there are only a few business objects to play with! The bare-bones scenario is:

1.A workflow is started for a person (PD-org type “External person”, ID 50000025).

2.This workflow is to be completed by a receiving wait step when a previously started absence request is approved.

The only link between the absence request and the External person is that this person ID was saved in the absence request form (Fig. 1). The object key for the approval event is of course the absence form number, in this example Number 5. Remember, the approval event contains no event parameters  for the person number field, it exists only in the absence table. Thus the absence form must be correlated to the person number at run-time for our example workflow to detect an event from the correct absence object.

Fig. 1

The traditional way of doing this set-up would be by recourse to coding. A new personnel event, from a delegation of an existing object (if one existed), would be triggered in the receiver function module of the original absence approval form event linkage in transaction SWE2. With correlations, no coding is now required, although interestingly, a special event receiver function module SWL_CORL_CORRELATE_BY_EVENT is inserted automatically into the event linkage table (Fig. 2).

Fig. 2

To set up this scenario, the first step is to set up the workflow container definitions. I’ve set as a mandatory import element Person based on the generic object PDOTYPES. I’ve used this rather than the personnel number field SWXFORMABS-PERNR simply to help identify different elements in the bindings, and it is slightly more realistic to start the workflow with an object. Within the template, the containers Absence based on FORMABSENC and CorrelationObject based on CL_SWF_MOD_ CORRELATION are created. CorrelationObject contains the run-time correlation data between FORMABSENC and PDOTYPES.OBJID. Let’s start with defining the correlation with transaction SWF_CRL1. The online help is here.

The correlation consists of a component FORMABSENC that must be an object with an event, and the correlated element (which can’t be an object) from the FORMABSENC attributes, although you define it how you like so long as the binding is allowed. Double-clicking the component FORMABSENC, something that could be a bit clearer, activates the assignments frame (Fig. 3).

Fig. 3Fig. 3

You can test the correlation using the object key of the component FORMABSENC, to make sure the settings have “stuck” – always a good check with workflow configurations! Your workflow key correlated to the absence business object is shown in XML format (Fig. 4).

Fig. 4

Now to the workflow definition proper.

In the SAP library, it lists activating a correlation in a process control step straight after defining it with SWF_CLR1. However, I found that the entry fields are from drop-downs, and these are not populated until you define a version-dependant event in the workflow header (Fig. 5).

1.Click on the status button for a new event and enter a name, here “Absence”.

2.The wait type should be “Wait for Event By Using Correlation”.

3.Enter the event to be waited for, here FORMABSENC-APPROVED

4.Make the receiver type “Wait Step Event”

Fig. 5

Now enter a step in the workflow for a process control (Fig. 6).

5.In the control tab function field, enter “Activate Correlation”

6.Select the name of event defined in step 1 above from the drop-down.

7.Enter the correlation name, here ZMY_FIRST_CORRELATION.

8.I’ve only got this to work only by using binding: Choose the binding from PERSON.OBJID from the import container, to PERSONNELNO in the correlation definition.

9.To complete the process definition, enter the correlation object container for the correlation instance.

imageFig. 6 

We now need to define a wait step.

10. Define binding for event from &_EVT_OBJECT& to workflow container &ABSENCE& (Fig. 7)

Fig. 7

11. Define binding for event from workflow import element &PERSON.OBJID& to correlation element &PersonnelNo&. (Fig. 8)

Fig. 8

12.  Activate the workflow. The information message number WD060 “The container element  “CorrelationObject” is written, but not read or exported” is normal (Fig. 9).

 

Fig. 9

That’s it. We can test the correlation.

13. Using transaction SWUS, I’ve started the workflow and entered the previously created object “External Person” (with transaction PP01), number 500000025 (Fig. 10)

Fig. 10

 

14. The workflow log indicates that step 314 is now waiting for an event for an object that contains the personnel number 500000025 (Fig 11).

Fig. 11

15. Let’s oblige by creating an APPROVED event from the previously saved absence form number 5 (Fig. 12).

Fig. 12

16. Success! The wait event has recognized the absence form number 5 as correlated to the personnel number 500000025 (Fig. 13).

 

Fig. 13

17. A quick look at the event logs (transaction SWEL) to see what has gone on in the background (Fig.14).

Fig. 14Fig 14

To report this post you need to login first.

12 Comments

You must be Logged on to comment or reply to a post.

  1. Srihari Hebbar
    A wonderful blog, I was a little surprised when I saw the correlations on the wait for event tab (had worked on ECC 5.0 which did not have it).

    I can use correlation to make many of my work flow designs better.

    (0) 
  2. kamal raja Elango
    hai
    really its an nice work !! good effort.
    when i trying to use it iam having an error in step no 7. i had complted the correlation and while testing also i got the result as per test correlation step. but when iam entering the name in step 7 control tab- correlation name it displaying “COMPONENT CL_SF_MOD_CORRELATION IS NOT DEFINED IN CORRELATION ZMY_FIRST_CORELATION”.
    pls help me to rectify this.
    regards
    rose
    (0) 
    1. Philip @Kisloff Post author
      Hi Rose

      Thanks for your kind words!

      I think I can reproduce your error. Could you check you are “using binding” and not “using base element” in step (7)?

      With “using base element” (which I never got to work) CL_SWF_MOD_CORRELATION is one of the allowed elements, and if selected that gives the error you describe on checking.

      I guess it could be a bit clearer, but see Fig. 6. BTW,I have just noticed that my cheat of getting around the 600X400 pixel limitation by putting two images against each other only works on IE, not Firefox 🙁

      Hope this helps

      best regards

      Phil

      (0) 
  3. Radha Subramanian
    Nice blog . Looks like a nice way of doing this stuff . However could not get a drop down on the Process control step for the co-rellation object althought I have created it . Also in the header , when i create the event , the class CL_SWF_MOD_CORRELATION event which shows up in the dropdown is FULFILLED_BY_EVENT . I have plonked in APPROVED manually . Any ideas .
    (0) 
    1. Philip @Kisloff Post author
      Actually, not so nice. We’re talking about step 3. I’m looking at the set up I have in my system, and it looks different to Fig.5. The text is correct, the wait for step is BOR FORMABSENC – APPROVED. I’m not sure how this mistake happened, but I do remember I had try lots of different settings until it worked, so maybe a screenshot got mixed up.

      (0) 
  4. Christian Gebert
    …this is a really nice blog and exactly what I’m looking for.

    But…it doesn’t work for me. Maybe you can help me: I’m starting the workflow via SWUS and everytime it’s stopping with an error:
    Workflow ‘000000001056’ wait step 0000000008 object FORMABSENC: Element ” not in container/empty
    Message no. WL420

    Do you have a clue?

    Thanks in advance
    Christian

    (0) 
  5. Mike Pokraka
    Although correlations are not often used in workflow, it’s always useful for people to understand what they are – and therefore understand when to use them.
    (0) 
  6. James Johnson

    Nice blog, thanks for the post Philip.  I thought I’d post to note an issue I ran into with setting up a correlation, and how to avoid it (specifically to avoid other people having to go through the same pain).

    If you’re intending to use a single correlation object for multiple types of correlation using similar objects (or want to copy the definitions of an existing correlation to use as a template for another), then be very careful with the event object to correlation binding. 

    If you have multiple correlated elements of FORMABSENC listed in the correlation object, but don’t specify all of them in the correlation binding, (even if you’re only interested in correlating one of the elements) the event wouldn’t link with the workflow when created.

    The way to handle this is to pass in a blank value as the source in the binding, with the unused correlated element(s) listed as the associated target.  Or (even better), just keep your correlation objects as granular as possible (obviating redundant correlated elements) to avoid the issue occuring in the first place.

    (0) 
  7. Jaganath Panda

    Hi Philip,All,

       Awesome One… Specially for releated Object Types in WF. Great Thanks!!..

    Scenario: Whenever a Normal Invoice is created for a particular Sales Order the Wait Step should complete.

    I have followed the same steps. as below:

    1. Created Event Linkage in SWE2

    2. Maintained Event in Header of WF temp..

    3. Used Process Control to Activate Correlation

    4. Created Wait Step with correlation.

    Tha Event is getting trigger as below:

    snap.PNG

    The WF log shows the below , as waiting :

    snap1.PNG

      The Correlation is working fine individually : snap3.PNG

    Could you helpout why the correlation wait step not able to recieve the Event trrigerred ( Invoice Created event with same sales order )

    Need your help..

    Thank You,

    Best regards,

    Jagan

    (0) 
    1. Paul Bakker

      Hi,

      Tip: More people will see your question if you post it as a new discussion, rather than tacking it onto a really old one.

      cheers

      Paul

      (0) 

Leave a Reply