Skip to Content

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

  • Call transaction SE11 , enter table name as BKPF and click on ‘Append Structure’

/wp-content/uploads/2013/07/1_249200.jpg

  • Provide a Z structure name on the subsequent popup

/wp-content/uploads/2013/07/2_249201.jpg

  • Create structure with single field ‘FINAL_APPROVER’ (This structure can have additional Approver fields if the number of Approval levels is fixed.)

/wp-content/uploads/2013/07/3_249202.jpg

  • Save and activate

/wp-content/uploads/2013/07/4_249203.jpg

Extend BKPF_SUBST structure


During posting of FI document, all fields from BKPF_SUBST structure are transferred to BKPF structure. Perform the following steps to add new field ‘Final Approver’ to BKPF_SUBST table

  • Call transaction SE11, enter structure name as BKPF_SUBST and click on ‘Append Structure’.

/wp-content/uploads/2013/07/5_249204.jpg

 

  • Provide a Z structure name on the subsequent popup

/wp-content/uploads/2013/07/6_249205.jpg

  • Create another structure with single field ‘FINAL_APPROVER’ (This structure can have additional Approver fields if the number of Approval levels is fixed.)

/wp-content/uploads/2013/07/7_249206.jpg

  • Save and activate

/wp-content/uploads/2013/07/8_249207.jpg

 

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.

/wp-content/uploads/2013/07/9_249208.jpg

  • Create function ‘ZSAMPLE_PROCESS_00001120’ as a copy of ‘SAMPLE_PROCESS_00001120’
    • Call transaction SE80 and create new function group e.g. ‘ZFI_DOC_POSTING’. Click YES on confirmation pop up. Save and activate function group

/wp-content/uploads/2013/07/10_249210.jpg/wp-content/uploads/2013/07/11_249211.jpg

/wp-content/uploads/2013/07/12_249212.jpg

    • Call transaction SE37 , enter ‘from Function’ name as ‘SAMPLE_PROCESS_00001120’
    • Click Copy Icon and specify ‘ZSAMPLE_PROCESS_00001120’ as ‘to Function’

/wp-content/uploads/2013/07/13_249213.jpg

  • 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/07/14_249214.jpg

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

/wp-content/uploads/2013/07/15_249215.jpg

    • Next, choose ‘ Process Modules of a Customer’

/wp-content/uploads/2013/07/16_249216.jpg

 

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

/wp-content/uploads/2013/07/17_249217.jpg

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.

Working Prototype


  • Park a Journal Entry via transaction FV50. Then complete the document by clicking ‘SAVE as COMPLETE’ button and trigger Approval Workflow

/wp-content/uploads/2013/07/18_249218.jpg

 

  • The Approval Work item is sent to Manager

/wp-content/uploads/2013/07/19_249219.jpg

 

  • The Approver (Manager) can then release the document from SAP inbox (transaction SBWP)

/wp-content/uploads/2013/07/20_249220.jpg

  • Document 101265204 gets posted by Workflow

/wp-content/uploads/2013/07/21_249221.jpg

/wp-content/uploads/2013/07/22_249222.jpg

  • Final Approver is captured on BKPF table entry

/wp-content/uploads/2013/07/23_249223.jpg

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