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:
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.
Call transaction SE80 and create new function group e.g. ‘ZFI_DOC_CHANGE’.
Call transaction SPRO:
SAP Reference IMG -> Financial Accounting -> Financial Accounting Global Settings -> Business Transaction Events
or
Call transaction FIBF. Choose ‘Products of a Customer’
Function ‘ZSAMPLE_INTERFACE_00002217’
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 |