Business Scenario:


In a typical FI Invoice approval process, the Processor (Accounts Payable Clerk) can ‘Park’ the document and then ‘Complete’ it to send it for approval.  After it is sent for approval, if the processor happens to change the document (e.g. correcting an error or making a necessary subsequent change), the Approval item is removed from the Approver’s SAP Inbox. The approval sub-workflow is re-started and the Workflow now waits for the document to be ‘Completed’ again.

The Processor must be informed that such a change has led to deletion of existing workflow from the Approver’s inbox and that the document must be ‘Completed’ once again in order to be resent for approval.

Benefits:

  1. This solution helps to prevent inadvertent/uninformed interference of the Approval process by the processor.
  2. The explanatory message helps the processor to update the underlying document with full knowledge of impacts on workflow. This also helps to avoid rework by the Workflow Administrator.

For the purpose of demo, consider Approval Workflow for Non-PO Invoices (Vendor Invoice).  A processor can Create / change a vendor invoice via transaction FV60.

/wp-content/uploads/2013/11/1_313847.png

If the processor changes ‘Reference text’ of a Vendor Invoice that was already sent for approval, the workflow gets killed (logically deleted) and no one gets alerted.

/wp-content/uploads/2013/11/2_313848.png

Implement Business Transaction Event (Process interface 2217)


BTE 2217 can be used to determine whether the FI document goes from COMPLETED to PARKED status.

/wp-content/uploads/2013/11/3_313849.png

  • Create function ‘ZSAMPLE_INTERFACE_00002217’ as a copy of ‘SAMPLE_INTERFACE_00002217’

Call transaction SE80 and create new function group e.g. ‘ZFI_DOC_CHANGE’.

/wp-content/uploads/2013/11/4_313850.png

  • Click YES on confirmation pop up. Save and activate function group

/wp-content/uploads/2013/11/5_313851.png/wp-content/uploads/2013/11/6_313852.png

  • Call transaction SE37 , enter ‘from Function’ name as ‘SAMPLE_INTERFACE_00002217’. Click Copy Icon and specify ‘ZSAMPLE_INTERFACE_00002217’ as ‘to Function’. Save the function.

/wp-content/uploads/2013/11/7_313856.png

  • Configure BTE

Call transaction SPRO:

SAP Reference IMG -> Financial Accounting -> Financial Accounting Global Settings -> Business Transaction Events

or

Call transaction FIBF. Choose ‘Products of a Customer’

/wp-content/uploads/2013/11/8_313857.png 

  • Add New Entry for Product ‘ZFI_CHG’, description and SET the active flag. Save the new product.

/wp-content/uploads/2013/11/9_313858.png

  • Next, choose ‘P/S Modules of a Customer’

/wp-content/uploads/2013/11/10_313859.png

 

  • Add New Entry for BTE – 2217. Use the function name and Product created in previous steps. Save the new entry.

/wp-content/uploads/2013/11/11_313860.png 

Function ‘ZSAMPLE_INTERFACE_00002217’

  • Call transaction SE37 and open function ‘ZSAMPLE_INTERFACE_00002217’ in change mode.

Sample Code:

FUNCTION zsample_interface_00002217.

*”——————————————————————–

*”*”Local Interface:

*”  EXPORTING

*”     REFERENCE(E_SUBRC) TYPE  SYSUBRC

*”  TABLES

*”      T_XVBKPF STRUCTURE  FVBKPF

*”      T_XVBSEG STRUCTURE  FVBSEG

*”      T_YVBKPF STRUCTURE  FVBKPF

*”      T_YVBSEG STRUCTURE  FVBSEG

*”——————————————————————–

* Data Declaration

  DATA:

      l_object_key          TYPE swotobjid-objkey,

      l_return_code         TYPE sy-subrc,

      l_workflow_count      TYPE syst-tabix,

      ls_worklist           TYPE swr_wihdr,

      lt_task_filter        TYPE TABLE OF swr_task,

      lt_worklist           TYPE TABLE OF swr_wihdr,

      l_text                TYPE char255.

* Check whether current doc is a Vendor Invoice

  CHECK t_xvbkpf-blart = ‘KR’.

* Setup object key – (Company code – Doc no. – Fiscal Year)

  CONCATENATE  t_xvbkpf-bukrs t_xvbkpf-belnr t_xvbkpf-gjahr INTO l_object_key.

  CONDENSE  l_object_key.

* Set up the TASK_FILTER – Approval Sub-Workflow template

  FREE lt_task_filter.

  APPEND ‘WS99000007’ TO lt_task_filter.

* Check if atleast one Sub Workflow instance already exists – for the current KR doc

  FREE lt_worklist.

  CALL FUNCTION ‘SAP_WAPI_WORKITEMS_TO_OBJECT’

    EXPORTING

      objtype                  = ‘FIPP’

      objkey                   = l_object_key

      top_level_items          = ‘ ‘

      selection_status_variant = ‘0001’      ” Select only active versions (Running,Ready,Committed ….)

    IMPORTING

      return_code              = l_return_code

    TABLES

      task_filter              = lt_task_filter

      worklist                 = lt_worklist.

  DESCRIBE TABLE lt_worklist LINES l_workflow_count.

* If Active Workflow intance for this Vendor Doc exists

  CHECK l_workflow_count >= 1.

* Doc status changed from COMPLETED TO PARK

  IF ( NOT t_yvbkpf-xprfg IS INITIAL ) AND ( t_xvbkpf-xprfg IS INITIAL ).

    CONCATENATE

               ‘NOTE: This document’s workflows have been deleted.’

               ‘You MUST “Save as Completed” to resend workflows for approval’

    INTO l_text.

    MESSAGE l_text TYPE ‘I’.

* Doc status changed from COMPLETED TO COMPLETED

  ELSEIF ( NOT t_yvbkpf-xprfg IS INITIAL ) AND ( NOT t_xvbkpf-xprfg IS INITIAL ).

*  Custom Message

* Doc status changed from PARK TO COMPLETED

  ELSEIF ( NOT t_xvbkpf-xprfg IS INITIAL ) AND  ( t_yvbkpf-xprfg IS INITIAL ).

*  Custom Message

  ENDIF.

ENDFUNCTION.


  • Save and activate Function ‘ZSAMPLE_INTERFACE_00002217’

  • Code Explanation:


After the BTE implementation, function ‘ZSAMPLE_INTERFACE_00002217’ will be called every time a Vendor Invoice is changed.  The function parameters ‘T_XVBKPF’ and ‘T_XVBSEG’ contain the old document data (header and item details) and ‘T_YVBKPF’ and ‘T_YVBSEG’ contain the new document data. The ‘Completed’ flag can be compared between the old and new data to determine the old and new status of the document. If there is an active Sub-Workflow for the given document, an appropriate message can be generated to alert the processor.

Working Prototype


  • Park a Vendor Invoice via transaction FV60. Then complete the document by clicking ‘SAVE as COMPLETE’ button. This action triggers the Approval Workflow

/wp-content/uploads/2013/11/12_313861.png

 

  • The Approval Work item is sent to Manager

/wp-content/uploads/2013/11/13_313865.png

 

  • At this time, if the Processor goes to transaction FV60 and changes the Vendor Invoice (for e.g.  Invoice reference text from ‘TEST V1’ to ‘TEST V2’), a pop up message alerts the processor.

/wp-content/uploads/2013/11/14_313866.png

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply