7/28/2019 Business Scenario Approver of Fi in Workflow
1/10
Business Scenario:
The SAP system must record the initiator and the final approver for financial transactions that go through workflow for posting.
These fields must describe for each posting the individual who parked the entry as well as the individual whose approval directlyled to the posting of the entry. The Final Approver is the individual who is ultimately responsible for the individual posting and
by approval has also approved the attached supporting documentation.This information is either available within Approval Sub-Workflow container or it can be viewed separately for each FI
document in transactions FBV3 or FB03 from the workflow protocol via the generic object services.
This document provides a custom solution to this requirement. It is possible to capture the final level Workflow Approver withinBKPF (Accounting Document Header) table.
Benefits:
If a future question concerning the posting occurs due to audit, the Final Approver is the person contacted to describe the detailsof the entry.
It provides an ability to check whether the initiator of the document and the final approver is the same individual.Extend BKPF table structure
Perform the following steps to add new field Final Approver to BKPF table
Call transaction SE11 , enter table name as BKPF and click on Append Structure
Provide a Z structure name on the subsequent popup
Create structure with single field FINAL_APPROVER (This structure can have additional Approver fields if the number ofApproval levels is fixed.)
http://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249201/2.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249200/1.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249201/2.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249200/1.jpg7/28/2019 Business Scenario Approver of Fi in Workflow
2/10
Save and activate
Extend BKPF_SUBST structure
During posting of FI document, all fields from BKPF_SUBST structure are transferred to BKPF structure. Perform the followingsteps to add new field Final Approver to BKPF_SUBST table
Call transaction SE11, enter structure name as BKPF_SUBST and click on Append Structure.
http://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249203/4.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249202/3.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249203/4.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249202/3.jpg7/28/2019 Business Scenario Approver of Fi in Workflow
3/10
Provide a Z structure name on the subsequent popup
Create another structure with single field FINAL_APPROVER (This structure can have additional Approver fields if thenumber of Approval levels is fixed.)
Save and activate
http://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249206/7.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249205/6.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249204/5.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249206/7.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249205/6.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249204/5.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249206/7.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249205/6.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249204/5.jpg7/28/2019 Business Scenario Approver of Fi in Workflow
4/10
Now both BKPF and BKPF_SUBST structures have new field FINAL_APPROVER.
Implement Business Transaction Event (Process interface 1120)
BTE 1120 can be used to populate the fields of structure BKPF_SUBST, which are eventually transferred to BKPF table.
Create function ZSAMPLE_PROCESS_00001120 as a copy of SAMPLE_PROCESS_00001120o Call transaction SE80 and create new function group e.g. ZFI_DOC_POSTING. Click YES on confirmation pop up. Save and
activate function group
http://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249208/9.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249207/8.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249208/9.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249207/8.jpg7/28/2019 Business Scenario Approver of Fi in Workflow
5/10
o Call transaction SE37 , enter from Function name as SAMPLE_PROCESS_00001120o Click Copy Icon and specify ZSAMPLE_PROCESS_00001120 as to Function
Configure BTEo Call transaction SPRO
SAP Reference IMG -> Financial Accounting -> Financial Accounting Global Settings -> Business
Transaction Eventsor
o Call transaction FIBF. Choose Products of a Customer
http://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249213/13.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249212/12.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249211/11.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249210/10.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249213/13.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249212/12.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249211/11.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249210/10.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249213/13.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249212/12.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249211/11.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249210/10.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249213/13.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249212/12.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249211/11.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249210/10.jpg7/28/2019 Business Scenario Approver of Fi in Workflow
6/10
7/28/2019 Business Scenario Approver of Fi in Workflow
7/10
Function ZSAMPLE_PROCESS_00001120
After the BTE implementation, function ZSAMPLE_PROCESS_00001120 will be called just before actual Posting of FIdocument. BTE 1120 provides us the facility of substituting BKPF fields from BKPF_SUBST structure. So if we determine and
populate the final approver in T_BKPFSUB, this value will be moved from T_BKPFSUB to T_BKPF table before posting andthen it will be available in BKPF table after Posting.
o Call transaction SE37 and open function ZSAMPLE_PROCESS_00001120 in change mode.o Write the following sample code:
FUNCTION zsample_process_00001120.*"-------------------------------------------------------------- *"*"Local Interface:*" IMPORTING*" VALUE(I_BKDF) TYPE BKDF OPTIONAL*" TABLES*" T_BKPF STRUCTURE BKPF*" T_BSEG STRUCTURE BSEG*" T_BKPFSUB STRUCTURE BKPF_SUBST
*" T_BSEGSUB STRUCTURE BSEG_SUBST*" T_BSEC STRUCTURE BSEC OPTIONAL*" CHANGING*" REFERENCE(I_BKDFSUB) TYPE BKDF_SUBST OPTIONAL*"--------------------------------------------------------------
DATA :l_bkpfsub TYPE bkpf_subst, l_bkpf TYPE bkpf.
DATA :l_agent TYPE sww_aagent, l_wi_cd TYPE sww_cd,l_wi_ct TYPE sww_ct,l_objkey TYPE swo_typeid.
CLEAR :l_agent.
* Read BKPF recordREAD TABLE t_bkpf INTO l_bkpf INDEX 1.
CHECK sy-subrc EQ 0.
CLEAR l_objkey.
CONCATENATE l_bkpf-bukrs l_bkpf-belnr l_bkpf-gjahrINTO l_objkey.
CONDENSE l_objkey.
* Determine Final JE approver from Workflow LOG tables
SELECT wi_aagent wi_cd wi_ctFROM swivobject
UP TO 1 ROWSINTO (l_agent,l_wi_cd,l_wi_ct)WHERE objtype = 'FIPP'
7/28/2019 Business Scenario Approver of Fi in Workflow
8/10
AND objkey = l_objkeyAND wi_type = 'W'AND wi_stat = 'COMPLETED'AND wi_rh_task = 'TS00007914'
ORDER BY wi_cd DESCENDING wi_ct DESCENDING.ENDSELECT.
IF NOT l_agent IS INITIAL.
* Read BKPF substitute recordREAD TABLE t_bkpfsub INTO l_bkpfsub INDEX 1.
IF sy-subrc EQ 0.
MOVE l_agent TO l_bkpfsub-final_approver.
* Update the BKPF substitute tableMODIFY t_bkpfsub INDEX 1 FROM l_bkpfsubTRANSPORTING final_approver.
ENDIF.
ENDIF.
ENDFUNCTION.
o Save and activate Function ZSAMPLE_PROCESS_00001120 Code Explanation:
Database view SWIVOBJECT provides all the work item headers for workflows linked to the parked document (FIPP). TaskTS00007914 specifies Approval task and descending SORT by date and time provides the Final Approver of the ParkedDocument.
Working Prototype
Park a Journal Entry via transaction FV50. Then complete the document by clicking SAVE as COMPLETE button and triggerApproval Workflow
The Approval Work item is sent to Manager
http://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249218/18.jpg7/28/2019 Business Scenario Approver of Fi in Workflow
9/10
The Approver (Manager) can then release the document from SAP inbox (transaction SBWP)
Document 101265204 gets posted by Workflow
http://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249220/20.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249219/19.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249220/20.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249219/19.jpg7/28/2019 Business Scenario Approver of Fi in Workflow
10/10
Final Approver is captured on BKPF table entry
http://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249223/23.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249222/22.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249221/21.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249223/23.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249222/22.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249221/21.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249223/23.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249222/22.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/102-44277-2-249221/21.jpg