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’

                      EXPORTING

                           EBELN          = PO Number

                           WAIT          = ‘1’  

                      EXCEPTIONS

                         FOREIGN_LOCK   = 2

                         SYSTEM_FAILURE = 3

                         OTHERS         = 3.

                 IF sysubrc IS INITIAL.

                     CALL FUNCTION ‘DEQUEUE_EMEKKOE’

                     EXPORTING

                     EBELN          = PO Number

                      EXIT.

                 ENDIF.

                 ENDDO.

                CALL FUNCTION ‘BAPI_PO_RESET_RELEASE‘.

               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. 

    

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. shaiksha vali

    Hi Needhi,

    Thanks for your excellent blog..I am facing same issue(Condition records table KONV not updating while using badi ME_PURCHDOC_POSTED).

    Now I have implemented same as you mentioned. My issues got solved.

    Regards,

    Shaiksha Vali.

    (0) 
    1. Jinn Hu

      Hello Shaiksha,

      We’ve met same issue. But we can’t find one good place in program LMEGUICJI to create the implicit enhancement. Would you please kindly share your experience?

      (0) 
      1. Jinn Hu

        The problem is solved. With help from ABAP, I can see the implicit enhancement position in the end of method SAVE of program LMEGUICJI.

        Thanks a lot for the information!

        (0) 
        1. shaiksha vali

          Hello Jinn Hu,

          FYI, I have return the implicit enhancement in the following area. It’s working fine in production.

          Class CL_OS_CA_COMMON, Interface IF_OS_CA_SERVICE, Method PREPARE_FOR_TOP_TRANSACTION -> Created Implicit enhancement.

          Regards,

          Shaiksha Vali.

          (0) 

Leave a Reply