Skip to Content
Author's profile photo Former Member

Approval Workflow for Pricing Condition

Business Scenario:

It is required that Sales manager must approve all order pricing changes. Since discounts and surcharges applied at order level, change the net price of an order, the discount/surcharge must be approved by a manager. Creating or updating a discount/surcharge record should trigger a workflow approval event. Once the workflow object is approved by the appropriate manager, the condition record is released and the discount/surcharge is applied to the order.

For the purpose of demo, consider the condition type for Customer Discount (K007). This document provides a custom solution for developing Approval Workflow for Condition Records.

Create Transaction Variant to make Processing Status ‘non-editable’ and assign a default value

A processor (sales clerk) can create and change condition records via VK11/VK12 transactions. It is necessary to disable the processing status field in order to prevent the sales clerk from accidently setting the status as Released.

  • Call transaction SHD0. Enter transaction code as VK11 and Z transaction variant ‘ZVAR_VK’. Click on ‘Create’ button.


  • Enter Condition type ‘K007’ and hit ‘Enter’ on the subsequent Pop up screen.

/wp-content/uploads/2013/10/2_311557.png /wp-content/uploads/2013/10/3_311561.png

  • Enter any Customer number, Amount and Set Processing status as ‘Blocked’


  • Set ‘Processing status’ field as ‘Output Only’ and ‘With Content’ on the subsequent popup screen. (screen variant)


  • Hit Save and then ‘Enter’ on the next pop up screen.


  • Save the Transaction Variant ‘ZVAR_VK’ and Screen variant ‘ZVAR_VK_1307’. Go to ‘Standard Variants’ tab and activate Transaction Variant ‘ZVAR_VK’. This sets ‘ZVAR_VK’ as default transaction variant for VK11 transaction.


         Transaction VK11 now has the Processing Status as a non-editable column with Default value as 1 (Blocked)


  • Call Transaction SHD0 and activate the same Transaction variant ’ZVAR_VK’ for Condition Change transaction – VK12.


  • Similarly, screen variants can be created for other condition types and assigned to this transaction variant.


For e.g. Transaction VK12 now has the Processing Status as a non-editable column with Default value as 1 (Blocked) for condition type PR01


Extend Business Object BUS3005 (Condition)

  • Call transaction SWO1 (Business Object Builder) and create object type ZZBUS3005


  • Provide Object name, Description and underlying program name. Supertype indicates that this object type is inherited from standard SAP business object type BUS3005.


  • Change Object Release status to ‘Implemented’


Create Custom Events

  • Place cursor on ‘Events’ and click ‘Create’. On the subsequent popup screen – provide event name ‘Created’. This event will serve as Triggering event for the Condition Record Approval Workflow.


  • Place cursor on event and change its release status to implemented


  • Create Event Parameters

Place cursor on event and choose ‘Parameters’.


Next click ‘Create’ and specify parameter name as ‘ChangeDoc_Pos’ of structure type CDPOS. This event parameter will contain old and new values of the condition. (While creation, the old values will be blank)


  • Create another Event ‘Changed’ with the same event parameter ‘ChangeDoc_Pos’ of structure type CDPOS.


Configure Workflow Triggering events on Change Document

When a change to a Condition Record is logged by the system using Change Document object ‘COND_A’ – the following event linkages will trigger the corresponding Business object Events.

  • Call transaction SWEC (Event Linkage for Change Documents) and click on ‘New Entries’


This entry will trigger ‘BUS3005.Created’ event every time a new Condition record is created. Create new Function ‘Z_FILL_EVENT_CONT’ that can be used to fill the Event Container with table of Change Document Items i.e.  Details of the change made to the Condition record.

Sample code:

FUNCTION z_fill_event_cont.


*”*”Local Interface:










* Fill Event Container from Change-document

  swc_set_table event_container ‘ChangeDoc_Pos’  changedocument_position.


  • Also add a new entry for ‘Changed’ Event.


This entry will trigger ‘BUS3005.Changed’ event every time a Condition record is changed.

Create Custom Attributes

  • Place cursor on ‘Attributes’ and click ‘Create’. Hit ‘Yes’ on the subsequent pop up.



  • Provide table name as ‘KONH’ and select the fields as shown. (More fields can be chosen if required within Workflow.)



  • Click ‘Create’ on all subsequent popup screens to create all selected attributes


Create Custom Methods

Review Pricing Condition – This method is used to present a custom approval screen to the Reviewer (Sales manager)

  • Create a new function – ‘Z_REVIEW_COND’ and design a custom Approval screen that lists Old /New values of the Pricing Condition record and Approve/Reject Buttons.

