cancel
Showing results for 
Search instead for 
Did you mean: 

Approve workitem programmatically

0 Kudos

Hi experts,

I want to approve user desion step in a worklfow program exit during a workflow process, that is, the step will be approved automatically based on some condition by the same agent ( who receives the work item ) . Knidly pass me some useful solution for this..

Thank You

Ramesh

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185167
Active Contributor
0 Kudos

Hello,

Could you please explain further, with an example?

If approval is no longer necessary you could have a fork that checks for that.

regards

Rick Bakker / hanabi technology

0 Kudos

Thank You for your reply. If approvers are repeated , then higher level approver should be auto approved. If we use fork also we need to use fm/ class to make auto approve.

Please let me know your inputs on this.

Thanks in advace..

Thank You

Ramesh

former_member185167
Active Contributor
0 Kudos

Hello,

You could have a condition step that checks if the current agent has already approved. If so then skip the approval step. Easier than making a procedure to auto-approve.

regards

Rick Bakker / hanabi technology

0 Kudos

Thank You .

We have to execute the the work item as per our process for audit purpose.

Thank You

Ramesh

former_member185167
Active Contributor
0 Kudos

Hello,

If it's approved automatically then it will be approved by WF-BATCH so I don't know if that will satisfy your auditors.

regards

Rick Bakker / hanabi technology

0 Kudos

Hi Experts,

We have implemented a program exit , in the decision step , to set the _wi_result parameter value 001( aprove) . Still I am unable to update the decision step by exit and work item remains in the inbox. Kindly help me on this . Below is my code from program exit.

* Local data
  data: lr_wf_container
type ref to if_swf_ifs_parameter_container,
        lr_wi_container
type ref to if_swf_ifs_parameter_container.

  data: lv_wi_id       
type sww_wiid,
        lv_rej_text    
type exmai,
        lv_ustatus     
type sysubrc,
        lv_se_number   
type lblni,
        lv_wi_result   
type i,
        lv_exit_ind    
type char1 value 'C',
        lv_bef_exec    
type sww_evttyp value 'BEF_EXEC'.

  constants:
lc_wi_result type swfdname value '_WI_RESULT'.

* Get the reference to the workflow container
 
call method im_workitem_context->get_wf_container
    receiving
      re_container = lr_wf_container.

* Get the reference to the workitem container

  call method im_workitem_context->get_wi_container
    receiving
      re_container = lr_wi_container.


 
case im_event_name.
   
when lv_bef_exec.
    

    lv_wi_result = '001'.  " Approve

   

        try.
         
call method lr_wi_container->set
           
exporting
              name       = lc_wi_result
             
value      = lv_wi_result
           
importing
              returncode = lv_ustatus.
*         if there is no update! please abort
         
if lv_ustatus <> 0.
           
message x001(000) with lv_ustatus.
          endif.
       
catch cx_swf_cnt_cont_access_denied .
       
catch cx_swf_cnt_elem_access_denied .
       
catch cx_swf_cnt_elem_not_found .
       
catch cx_swf_cnt_elem_type_conflict .
       
catch cx_swf_cnt_unit_type_conflict .
       
catch cx_swf_cnt_elem_def_invalid .
       
catch cx_swf_cnt_container .
      endtry.
    when others.
  endcase.
endmethod.

Thank you

Ramesh

anjan_paul
Active Contributor
0 Kudos

hI,

  It is possible you put a activity step to collect list of approvers in previous level. Then take a loop on the approvers container element, if current approver is exist in the approver container element.   condition step before Decision step and check  it is previously approved by any user. If approver was there then send the User decision first in background step, in binding collect the workitem id,

then use one activity step to call  SAP_WAPI_DECISION_COMPLETE to complete the decision step.

0 Kudos

Thank you for your reply.

In the workflow container, one of the table container contains all approver and their levels.

I hope by using this we can write the condition for repeated uesrs but my concern is, for the repeted users how to approve programmetically.As i know the RFC SAP_WAPI_DECISION_COMPLETE we cannot use in the program exit.

Please help me on this.

Regards,

Ramesh

anjan_paul
Active Contributor
0 Kudos

Hi,

  yes right.

Then I think  you don't have any option other than this.

Whenver approver is repeatd, don't give any user decision step. Instead of use your custom task to update your table for approval.

former_member185167
Active Contributor
0 Kudos

You are making this way too complicated. Time to re-think.