Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 
Former Member

Q : Reset the release strategy / indicator if any thing is changed in PO / Contract

Solution : Step 1 ) Create implementation of BADI ME_PURCHDOC_POSTED.               

               Step 2 ) In method posted, write the code to check if any modification is made in PO / Contract.               

               Step 3) If any modification is made, set the flag say, LV_FLAG = 'X'.               

               Step 4) Pass this flag to implicit enhancement for PO/Contract using EXPORT  TO MEMORY ID.                          

                         (Create implicit enhancement for PO / Contract as mentioned below )                           

                        PO -> Program- LMEGUICJI                           

                        Contract -> Class - CL_OS_CA_COMMON

                                         Method - IF_OS_CA_SERVICE~PREPARE_FOR_TOP_TRANSACTION            

               Step 5) In the Implicit Enhancement, import the flag (Step 4) using IMPORT <x> FROM MEMORY ID.            

               Step 6) Check if LV_FLAG is set (='X').If yes, call the BAPI_PO_RESET_RELEASE to reset the release indicator. 

        Important Note 1 :

             -  After implementing this solution some times you may get the error message as 'Use XXX is already processing Document YYY'.  

             -  This error occurs, because the table EKKO is locked by the system for updating the PO / Contract changes in database. 

             -  And, BAPI 'BAPI_PO_RESET_RELEASE ' is getting called before checking whether the table is locked or released.

              -  The solution to this is, call the below code in Implicit Enhancement before calling BAPI_PO_RESET_RELEASE.

                  DO.   "loop until the lock is released by system

                       CALL FUNCTION 'ENQUEUE_EMEKKOE'


                           EBELN          = PO Number

                           WAIT          = '1'  


                         FOREIGN_LOCK   = 2

                         SYSTEM_FAILURE = 3

                         OTHERS         = 3.

                 IF sy-subrc IS INITIAL.

                     CALL FUNCTION 'DEQUEUE_EMEKKOE'


                     EBELN          = PO Number





               This will ensure that the BAPI is always called when the table EKKO is in released state.

     Important Note 2 :

               - 'BAPI_PO_RESET_RELEASE' will not work for the documents which has already been printed out.

                - In this BAPI  the records from NAST are fetched & variable printed is set to 'X'.

                - printed = 'X' does not allow the PO/ Contract release strategy to get reset for already printed documents.

                - Solution to this is create a Z BAPI which will be a copy of  standard BAPI 'BAPI_PO_RESET_RELEASE'.

               -  In this BAPI clear the variable printed before calling FM ''ME_REL_RESET".

         Note :  Reason for creating Implicit Enhancement :      

              - If we directly call the BAPI_PO_RESET_RELEASE inside the BADI  ME_PURCHDOC_POSTED implementation.

                It will reset the release strategy but it will interrupt the normal SAVE process of PO / Contract

              - Any other changes made in PO/Contract will not get saved.

              - So, using Implicit Enhancement will ensure that the changes made in PO/ Contract are saved first & then the release strategy is reset.