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: 
jayesh_mudaliar
Explorer
0 Kudos


Please go through the Part 1 Forward Button customization for better understanding.

Many time there are custom requirements for which it requires the need of creating Enhancement in standard SAP functionality.

Overview : PO Approvers are maintained in Release Strategy. Once the PO is generated it is set to be approved by PO approvers based on the levels maintained in PPOME structure. Only then the PO will be set to 03 status in EKKO.

Pre-requisite : All the roles and authorization must be given to the approvers to access the PO Approval Tile in SAP Fiori.

Requirement :  If the approver find the PO is incorrect, he will reject the PO. The rejection of PO must contain the rejection text. Since the Text is an optional there comes up the challenge to make it mandatory.

jayesh_mudaliar_0-1714728155246.png

Solution: 

There are many ways to do this 
1. Doing changes in Front-End using BTP/WEB IDE.

2. Making it mandatory from ECC

I chose the 2nd method since there was some issue in licensing the BTP and it was not configured correctly.

Making it mandatory from ECC


My PO tile looks like this 

jayesh_mudaliar_1-1714728363065.png

When the approver click on the Reject button , he must enter the Rejection note. If he doesn't then the PO should not be rejected.

jayesh_mudaliar_0-1714728155246.png

SAP has provided only few objects which can be modified without the BTP framework. PO Approval is one of it. The main thing to note and find the Odata.


How to find the OData which will can be used for my development?
You can find the OData from going to Fiori tile -> Do Frontend debugging-> Refresh the page-> Navigate to Network Tab -> Find Path starting with key words /sap/opu/odata

In my case the OData is GBAPP_POAPPROVAL
/sap/opu/odata/SAP/GBAPP_POAPPROVAL

jayesh_mudaliar_4-1714730619543.png

You can also find it through the XML file 

jayesh_mudaliar_5-1714730797939.png

Now you have the Standard OData name, it must be implemented so that it could connect with the backend system by providing the system name in External system. 

Odata Implementation: The ODATA deployment is Central HUB . We have separate GW systems for hosting Fiori Tiles.

Tcode : /n/iwfnd/maint_service

jayesh_mudaliar_2-1714729367937.png

jayesh_mudaliar_3-1714729398317.png

jayesh_mudaliar_7-1714731093754.png

Now one must get 200 response after connecting it with backend system. 
Tcode : /n/iwfnd/gw_client

jayesh_mudaliar_8-1714731232808.png

Till now OData is successfully configured. Now its time to find the BADI in ECC system to implement. This can be found in my previous Blog
Let me directly jump to the method which would be required to implement.
The method is Change SET_DECISION method

jayesh_mudaliar_9-1714731665289.png

Here the SAP Standard documentation is pretty clear about the way of processing. You can go through it.

jayesh_mudaliar_10-1714731777859.png

Accept : iv_decision = 1.
Reject : iv_decision  = 2.
If you want nothing should happen mark ev_decision_processed 'X'. 

METHOD IF_GBAPP_EX_APV_PO_RDP~CHANGE_SET_DECISION.
" Standard Documentation: Do not delete

* This method can be used to enable execution of a workitem
* without updating a purchase order. The customer should
* implement the method and call a corresponding function to execute
* the workitem followed by COMMIT WORK.
* To avoid update of the purchase order, it is necessary to set the
* output parameter EV_DECISION_PROCESSED to 'X'.
* Preventing update of a document can be necessary, if the customer
* uses his own workflow where update of purchase order takes place
* in a separate background workflow step.
  IF iv_decision EQ 2.
    IF iv_rejection_text IS INITIAL.
      ev_decision_processed 'X'.
    ELSE.
      DATA t_return TYPE STANDARD TABLE OF  BAPIRET2.
      CALL FUNCTION 'ZFIORI_PO_APPROVAL_REJ_CHG' IN UPDATE TASK
        EXPORTING
          iv_ebeln iv_pc_number
        TABLES
          t_return t_return.
      COMMIT WORK.
    ENDIF.
  ENDIF.
