Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

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’

  • 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 of Approval levels is fixed.)

  • 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 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’.

 

  • 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 the number of Approval levels is fixed.)

  • Save and activate

 

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

    • Call transaction SE37 , enter ‘from Function’ name as ‘SAMPLE_PROCESS_00001120’

    • Click Copy Icon and specify ‘ZSAMPLE_PROCESS_00001120’ as ‘to Function’

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

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

Working Prototype


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

 

  • The Approval Work item is sent to Manager

 

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

  • Document 101265204 gets posted by Workflow

  • Final Approver is captured on BKPF table entry

Labels in this area