1/23/2017 Approval Workflow for Pricing Condition | SAP BlogsGet Started Solutions Support Training Community Developer Partner About Community / Blogs Approval Workflow for Pricing Condition October 30, 2013 | 678 Views | Tanmay Vyas more by this author SAP Business Workflow abap devlopment | pricing condition;pricing | pricing sales order | sap sales and distribution | sap sd | sap sd pricing | sap workflow | sap workflow design | workflow approval share 0 share 0 tweet share 0 Follow Business Scenario: It is required that Sales manager must approve all order pricing changes. Since discounts and surcharges applied at order level, https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 1/33 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs 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. https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 2/33 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs 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) https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 3/33 This sets ‘ZVAR_VK’ as default transaction variant for VK11 transaction.sap. Save the Transaction Variant ‘ZVAR_VK’ and Screen variant ‘ZVAR_VK_1307’.com/2013/10/30/approvalworkflowforpricingcondition/ 4/33 . https://blogs.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Hit Save and then ‘Enter’ on the next pop up screen. Go to ‘Standard Variants’ tab and activate Transaction Variant ‘ZVAR_VK’. 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs 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. Transaction VK12 now has the Processing Status as a noneditable column with Default value as 1 (Blocked) for condition type PR01 https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 5/33 . For e. screen variants can be created for other condition types and assigned to this transaction variant. Similarly.g. 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Extend Business Object BUS3005 (Condition) Call transaction SWO1 (Business Object Builder) and create object type ZZBUS3005 Provide Object name.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 6/33 . Description and underlying program name. Change Object Release status to ‘Implemented’ https://blogs. Supertype indicates that this object type is inherited from standard SAP business object type BUS3005. 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Create Custom Events Place cursor on ‘Events’ and click ‘Create’.com/2013/10/30/approvalworkflowforpricingcondition/ 7/33 . On the subsequent popup screen – provide event name ‘Created’.sap. Place cursor on event and change its release status to implemented https://blogs. This event will serve as Triggering event for the Condition Record Approval Workflow. the old values will be blank) https://blogs. This event parameter will contain old and new values of the condition. (While creation.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Create Event Parameters Place cursor on event and choose ‘Parameters’.sap. Next click ‘Create’ and specify parameter name as ‘ChangeDoc_Pos’ of structure type CDPOS.com/2013/10/30/approvalworkflowforpricingcondition/ 8/33 . 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Create another Event ‘Changed’ with the same event parameter ‘ChangeDoc_Pos’ of structure type CDPOS.com/2013/10/30/approvalworkflowforpricingcondition/ 9/33 .sap. https://blogs. 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. Create new Function ‘Z_FILL_EVENT_CONT’ that can be used to fill the Event Container with table of Change Document Items i. *”———————————————————————- *”*”Local Interface: *” IMPORTING *” VALUE(CHANGE_DOC_OBJECT) TYPE SWECDOBJ- CDOBJECTCL OPTIONAL *” VALUE(OBJTYPE) TYPE SWECDOBJ-OBJTYPE OPTIONAL *” VALUE(OBJKEY) TYPE SWEINSTCOU-OBJKEY OPTIONAL *” VALUE(EVENT) TYPE SWOTRE-EVENT OPTIONAL *” TABLES *” EVENT_CONTAINER STRUCTURE SWCONT OPTIONAL *” CHANGEDOCUMENT_POSITION STRUCTURE CDPOS OPTIONAL *”———————————————————————- * Fill Event Container from Change-document https://blogs.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Call transaction SWEC (Event Linkage for Change Documents) and click on ‘New Entries’ This entry will trigger ‘BUS3005.e. Details of the change made to the Condition record. Sample code: FUNCTION z_fill_event_cont.com/2013/10/30/approvalworkflowforpricingcondition/ 10/33 .sap.Created’ event every time a new Condition record is created. Provide table name as ‘KONH’ and select the fields as shown. ENDFUNCTION. Hit ‘Yes’ on the subsequent pop up.sap. (More fields can be chosen if required within https://blogs. This entry will trigger ‘BUS3005.com/2013/10/30/approvalworkflowforpricingcondition/ 11/33 . Create Custom Attributes Place cursor on ‘Attributes’ and click ‘Create’.Changed’ event every time a Condition record is changed.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs swc_set_table event_container ‘ChangeDoc_Pos’ changedocument_position. Also add a new entry for ‘Changed’ Event. https://blogs.sap.com/2013/10/30/approvalworkflowforpricingcondition/ 12/33 .1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs 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. 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Sample Screen Function module ‘Z_REVIEW_COND’ can be developed with the assumption that Change Document table is passed to it from workflow. MOVE it_changedoc_items-value_old TO v_old_discount. Sample code: * Populate Modified Fields LOOP AT it_changedoc_items. For each relevant field in the Change Document table – capture the old and new values and display on custom screen.sap. Fetch Customer number from Condition table. CASE it_changedoc_items-fname. MOVE it_changedoc_items-value_new TO https://blogs.com/2013/10/30/approvalworkflowforpricingcondition/ 13/33 . (‘A307’ in this example) Capture the Review Result as ‘A’ for Approved and ‘R’ for Rejected and pass it as Exporting parameter. v_old_discount = v_old_discount / 10. * Discount changed WHEN ‘KBETR’. * Valid-to Date changed WHEN ‘DATBI’. WRITE: it_changedoc_items-value_old TO wa_old-valid_to. In SWO1 transaction – Place cursor on ‘Method and click ‘Create’. * Valid-from Date changed WHEN ‘DATAB’. On the subsequent popup screen – provide function name ‘Z_REVIEW_COND’.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs v_new_discount.sap. WRITE: it_changedoc_items-value_old TO wa_old-valid_from. ENDLOOP.com/2013/10/30/approvalworkflowforpricingcondition/ 14/33 . Set method as Dialog and create method parameters using https://blogs. it_changedoc_items-value_new TO wa_new-valid_from. v_new_discount = v_new_discount / 10. ENDCASE. WHEN OTHERS. it_changedoc_items-value_new TO wa_new-valid_to. com/2013/10/30/approvalworkflowforpricingcondition/ 15/33 . DATA: https://blogs.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs function parameters. Autogenerated Code: begin_method reviewcond changing container.sap. Click ‘Yes’ on the following pop up to autogenerate the method code. 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs createdby TYPE konh-ernam. swc_get_element container ‘CondType’ condtype. swc_get_element container ‘Createdby’ createdby. swc_get_table container ‘ChangeDocumentTable’ changedocumenttable. CASE sy-subrc. ” OK WHEN OTHERS.sap. condtype TYPE t685t-vtext. swc_set_element container ‘ReviewResult’ reviewresult. https://blogs. changedocumenttable LIKE cdpos OCCURS 0.com/2013/10/30/approvalworkflowforpricingcondition/ 16/33 . reviewresult TYPE syst-input. ” to be implemented ENDCASE. WHEN 0. CALL FUNCTION ‘Z_REVIEW_COND’ EXPORTING im_createdby = createdby im_cond_type_name = condtype IMPORTING ex_review_result = reviewresult TABLES changedocument_position = changedocumenttable EXCEPTIONS OTHERS = 01. 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs swc_set_table container ‘ChangeDocumentTable’ changedocumenttable. Release Pricing Condition – This method is used to Release the block on the Condition record after Approval. https://blogs.sap. This method is a Background method. Place cursor on Method and click ‘Create’. Place cursor on method ‘ReleaseCond’ and click ‘Program’ to write method code. end_method.com/2013/10/30/approvalworkflowforpricingcondition/ 17/33 . On the subsequent popup screen – provide method name ‘ReleaseCond’. CALL FUNCTION ‘RV_TABLE_NAME_SET’ EXPORTING rt_kotabnr = l_cond_tab rt_kvewe = l_usage https://blogs. * Determine condition tablename CLEAR l_cond_tab_name. swc_get_property self ‘Table’ l_cond_tab.sap. * Fetch Condition Header data swc_get_property self ‘Application’ l_appl. l_cond_type TYPE kscha. v_sel_tab_name type string.com/2013/10/30/approvalworkflowforpricingcondition/ 18/33 . l_appl TYPE kappl. swc_get_property self ‘Usage’ l_usage.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Sample Code: begin_method releasecond changing container. swc_get_property self ‘ConditionType’ l_cond_type. l_cond_tab_name TYPE t681- kotab. l_cond_tab TYPE kotabnr. DATA : l_usage TYPE kvewe. IF sy-subrc EQ 0. * 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.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs IMPORTING rt_kotab = l_cond_tab_name. end_method.com/2013/10/30/approvalworkflowforpricingcondition/ 19/33 . COMMIT WORK AND WAIT.sap. ENDIF. Place cursor on method ‘ReleaseCond’ and change its release status to implemented Save and Generate object type ‘ZZBUS3005’ https://blogs. MOVE l_cond_tab_name TO v_sel_tab_name. Build template for Pricing Condition Workflow https://blogs. attributes and events from ZZBUS3005 (subtype) will be available within object type BUS3005 (supertype) – when it is used in any Workflow.com/2013/10/30/approvalworkflowforpricingcondition/ 20/33 .sap.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Setup Business Object Delegation Call transaction SWO1 and click on Setting > Delegate Add ‘New Entry’ This setting causes all the new methods. sap.com/2013/10/30/approvalworkflowforpricingcondition/ 21/33 . Activate the event linkages.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Call transaction SWDD – Workflow Builder. https://blogs. 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. For each event.com/2013/10/30/approvalworkflowforpricingcondition/ 22/33 .sap. setup start condition > (Condition type = ‘K007’) This ‘Start Condition’ will be evaluated before triggering new workflow instance.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs This setting will trigger a workflow instance every time a Condition record is created or changed. Create Workflow Container variable ‘ChangeDoc_Pos’ https://blogs. com/2013/10/30/approvalworkflowforpricingcondition/ 23/33 . Go to ‘Start Events’ under ‘Basic Data’ and setup the Data binding as shown – for both events.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Set variable ‘ChangeDoc_Pos’ property as ‘Import’ and ‘Multiline’.sap. This setting passes data from Event container to Workflow container – during the triggering of the Workflow https://blogs. 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. 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Add a new ‘Activity’ step for generating a Review task.sap. Double Click on ‘Undefined Step’ and choose step type as ‘Activity’ Choose Create task https://blogs.com/2013/10/30/approvalworkflowforpricingcondition/ 24/33 . 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Click ‘Yes’ on the subsequent pop up to autocreate Task Container variables. Make sure that Change Document table is passed to the task and Review Result is retrieved back to Workflow.com/2013/10/30/approvalworkflowforpricingcondition/ 25/33 . https://blogs.sap. com/2013/10/30/approvalworkflowforpricingcondition/ 26/33 .sap. https://blogs.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs 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. Right click on the outcome branch ‘Approved’ and select ‘Create’ – Activity Step Choose Create task https://blogs.com/2013/10/30/approvalworkflowforpricingcondition/ 27/33 .sap.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Add new Activity step for Releasing Condition Record in background. 1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Pass the Business Object instance to this task Save and activate Workflow Template Working DEMO User creates a Condition record for Condition type ‘K007.com/2013/10/30/approvalworkflowforpricingcondition/ 28/33 .sap. Initially – the processing status is BLOCKED https://blogs. sap. the customer discount is not reflected in the Order https://blogs.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs 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.com/2013/10/30/approvalworkflowforpricingcondition/ 29/33 . Alert Moderator https://blogs.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs The Sales Manager can view the following Review Screen by executing the Approval Work item.com/2013/10/30/approvalworkflowforpricingcondition/ 30/33 . the Condition Record is released and customer discount is now applied on to the Gross Price of the Order.sap. (Old values are blank since this is a new condition) On Approval. com/2013/10/30/approvalworkflowforpricingcondition/ 31/33 . OD Ronen Weisz January 29.sap. JP https://blogs. do you know of any way to do the condition update with a function module and not with a direct update? Ronen Jyoti Prakash May 2.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs 8 Comments You must be Logged on to comment or reply to a post. and seeing the whole process as you showed it was very helpful. One question. 2013 at 7:10 am Very Nice material Regards. Thanks. 2014 at 11:52 am Tanmay Nice & elaborated documentation. OD Manikandan October 31. 2014 at 7:24 pm I have been looking for a way to do this for a long time. Best Wishes. Keep the good work & word moving. If approval user click cancel button in a review screen work item is completed. 2016 at 4:19 pm Hi Tanmay.com/2013/10/30/approvalworkflowforpricingcondition/ 32/33 . 2016 at 8:58 pm https://blogs. How do you implement cancel button in workflow ? Thanks in advance. 2014 at 5:27 pm hi tanmay vyas Nice material thank u satish anandkumar radhakrishnan May 3. I think to move release code for review screen. 2014 at 7:08 am Good Explanation!! Thanks a lot Wallace Ferreira e Silva February 5. Wallace Tanmay Vyas Post author February 22.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs satish kumar pulijala May 2.sap. because the method must be asynchronous and don´t accept export parameter. In the given scenario – I have used a Synchronous method for the Review task. How do solved this issue ? Thanks in advance and congrats great job ! Share & Follow Privacy Terms of Use Legal Disclosure Copyright Trademark Sitemap Newsletter https://blogs.sap. 2016 at 12:41 pm Thanks Tanmay.On click of ‘Cancel’ button – You can use macro exit_cancelled to CANCEL the processing of the workitem but still keep the workitem within the Approver’s inbox. But in VK11 and VK12 when user enter more one line in tabel control kbstat not filled with screen variant. Tanmay Wallace Ferreira e Silva February 23. I used assychronous method with sucesss.1/23/2017 Approval Workflow for Pricing Condition | SAP Blogs Hi Wallace.com/2013/10/30/approvalworkflowforpricingcondition/ 33/33 .
Report "Approval Workflow for Pricing Condition in SAP"