Sample Screen


  • Function module ‘Z_REVIEW_COND’ can be developed with the assumption that Change Document table is passed to it from workflow.
  • For each relevant field in the Change Document table – capture the old and new values and display on custom screen.
  • Fetch Customer number from Condition table. (‘A307’ in this example)
  • Capture the Review Result as ‘A’ for Approved and ‘R’ for Rejected and pass it as Exporting parameter.

Sample code:

* Populate Modified Fields

  LOOP AT it_changedoc_items.

    CASE it_changedoc_items-fname.

*     Discount changed

      WHEN ‘KBETR’.

        MOVE it_changedoc_items-value_old TO v_old_discount.

        v_old_discount = v_old_discount / 10.

        MOVE it_changedoc_items-value_new TO v_new_discount.

        v_new_discount = v_new_discount / 10.

*     Valid-from Date changed

      WHEN ‘DATAB’.


           it_changedoc_items-value_old TO wa_old-valid_from,

           it_changedoc_items-value_new TO wa_new-valid_from.

*     Valid-to Date changed

      WHEN ‘DATBI’.


           it_changedoc_items-value_old TO wa_old-valid_to,

           it_changedoc_items-value_new TO wa_new-valid_to.




In SWO1 transaction – Place cursor on ‘Method and click ‘Create’. On the subsequent popup screen – provide function name ‘Z_REVIEW_COND’.

/wp-content/uploads/2013/10/28_311587.png /wp-content/uploads/2013/10/29_311588.png

Set method as Dialog and create method parameters using function parameters.            



Click ‘Yes’ on the following pop up to auto-generate the method code.


Auto-generated Code:

begin_method reviewcond changing container.


      createdby TYPE konh-ernam,

      condtype TYPE t685t-vtext,

      reviewresult TYPE syst-input,

      changedocumenttable LIKE cdpos OCCURS 0.

swc_get_element container ‘Createdby’ createdby.

swc_get_element container ‘CondType’ condtype.

swc_get_table container ‘ChangeDocumentTable’ changedocumenttable.



    im_createdby            = createdby

    im_cond_type_name       = condtype


    ex_review_result        = reviewresult


    changedocument_position = changedocumenttable


    OTHERS                  = 01.

CASE sy-subrc.

  WHEN 0.            ” OK

  WHEN OTHERS.       ” to be implemented


swc_set_element container ‘ReviewResult’ reviewresult.

swc_set_table container ‘ChangeDocumentTable’ changedocumenttable.


Release Pricing Condition – This method is used to Release the block on the Condition record after Approval.

  • Place cursor on Method and click ‘Create’. On the subsequent popup screen – provide method name ‘ReleaseCond’. This method is a Background method.


  • Place cursor on method ‘ReleaseCond’ and click ‘Program’ to write method code.


Sample Code:

    begin_method releasecond changing container.


      l_usage             TYPE kvewe,

      l_cond_tab          TYPE kotabnr,

      l_appl              TYPE kappl,

      l_cond_type         TYPE kscha,

      l_cond_tab_name     TYPE t681-kotab,

      v_sel_tab_name      type string.

* Fetch Condition Header data

  swc_get_property self ‘Application’    l_appl.

  swc_get_property self ‘Usage’          l_usage.

  swc_get_property self ‘Table’          l_cond_tab.

  swc_get_property self ‘ConditionType’  l_cond_type.

* Determine condition tablename

  CLEAR l_cond_tab_name.



      rt_kotabnr = l_cond_tab

      rt_kvewe   = l_usage


      rt_kotab   = l_cond_tab_name.

  MOVE l_cond_tab_name  TO v_sel_tab_name.

* Update table to set Condition Record as RELEASED

  UPDATE (v_sel_tab_name)

     SET kbstat = ‘2’

         kfrst = ”

   WHERE kappl      = l_appl

     AND kschl      = l_cond_type

     AND knumh      = object-key-conditionrecordno.

  IF sy-subrc EQ 0.




  • Place cursor on method ‘ReleaseCond’ and change its release status to implemented


  • Save and Generate object type ‘ZZBUS3005’


Setup Business Object Delegation

  • Call transaction SWO1 and click on Setting -> Delegate


Add ‘New Entry’


This setting causes all the new methods, attributes and events from ZZBUS3005 (subtype) will be available within object type BUS3005 (supertype) – when it is used in any Workflow.

