cancel
Showing results for 
Search instead for 
Did you mean: 

ESS-Leave Request hold in background

gerardoperez
Explorer
0 Kudos

Hi.

We have implemented the workflow for leave requests in ESS. But this workflow is customized, because we use more than 2 levels for aprobation.

We created a method for change the records state in table PTREQ_HEADER (according a workkaround suggested in a SDN forum thread)

But the problem is the workflow takes so long time for process this method; and hold in it for hours.

In debugging mode, this method works OK, but in background, hold it.

Would you help us?

Thanks in advance.

Method code:

begin_method zbuscaestado changing container.

DATA: zestado TYPE datatype-char0001,         
      zfinal TYPE datatype-char0001,          
      zregid TYPE ptreq_header-request_id,    
      l_request TYPE ptarq_uia_request,       
      request TYPE REF TO if_pt_req_request,  
      status TYPE tim_req_status,             
      event TYPE tim_req_xfer_event,          
      salir TYPE c.                           
                                              
swc_get_element container 'ZEstado' zestado.  
swc_get_element container 'ZRegID' zregid.    
swc_get_element container 'ZFinal' zfinal.                                                                                
MOVE space TO zestado.                                                                                
SELECT SINGLE *                                     
  FROM ptreq_header                                 
    WHERE request_id EQ zregid                      
    AND   status EQ 'APPROVED'.                     
                                                    
IF sy-subrc EQ 0.                                   
  MOVE 'A' TO zestado.                              
*    MOVE 'X' TO salir.                             
  IF zfinal NE 'S'.                                                                                
MOVE cl_pt_req_const=>c_reqtrans_send TO event.
    CALL FUNCTION 'ENQUEUE_EPTREQ'                   
      EXPORTING                                      
        mode_ptreq_header = 'E'                      
        request_id        = zregid                   
      EXCEPTIONS                                     
        foreign_lock      = 1                        
        system_failure    = 2                        
        OTHERS            = 3.                                                                                
CALL METHOD ca_pt_req_header=>agent->get_request 
      EXPORTING                                      
        im_request_id = zregid                       
      IMPORTING                                      
        ex_request    = request.                                                                                
CALL METHOD request->initiate_state_transition   
      EXPORTING                                      
        im_transfer_event = event                    
*      im_event          = event                     
        im_external_call = space                     
*        im_ret_value      = 0                       
      IMPORTING                                      
        ex_new_status     = status.                  
                                       
    CALL FUNCTION 'DEQUEUE_EPTREQ'                   
      EXPORTING                                      
        request_id = zregid.                                                                                
ENDIF.                                                                                
ELSE.                                                                                
SELECT SINGLE *                                    
    FROM ptreq_header                                
      WHERE request_id EQ zregid                     
      AND   status EQ 'REJECTED'.                    
                                                     
  IF sy-subrc EQ 0.                                  
    MOVE 'R' TO zestado.                             
*      MOVE 'X' TO salir.                            
    MOVE cl_pt_req_const=>c_reqtrans_delete TO event.

    CALL FUNCTION 'ENQUEUE_EPTREQ'                   
      EXPORTING                                      
        mode_ptreq_header = 'E'                      
        request_id        = zregid                   
      EXCEPTIONS                                     
        foreign_lock      = 1                        
        system_failure    = 2                        
        OTHERS            = 3.                                                                                
CALL METHOD ca_pt_req_header=>agent->get_request 
      EXPORTING                                      
        im_request_id = zregid                       
      IMPORTING                                      
        ex_request    = request.                                                                                
CALL METHOD request->initiate_state_transition   
      EXPORTING                                      
        im_transfer_event = event                    
*      im_event          = event                     
        im_external_call = space                     
*        im_ret_value      = 0                       
      IMPORTING                                      
        ex_new_status     = status.         
         
     CALL FUNCTION 'DEQUEUE_EPTREQ'              
       EXPORTING                                 
         request_id = zregid.                    
                                                 
 *    ELSE.                                      
 *      CLEAR salir.                             
   ENDIF.                                                                                
ENDIF.                                                                                
COMMIT WORK AND WAIT.                                                                                
swc_set_element container 'ZEstado' zestado.    
                                                 
 end_method.

Edited by: Gerardo Perez on Apr 24, 2009 2:29 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

bpawanchand
Active Contributor
0 Kudos
COMMIT WORK AND WAIT

Why do you wait ? after COMMIT WORK

former_member185167
Active Contributor
0 Kudos

Hello,

Please use:

programming

but without the spaces before and after } and {

Testing:


programming

regards

Rick Bakker

Hanabi Technology

gerardoperez
Explorer
0 Kudos

Sorry, I am using this option (to display as code) but is not working I think.

regards,