Hi Friends,

We all know that in MM, a Contract is not a legal document. Hence standard SAP transaction ME35K for releasing the Contract does not provide any provision for rejecting it. But in our experience, we may have to face a situation from the client that, they want a provision for rejecting the contract from ME35K (even after explaining the business purpose of a contract) from within a workflow. Recently, I had to face such a situation where the client wants to reject the contract similar to what they can do for a Purchase Order or for a Purchase Requisition in their respective workflows. We tried our level best to defend, but they were adamant on their requirement.


I searched a lot in internet as well as on SDN, but was unable to find any standard solution for this. So I came up with an idea that, we will build a custom rejection scenario in Contract approval process and this is working well. This will not tamper the standard approval process and will not touch the standard tables EKKO and EKPO. This was achieved with the help of a Z table for maintaining the rejection details and some implicit enhancements built into the program RM06EF00.


I thought that sharing this will help others to tackle this situation. The step by step procedure for this is explained below.


Step-1:

Create a Z table for storing the rejection details of a Contract, so that this can used later for giving validations like Contract should not be changed during approval process etc. The table  should contain the following fields.

Capture1.JPG

In our example the table name is ZMMH005.

Step-2:

We have to add an additional button to the list output for transaction ME35K for rejection and can hide some buttons already available. The standard output of ME35K for a particular release code is shown below.

Capture2.JPG

To add a new button we need to identify the GUI Status. This can be obtained by going to the menu System->Status from the above screen. This will give the standard status as FREI which contains the following application toolbar items.

Capture3.JPG

Since this is standard we can not change. So we need to copy this status into a Z one as ZFREI into some dummy program ZABI_MM_TEST1. Then it is possible to add or delete application toolbar items of ZFREI. Into the GUI Status ZFREI, I had added a new item called REJT and removed the standard ones like FRGS, FRGR, PREV & FREI.

Capture4.JPG


Step-3:

The new GUI Status need to be called from within the standard program RM06EF00, so that this will overwrite the standard GUI Status FREI. Within the program RM06EF00, we can see that after the START_OF_SELECTION event, the standard GUI Status is being set(in line no 176). After that, we can see a perform frg_init, in which we will create an implicit enhancement and will set the custom GUI Status ZFREI.


For learning how to IMPLICIT ENHANCEMENT you can refer this thread http://wiki.sdn.sap.com/wiki/display/ABAP/How+To+Do+Implicit+Enhancement


This is done as follows:

Capture5.JPG

After this, the standard output of ME35K for a particular release code will be changed as below.

Capture6.JPG


Step-4:

We had to write code for the rejection. This is done with another enhancement implementation. Under the event AT USER-COMMAND, we can see a perform user_command. Inside this form routine, we will be able find an enhancement spot called ES_SAPFM06L. Create an implementation for this spot and write the code corresponding to rejection.


Since the release happens from a workflow, while coding in this enhancement we should write code to insert values into table ZMMH005(created in step-1), trigger the event SIGNIFICANTLYCHANGED of business object BUS2014 and another custom event of a custom class if some rejection mails need to be send to the initiator through another custom workflow.All these code is given below.


ENHANCEMENT ZMM_ENH02.    “active version
 
CASE syucomm.

        WHEN ‘REJT’.
     
READ TABLE fekko WITH KEY hidkebeln BINARY SEARCH.
     
IF sysubrc = 0.
      
DATA : objkey     TYPE swo_typeid,
             lt_input  
TYPE TABLE OF swr_cont,
             wa_input  
LIKE LINE OF lt_input,
             wa_zmmh005
TYPE zmmh005,
             wa_ekko   
TYPE ekko,
             wa_t16fw  
TYPE t16fW.

       SELECT SINGLE * FROM ekko INTO wa_ekko WHERE ebeln = hidkebeln.
      
IF sysubrc = 0.
        
SELECT SINGLE * FROM t16fw INTO wa_t16fw
          
WHERE frggr = wa_ekkofrggr AND otype = ‘US’ AND objid = syuname.
        
IF sysubrc = 0.
           objkey
= hidkebeln.
           wa_input
element  = ‘ReleaseCode’.
           wa_input
value    = wa_t16fwfrgco.
          
APPEND wa_input TO lt_input.
           *The following event is called so that the workitem disappears from the a
gent’s inbox.

           CALL FUNCTION ‘SAP_WAPI_CREATE_EVENT’
            
EXPORTING
               object_type            
= ‘BUS2014’
               object_key             
= objkey
              
event                   = ‘SIGNIFICANTLYCHANGED’
               commit_work            
= ‘X’
               event_language         
= sylangu
              
language                = sylangu
               user                   
= syuname
            
TABLES
               input_container        
= lt_input.
          
IF sysubrc = 0.
            
SELECT SINGLE * FROM zmmh005 INTO wa_zmmh005 WHERE ebeln = hidkebeln.
            
IF sysubrc = 0.
              
MOVE-CORRESPONDING wa_ekko TO wa_zmmh005.
               wa_zmmh005
procstat = ’08’.

               MODIFY zmmh005 FROM wa_zmmh005.
              
