Skip to Content

ESS-Leave Request hold in background

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Apr 24, 2009 at 07:35 PM

    Hello,

    Please use:

    programming

    but without the spaces before and after } and {

    Testing:

    programming
    

    regards

    Rick Bakker

    Hanabi Technology

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 24, 2009 at 07:57 AM
    COMMIT WORK AND WAIT

    Why do you wait ? after COMMIT WORK

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.