Skip to Content
avatar image
Former Member

Approve Reject Button working same way

Hello Experts,

I am implementing My Inbox for our WF approvals. I have all things working and the buttons are also coming up as it should. The problem is when I approve it works fine but when I reject it, it works same way as Approve. I am not able to reject my WFs. I am not getting _WI_RESULT in my container and even if I set LASTERROR field to 'R' or any other return code, iy does not do anything except to approve it. I am not doing anything special for the approve button and it works just fine.

Please help me with this. Much appreciated.

Thank you.

The code is below.

DATA ls_formabs TYPE swxformabs.
"Access the workflow data
CALL FUNCTION 'SAP_WAPI_GET_OBJECTS'
EXPORTING
workitem_id = is_wi_details-wi_id
IMPORTING
leading_object_2 = ls_object.
"Get the formnumber which is the key to the absence table
MOVE ls_object-instid TO formnumber.
"Select the details of the absence from the table SWXFORMABS
SELECT SINGLE * FROM swxformabs
INTO ls_formabs
WHERE formnumber = formnumber.
"Read the workflow's container data
CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
EXPORTING
workitem_id = is_wi_details-wi_id
IMPORTING
return_code = lv_retcode
TABLES
simple_container = lt_container.
" Check which decision was selected and set the data
" values appropriately
CASE iv_decision_key.
WHEN 0001. "Approved
ls_container_line-value = iv_decision_key.
ls_formabs-procstate = iv_decision_key.
WHEN 0002. "Rejected
ls_container_line-value = iv_decision_key.
ls_formabs-procstate = iv_decision_key.
ENDCASE.
"_WI_RESULT is what the workflow keys off to determine
"which path to follow - Approve or Reject path
ls_container_line-element = 'LASTERROR'.
"Modify the workflow's container data - we are updating the row that
"holds _WI_RESULT which will be in the second row of the table
MODIFY lt_container INDEX 9 FROM ls_container_line TRANSPORTING value.
"Write the updated container back to the workflow engine
CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'
EXPORTING
workitem_id = is_wi_details-wi_id
do_commit = 'X'
IMPORTING
return_code = lv_retcode
TABLES
simple_container = lt_container.
IF lv_retcode NE 0.
"Handle error
ENDIF.

"Update the Absence table with the updated data
ls_formabs-approvdate = sy-datum.
ls_formabs-approvby = sy-uname.
UPDATE swxformabs FROM ls_formabs.
"Complete the task
CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'
EXPORTING
workitem_id = is_wi_details-wi_id.
"This task requires a confirm to be fully completed
"and start the next step in the workflow
CALL FUNCTION 'SAP_WAPI_WORKITEM_CONFIRM'
EXPORTING
workitem_id = is_wi_details-wi_id.

ENDMETHOD.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers