Blogs

Phil Kisloff

Correlations in SAP Business Workflow
Phil Kisloff Active Contributor Bronze: 250-499 points SAP Mentor
Business Card
Company: Capgemini
Posted on Sep. 11, 2007 12:39 AM in Business Process Management, Business Process Expert, SAP Business Workflow

Subscribe.Subscribe
Print. Print
Permalink Permalink
Share

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

Phil Kisloff  Active Contributor Bronze: 250-499 points SAP Mentor is an SAP Mentor and Senior Applications Consultant for Capgemini.


Comment on this articleHope this is useful to all workflow developers!
Comment on this weblog
Showing messages 1 through 7 of 7.

Titles Only Main Topics Oldest First

  • Useful blog
    2009-11-01 10:52:30 Mike Pokraka Business Card [Reply]

    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.
  • Dear Phil...
    2008-10-16 04:53:57 Christian Gebert Business Card [Reply]

    ...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

  • Nice Blog
    2008-02-27 04:36:15 Radha Subramanian SAP Employee Business Card [Reply]

    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 .
    • Nice Blog
      2008-02-27 06:59:42 Phil Kisloff Business Card [Reply]

      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.


  • nice blog
    2007-09-19 08:46:15 kamal raja Elango Business Card [Reply]

    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
    • nice blog
      2007-09-19 12:22:28 Phil Kisloff Business Card [Reply]

      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


  • Thank you
    2007-09-12 12:42:33 Srihari Hebbar Business Card [Reply]

    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.


Showing messages 1 through 7 of 7.