Skip to Content

This post describes a universal approach to designing and building complex workflows for shopping carts.

Initial Customizing and activation of Workflow and BRF Objects are not described in this article. Main point is customization with development techniques.

Idea

Idea is to create a simple 2-Steps Workflow.

First approver is a requester of shopping cart, active only in case buy-on-behalf. ( Requester not equal to creator ). Requester can complete shopping cart.

Second approver is a free selected user from the system (for example own customer rule based on customer table). Approved can approve or reject shopping cart, but not allowed to change it. This step active only if shopping cart was created not by mentioned predefined user.

This Workflow will start only if free-text position exists, otherwise – no approval needed.

Common rules for evaluation can be represented as following.

image2013-5-1 22-36-42.png

Preparations

Created development package ZSRM_WF for all development object.

Group for own BRF objects

Start transaction BRF, then choose Utilities->Object Groups

image2013-5-1 20-19-40.png

Add a new entry

image2013-5-1 20-21-51.png

Save new entry and go back to transaction BRF. Now you can see new group.

image2013-5-1 20-23-25.png

New Workflow Tasks

You may need to define new workflow tasks. One per Workflow step.

image2013-5-1 22-38-40.png

Actually you need to copy them from the one of standard Tasks: Approval(TS40007953) or Completion (TS40007952).

So, first step is copied from TS40007952, second – from TS40007953.

To copy Workflow open transaction PFTC, enter template task and click “copy”.

image2013-5-1 21-58-58.png

Enter ab abbrevation and step description (this description will be schown in Workflow preview for shopping cart).

image2013-5-1 22-1-33.png

image2013-5-1 22-3-15.png

After copying you need to generalize the task. Go in change mode and navigate via menu:

image2013-5-1 22-5-18.png

Then select generalization type (General Task)

image2013-5-1 22-7-33.png

The same should be done for the second step(copy from TS40007953)

image2013-5-1 22-9-26.png

Define Rules for responsible approvers determination.

image2013-5-1 22-40-40.png

For the definition of mentioned rules you need to go to transaction SPRO, then navigate to: SAP Implementation Guide->SAP Supplier Relationship Management->Cross-Application Basic Settings->Business Workflow->Process-Controlled Workflow->Process-Controlled Workflow->Define Filter Values for BAdI ‘Define Agents’.

image2013-5-1 22-16-31.png

Here you should define 2 new rules – each for one step.

image2013-5-1 22-18-27.png

Define new Event/Expression for process level evaluation

Check, if process level relevant.

image2013-5-1 22-42-48.png

Step 1 – Requester in case buy on behalf

Create new expression.

New Expression is based on BRF Rules. Both expressions we need (CREATOR and REQUESTER) exist in Standard. So we create a new Expression type 0FB001 (SAP Formula Interpreter)

Go to transaction BRF and open customer group ZSRM.

image2013-8-1 20-26-5.png

Right click on Expressions and select New expression.

image2013-8-1 20-28-24.png

Enter type boolean and click on FormulaEditor.

image2013-8-1 20-30-42.png

Formula is just a comparison if creator not equal to requester

image2013-8-1 20-34-39.png

Go back and save an expression.

Create new event

Now it is time to create an event for created expression.

image2013-8-1 20-37-57 (1).png

Select the type 0EVENT for event.

image2013-8-1 20-39-56.png

Enter description and save the event. After that open event in edit modus.

image2013-8-1 20-45-52.png

Add expression to the event and save the data

image2013-8-1 20-47-12.png

Now you are ready with event for first step.

Step 2 – Customer approver

For the second step a customer function will be used.

Create evaluation function

Create a new function group ZSRM_WF_EX for Workflow Expressions.

Create new function module ZSRM_WF_EX_CUST_APPR_REL (Custom Approval relevance) as a copy from BRF_CALL_FUNCTION_TEMPLATE

image2013-8-1 21-49-19.png

Create new expression.

Now a new expression with the call of created function module to be created.

Go to BRF transaction and create new expression

image2013-8-1 22-17-46.png

Enter type and fucntion module name.

image2013-8-1 22-19-42.png

Save the expression.

Create new event

Now it is time to create an event for created expression.

image2013-8-1 22-21-4.png

image2013-8-1 22-22-4.png

Now you are ready with event for the second step.

Link to the second part of this post: Custom Workflow – Developer view – Part 2 – Process Schema and Implementation

P.S.:  English language is not my native language, and any person is not insured from mistakes and typing errors. If you have found an error in the text, please let me know – I’ll correct the post.

P.P.S.: If you have some ideas, how to correct/improve this post – please don’t hesitate to leave a comment.

To report this post you need to login first.

5 Comments

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

  1. Kendall J. Calvin Sr.

    I do have one question about the Reqst Appr; can an alternate approval event limiter be instituted during the particular event, or is a new evaluation process required. I a new undergraduate with a curiosity for SAP system programming.

    Great post.

    (0) 
    1. Konstantin Anikeev Post author

      Hi Kendall,

      as I understood, you meant event triggered from event (correct me, if I’m wrong).

      This is not a case for BRF.

      “BRF event” is the term for a calling point from within the application to the BRF. This linkage is fixed, and the call is synchronous. For this reason, a BRF event should not be viewed like ABAP-OO or the “Observer Pattern” where an event only represents a loose linkage between two software components.      

      As alternative you may use a number of expressions in a single event. In that case “event1 raises event2” means “event1 calls expressions of event 2”.

      More Info about BRF events you can find here and here.

      Best Regards

      Konstantin

      (0) 
  2. Lakshman N

    Thanks for sharing this.

    BTW , Your English is good. What does really matter is the content and its quality.

    The topic you’ve chosen is pretty good one and the way you explained is really nice.

    (0) 
  3. Ashish Shah

    Hi Konstantin,

    Thanks for the detailed Blog on this topic.

    Just to add to the option that you have shown about dynamically determining Process Schema.

    Instead of creating a Function module we can also create a class and its method can return the values of Schema.

    I suggest you create part 3 of this blog where in your BRF expression would use class and method approach.

    Regards,

    Ashish

    (0) 

Leave a Reply