COMMIT WORK.
            
ELSE.
              
MOVE-CORRESPONDING wa_ekko TO wa_zmmh005.
               wa_zmmh005
procstat = ’08’.

               MODIFY zmmh005 FROM wa_zmmh005.
              
COMMIT WORK.
            
ENDIF.

             *This event call is required only if you need to send a mail after the rejection of the contract.
      
CALL METHOD zcl_mm_wf_contract_reject=>raise_event
        
EXPORTING
           i_ebeln
= hidkebeln
           i_event
= ‘REJECT_INIT’.

       MESSAGE ‘Contract rejected successfully !’ TYPE ‘S’.
      
Leave to screen 0.
    
ENDIF.
  
ENDIF.
ENDIF.

ELSE.

        MESSAGE ‘Please choose a valid line’ TYPE ‘S’.

          ENDIF.

     ENDCASE.

ENDENHANCEMENT.


In the above code the class zcl_mm_wf_contract_reject is created for triggering the custom workflow for sending the rejection mail to the initiator. The workflow is configured to be triggered against the REJECT_INIT event of the class. This is required only because, the business object BUS2014 does not contain any event for rejection(such as in case of PO business object BUS2012, REJECTION_START event).


Deatils on how to create a Z class for triggering a workflow can be learned from the following SCN document.

Getting started with ABAP OO for Workflow … using the IF_WORKFLOW interface


Step-5:

The entry that falls into the table ZMMH005, need to be updated while release happens. This can be achieved by creating an implicit implementation in perform FRG_UPDATE before the existing code(line no 103 in the perform user_command). The code to be written is given below:


ENHANCEMENT ZMM_REJECTSTAT_CHANGE.   
“Updating the contract rejection status table with proper process status while Release & Save and while Release + Save
DATA : wa_zmmh005 TYPE zmmh005.
DATA : wa_t16fs type t16fs,
       lv_char 
TYPE c,
       lv_count
type i,
       lv_frgco
type frgco,
       lv_text 
TYPE char5,
       lt_t16fw
type TABLE OF t16fw,
       wa_t16fw
type t16fw.

SELECT * FROM t16fw INTO TABLE lt_t16fw WHERE frggr = ekkofrggr.
IF sysubrc = 0.
  
DESCRIBE TABLE lt_t16fw lines lv_count.
   lv_char
= lv_count.
  
CONCATENATE ‘FRGC’ lv_char INTO lv_text.
  
CONDENSE lv_text.

    SELECT SINGLE (lv_text) FROM t16fs INTO lv_frgco WHERE frggr = ekko-frggr.

      IF sysubrc = 0.

        READ TABLE lt_t16fw INTO wa_t16fw with key frggr = ekkofrggr frgco = lv_frgco.

        IF syuname = wa_t16fwobjid.

          SELECT SINGLE * FROM zmmh005 INTO wa_zmmh005 WHERE ebeln = ekkoebeln .

          IF sysubrc = 0.

       wa_zmmh005procstat = ’05’.

              MODIFY zmmh005 FROM wa_zmmh005 .

          ENDIF.

       ELSE.

           SELECT SINGLE * FROM zmmh005 INTO wa_zmmh005 WHERE ebeln = ekkoebeln.

           IF sysubrc = 0.

       wa_zmmh005procstat = ’03’.

              MODIFY zmmh005 FROM wa_zmmh005 .

           ENDIF.

        ENDIF.

      ENDIF.

   ENDIF.

ENDENHANCEMENT.


Step-6:

The following piece of code can written in exit EXIT_SAPMM06E_012 of MM06E005 for preventing any changes to the contract during approval process.


DATA: wa_zmmh005 TYPE zmmh005.
DATA: wa_ekko1 TYPE ekko.
DATA: wa_ekpo_app TYPE ekpo.

READ TABLE tekpo INTO wa_ekpo_app INDEX 1.
IF sysubrc = 0.
IF sytcode = ‘ME31K’ OR sytcode = ‘ME32K’ OR sytcode = ‘ME33K’.
  
SELECT SINGLE * FROM zmmh005 INTO wa_zmmh005 WHERE ebeln = wa_ekpo_appebeln.

      IF sysubrc = 0.

         IF wa_zmmh005frgke = ‘B’.

           IF wa_zmmh005procstat = ’03’.

MESSAGE e000(zmm00).
    
ENDIF.
   
ENDIF.
ELSE.
  
SELECT SINGLE * FROM ekko INTO wa_ekko1 WHERE ebeln = wa_ekpo_appebeln.

IF sysubrc = 0.

  IF wa_ekko1frgke = ‘B’.

     IF wa_ekko1procstat = ’03’.

MESSAGE e000(zmm00).
  
ENDIF.
ENDIF.
ENDIF.
ENDIF.

ENDIF.
ENDIF.


To report this post you need to login first.

2 Comments

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

  1. Projeto CSC

    Dear greetings Abijith Chandra ,
    I will implement and test. Unfortunately many companies do not understand the concept of the legal document. Congratulations for the initiative.

    Ubirajara Novaes

    (0) 

Leave a Reply