ENDMETHOD.


As per my requirement if the approver accept I should not check anything and simply make it happen, hence I have not done anything with iv_decision = 1. If you want, you can add your custom requirement under it. 
For me I have marked ev_decision_processed 'X', if rejection text/ note in not provided.
I have used a Update Task FM because these were the async call hence the system was giving dump while updating the EKKO. So as to correct this I have divided it in 2 Logical unit. A wait of 5 secs have introduced so that the previous task gets over.

jayesh_mudaliar_12-1714732313298.png


FUNCTION zfiori_po_approval_rej_chg.
*"----------------------------------------------------------------------
*"*"Update Function Module:
*"
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IV_EBELN) TYPE  EBELN
*"  TABLES
*"      T_RETURN STRUCTURE  BAPIRET2
*"----------------------------------------------------------------------
*"*"Update Function Module:
  WAIT UP TO SECONDS.
  DATAlr_po           TYPE REF TO cl_po_header_handle_mm,
        ls_bapi         TYPE bapiret2,
        l_result        TYPE mmpur_bool,
        lv_procstat     TYPE ekko-procstat,
        ls_document     TYPE mepo_document.
  CONSTANTSlc_status TYPE ekko-procstat VALUE '08',
             lc_set_status TYPE ekko-procstat VALUE '03',
             lc_process TYPE char16 VALUE 'PO_PROCESS',
*             lc_trtyp TYPE char1 VALUE 'VER',
*             lc_trtyp TYPE char1 VALUE 'V',
             lc_ind TYPE char40 VALUE 'RELEASE',
             lc_tcode TYPE SY-TCODE VALUE 'ME29N'.


  SELECT SINGLE procstat FROM ekko INTO lv_procstat WHERE ebeln =  iv_ebeln.
  IF lv_procstat EQ lc_status.
*  prepare creation of PO instance
    ls_document-process     'PO_PROCESS'.
    ls_document-trtyp       'VER'.
    ls_document-doc_key(10iv_ebeln.
    ls_document-initiator-initiator 'RELEASE'.

    CREATE OBJECT lr_po.
    lr_po->for_bapi 'X'.
    lr_po->po_initializels_document ).
    lr_po->set_po_numberiv_ebeln ).


    CALL FUNCTION 'MEPO_DOC_READ'
      EXPORTING
        im_ebeln                       iv_ebeln
        im_tcode                       lc_tcode"'ME29N'
        im_trtyp                       ls_document-trtyp
*    IM_ID                          =
        im_document                    ls_document
*   IM_NO_MESSAGING                =
*   IM_NO_MESSAGE_REQ              =
*   IM_NO_AUTHORITY                =
* EXCEPTIONS
*   DOC_NUMBER_MISSING             = 1
*   TRANSACTION_CODE_MISSING       = 2
*   TRANSACTION_TYPE_MISSING       = 3
*   INVALID_CALL                   = 4
*   OTHERS                         = 5
              .
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.
    DATA ex_data  LIKE  mepoheader.
    CALL FUNCTION 'MEPO_DOC_HEADER_GET'
      IMPORTING
        ex_ekko ex_data.

    IF cl_process_state_mm=>is_allowed(
                     im_bstyp   ex_data-bstyp
                     im_state   ex_data-procstat
                     im_process cl_process_state_mm=>c_pr_reset_rej )
                                                          EQ mmpur_no.
      MESSAGE e806(mepoWITH ex_data-procstat RAISING failed.
    ENDIF.
    ex_data-procstat cl_process_state_mm=>c_active.
    lr_po->set_dataex_data ).


    UPDATE ekko SET procstat lc_set_status WHERE ebeln EQ iv_ebeln.
*    UPDATE ekko SET PROCSTAT = ex_data-procstat where ebeln eq iv_ebeln.
  ENDIF.

ENDFUNCTION.

Labels in this area