Build template for Pricing Condition Workflow

  • Call transaction SWDD – Workflow Builder. Click Save and provide name for the Workflow template



  • Click on ‘Basic Data’ tab to setup triggering events


  • Go to ‘Start Events’ tab and setup ‘Created’ and ‘Changed’ events of Business Object BUS3005 as the triggering events for this workflow template.


  • Activate the event linkages.

This setting will trigger a workflow instance every time a Condition record is created or changed.


  • For each event, setup start condition -> (Condition type = ‘K007’)

This ‘Start Condition’ will be evaluated before triggering new workflow instance.


  • Create Workflow Container variable ‘ChangeDoc_Pos’



  • Set variable ‘ChangeDoc_Pos’ property as ‘Import’ and ‘Multiline’. This indicates that the Change Document table will be passed to the Workflow from the Triggering Event



  • Similarly create Workflow Container variable ‘BUS3005’ of object type ‘BUS3005’ and set its property as ‘Import’ Parameter.


  • Go to ‘Start Events’ under ‘Basic Data’ and setup the Data binding as shown – for both events. This setting passes data from Event container to Workflow container – during the triggering of the Workflow



  • Add a new ‘Activity’ step for generating a Review task.

Double Click on ‘Undefined Step’ and choose step type as ‘Activity’



Choose Create task

/wp-content/uploads/2013/10/50_311610.png /wp-content/uploads/2013/10/51_311611.png



Click ‘Yes’ on the subsequent pop up to auto-create Task Container variables.



Make sure that Change Document table is passed to the task and Review Result is retrieved back to Workflow.

/wp-content/uploads/2013/10/53_311613.png /wp-content/uploads/2013/10/54_311614.png

Set the task as General Task

Use Rule ‘00000168’ to determine ‘Approver’ as the manager of the User (who creates/changes a condition record)


  • Add a condition step todetermine the Result of Approval.

/wp-content/uploads/2013/10/56_311616.png /wp-content/uploads/2013/10/57_311617.png

  • Add new Activity step for Releasing Condition Record in background.

Right click on the outcome branch ‘Approved’ and select ‘Create’ – Activity Step



Choose Create task

/wp-content/uploads/2013/10/59_311619.png /wp-content/uploads/2013/10/60_311660.png


Pass the Business Object instance to this task


  • Save and activate Workflow Template


Working DEMO

  • User creates a Condition record for Condition type ‘K007. Initially – the processing status is BLOCKED


  • On SAVE, the Workflow gets triggered and Approval item is routed to the Manager of the User who created the Condition record.


At this time, the customer discount is not reflected in the Order



  • The Sales Manager can view the following Review Screen by executing the Approval Work item. (Old values are blank since this is a new condition)


  • On Approval, the Condition Record is released and customer discount is now applied on to the Gross Price of the Order.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo OD Manikandan
      OD Manikandan

      Very Nice material



      Author's profile photo Ronen Weisz
      Ronen Weisz

      I have been looking for a way to do this for a long time,

      and seeing the whole process as you showed it was very helpful.

      One question, do you know of any way to do the condition update with a function module and not with a direct update?


      Author's profile photo Jyoti Prakash
      Jyoti Prakash


      Nice & elaborated documentation. Keep the good work & word moving.


      Best Wishes,


      Author's profile photo Former Member
      Former Member

      hi tanmay vyas

      Nice material

      thank u


      Author's profile photo anandkumar radhakrishnan
      anandkumar radhakrishnan

      Good Explanation!! Thanks a lot 🙂

      Author's profile photo Wallace Ferreira e Silva
      Wallace Ferreira e Silva

      Hi Tanmay,

      If approval user click cancel button in a review screen work item is completed.

      I think to move release code for review screen, because the method must be asynchronous and don´t accept export parameter.

      How do you implement cancel button in workflow ?

      Thanks in advance.


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Wallace,

      In the given scenario - I have used a Synchronous method for the Review task.On click of 'Cancel' button - You can use macro exit_cancelled to CANCEL the processing of the work-item but still keep the work-item within the Approver's inbox.


      Author's profile photo Wallace Ferreira e Silva
      Wallace Ferreira e Silva

      Thanks Tanmay,

      I used assychronous method with sucesss. But in VK11 and VK12 when user enter more one line in tabel control kbstat not filled with screen variant.

      How do solved this issue ?

      Thanks in advance and congrats great job !

      Author's profile photo Toney Benoy
      Toney Benoy

      Hi Tanmay,

      A very nice document, Everything is explained very well

      Can you please explain about the review screen in detail, Can you please explain more about review screen and how are you implementing review screen into SAP inbox

      Thanks in advance



      Toney C Benoy