cancel
Showing results for 
Search instead for 
Did you mean: 

regarding the change status of leave workflow.

Former Member
0 Kudos

hi friends,

i have copied the standard leave worklfow "WS12300111" and customized it just to meet our requirement means for multiple approvers.

everything is working fine in production means if user ID "AIHR01' raise a leave request the workitem will go to "AIHR02" after his approving the workitem will go to the final approver means "AIHR03" after his approval the leave request will be completed and the status in the TC - PTARQ is coming as "APPROVED" means only after the approving of "AIHR03" the status is coming "APPROVED" but in some cases when user id "AIHR02" is approved instead of coming status "SENT" it is coming "APPROVED" in TC-PTARQ and because of this status the workitem is coming blank in UWL of "AIHR03".

I have already incorporated the given below method in the "WORKFLOW" just to change the status from "APPROVED" to "SENT" after the approval of user ID "AIHR02" but in some cases it is not working fine it is giving BUG.

-


begin_method changestatus changing container.

DATA:request TYPE ptreq_header-request_id,

wi_id TYPE swwwihead-wi_id.

DATA: request_instance TYPE REF TO if_pt_req_request,

event TYPE tim_req_xfer_event VALUE

cl_pt_req_const=>c_reqtrans_send,

ex_status TYPE tim_req_status,

container_wi TYPE swcont OCCURS 0,

agents TYPE STANDARD TABLE OF swhactor WITH HEADER LINE.

swc_get_element container 'REQUEST' request.

swc_get_element container 'Wi_id' wi_id.

DO.

CALL FUNCTION 'ENQUEUE_EPTREQ'

EXPORTING

  • MODE_PTREQ_HEADER = 'S'

  • MANDT = SY-MANDT

request_id = request

  • X_REQUEST_ID = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3

.

IF sy-subrc = 0.

EXIT.

ENDIF.

WAIT UP TO 60 SECONDS.

ENDDO.

IF sy-subrc = 0.

CALL METHOD ca_pt_req_header=>agent->get_request

EXPORTING

im_request_id = request

IMPORTING

ex_request = request_instance

EXCEPTIONS

request_not_found = 1

OTHERS = 2.

IF sy-subrc = 0.

CALL METHOD request_instance->initiate_state_trans

EXPORTING

im_transfer_event = event

im_external_call = 'X'

  • im_ret_value = 0

ex_new_status = ex_status

  • ex_ret_code =

.

swc_set_element container 'Ex_Status' ex_status.

ENDIF.

CALL FUNCTION 'DEQUEUE_EPTREQ'

EXPORTING

  • MODE_PTREQ_HEADER = 'S'

  • MANDT = SY-MANDT

request_id = request

  • X_REQUEST_ID = ' '

  • _SCOPE = '3'

  • _SYNCHRON = ' '

  • _COLLECT = ' '

.

ENDIF.

swc_create_container container_wi.

swc_set_element container_wi 'WI_ID' wi_id.

agents-otype = 'US'.

agents-objid = sy-uname.

APPEND agents.

CALL FUNCTION 'SWW_WI_START_SIMPLE'

EXPORTING

task = 'TS90000089'

called_in_background = 'X'

TABLES

agents = agents

wi_container = container_wi

EXCEPTIONS

id_not_created = 1

read_failed = 2

immediate_start_not_possible = 3

execution_failed = 4

invalid_status = 5

OTHERS = 6.

end_method.

-


Request you to plesase help me to solve this issue .why in some cases instead of coming status "SENT" it is coming "APPROVED" after the approval of user id "AIHR02".

BECAUSE of the "APPROVED" staus the same workitem is coming blank in the UWL OF "AIHR03".

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

solved by own

rammel_sapdev
Explorer
0 Kudos

Hi,

How were you able to solve it? I am having problems also. I am not sure if it is because of the delay in changing form status SENT to APPROVED that is why it is not able to change status from APPROVED to SENT. Please help. Happened twice already, didn't happen for other users. Thanks

Here is my code:

METHOD change_leavereq_status.

   DATA: lr_request        TYPE REF TO if_pt_req_request,

         lv_event_sent     TYPE tim_req_xfer_event VALUE cl_pt_req_const=>c_reqtrans_send,

         lv_status         TYPE tim_req_status,

         lv_enqueue        TYPE boole_d.

*>>> Enqueue the request

* Perform locking of request 10 times just in case first enqueue doesnt work

   DO 10 TIMES.

     CALL FUNCTION 'ENQUEUE_EPTREQ'

       EXPORTING

         mode_ptreq_header = 'S'

         mandt             = sy-mandt

         request_id        = iv_request_id

       EXCEPTIONS

         foreign_lock      = 1

         system_failure    = 2

         OTHERS            = 3.

     IF sy-subrc EQ 0.

*      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

*              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

       lv_enqueue = abap_true.

       EXIT.

     ELSE.

       WAIT UP TO 60 SECONDS.

     ENDIF.

   ENDDO.

*>>> Enqueue the request

   IF lv_enqueue EQ abap_true.

*   Request object

     CALL METHOD cl_pt_req_badi=>get_request

       EXPORTING

         im_req_id  = iv_request_id

       IMPORTING

         ex_request = lr_request.

     IF lr_request IS NOT INITIAL.

*   Change status of request

       CALL METHOD cl_pt_req_badi=>initiate_state_transition

         EXPORTING

           im_request    = lr_request

           im_event      = lv_event_sent

         IMPORTING

           ex_new_status = lv_status.

       IF lv_status EQ 'SENT'.

         ev_ok = abap_true.

         COMMIT WORK AND WAIT.

       ELSE.

         ev_error_msg = 'Failed to change leave request status'.

         CONCATENATE ev_error_msg : lv_status INTO ev_error_msg.

       ENDIF.

     ELSE.

       ev_error_msg = 'Failed to change leave request status'.

       IF sy-msgid IS NOT INITIAL.

         CONCATENATE sy-msgid sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

                INTO ev_error_msg SEPARATED BY space.

       ENDIF.

     ENDIF.

*   Dequeue

     CALL FUNCTION 'DEQUEUE_EPTREQ'

       EXPORTING

         mode_ptreq_header = 'S'

         request_id        = iv_request_id.

   ELSE.

     ev_error_msg = 'Failed to lock leave request'.

     IF sy-msgid IS NOT INITIAL.

       CONCATENATE sy-msgid sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

              INTO ev_error_msg SEPARATED BY space.

     ENDIF.

   ENDIF.

ENDMETHOD.

paul_bakker2
Active Contributor
0 Kudos

You'll get a better response if you post your own question. The is thread is 5 years old and the OP hasn't logged in since 2011!

cheers

Paul