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.
- This solution helps to prevent inadvertent/uninformed interference of the Approval process by the processor.
- 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.
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.
Implement Business Transaction Event (Process interface 2217)
BTE 2217 can be used to determine whether the FI document goes from COMPLETED to PARKED status.
- 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’.
- Click YES on confirmation pop up. Save and activate function group
- 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.
- Configure BTE
Call transaction SPRO:
SAP Reference IMG -> Financial Accounting -> Financial Accounting Global Settings -> Business Transaction Events
Call transaction FIBF. Choose ‘Products of a Customer’
- Add New Entry for Product ‘ZFI_CHG’, description and SET the active flag. Save the new product.
- Next, choose ‘P/S Modules of a Customer’
- Add New Entry for BTE – 2217. Use the function name and Product created in previous steps. Save the new entry.
- Call transaction SE37 and open function ‘ZSAMPLE_INTERFACE_00002217’ in change mode.
*” REFERENCE(E_SUBRC) TYPE SYSUBRC
*” T_XVBKPF STRUCTURE FVBKPF
*” T_XVBSEG STRUCTURE FVBSEG
*” T_YVBKPF STRUCTURE FVBKPF
*” T_YVBSEG STRUCTURE FVBSEG
* Data Declaration
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.
* Set up the TASK_FILTER – Approval Sub-Workflow template
APPEND ‘WS99000007’ TO lt_task_filter.
* Check if atleast one Sub Workflow instance already exists – for the current KR doc
CALL FUNCTION ‘SAP_WAPI_WORKITEMS_TO_OBJECT’
objtype = ‘FIPP’
objkey = l_object_key
top_level_items = ‘ ‘
selection_status_variant = ‘0001’ ” Select only active versions (Running,Ready,Committed ….)
return_code = l_return_code
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 ).
‘NOTE: This document’s workflows have been deleted.’
‘You MUST “Save as Completed” to resend workflows for approval’
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
- 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.
- Park a Vendor Invoice via transaction FV60. Then complete the document by clicking ‘SAVE as COMPLETE’ button. This action triggers the Approval Workflow
- The Approval Work item is sent to Manager
- 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.