Final Approver of FI Workflow

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 directly led 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 within BKPF (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 details of 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

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

Next, choose ‘ Process Modules of a Customer’

Add New Entry for Process interface – 1120. Use the function name and Product created in previous steps. Save the new entry.

Function ‘ZSAMPLE_PROCESS_00001120’

After the BTE implementation, function ‘ZSAMPLE_PROCESS_00001120’ will be called just before actual Posting of FI document. 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 and then it will be available in BKPF table after Posting.

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

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 record

READ 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-gjahr

INTO l_objkey.

CONDENSE l_objkey.

* Determine Final JE approver from Workflow LOG tables

SELECT wi_aagent wi_cd wi_ct

FROM swivobject

UP TO 1 ROWS

INTO (l_agent,l_wi_cd,l_wi_ct)

WHERE objtype = ‘FIPP’

AND objkey = l_objkey

AND 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 record

READ 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 table

MODIFY t_bkpfsub INDEX 1 FROM l_bkpfsub

TRANSPORTING final_approver.

ENDIF.

ENDIF.

ENDFUNCTION.

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). Task ‘TS00007914’ specifies Approval task and descending SORT by date and time – provides the Final Approver of the Parked Document.