Skip to Content

Sometimes a HCM Process just needs to be deleted (cancelled).  I’ve found that occasionally there will be a hung request out there that no user is able to process.  It only happens very rarely, but being able to quickly cancel the request and any associated workflow is a handy thing to do.  So here is a quick and dirty program which allows you to choose a process by reference number and cancel both the request and any workflows associated with it.  thanks..

report zupd_proc_status.

data: t_t5asrprocesses type t5asrprocesses.
data: t_sww_wi2obj type sww_wi2obj.

selection-screen begin of block b1 with frame title text002.
selection-screen begin of line.
selection-screen comment 1(27) text005.
parameter: p_refn like t5asrprocessesreference_number.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 1(27) text004.
parameter : p_stat like t5asrprocessesstatus default ‘WITHDRAWN’.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 1(27) text007.
parameter : p_wf type char1 default ‘X’.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 1(27) text006.
parameter : p_test type char1 default ‘X’.
selection-screen end of line.
selection-screen end of block b1.

startofselection.

  select single * into t_t5asrprocesses from t5asrprocesses
     where reference_number = p_refn.

  if sysubrc <> 0.
    message i103(hrasr00_process) with p_refn.
    exit.
  else.
    if t_t5asrprocessesstatus eq p_stat.
      message ‘Status is already the requested status.’ type ‘I’.
      exit.
    else.
      if p_test is initial.
        t_t5asrprocessesstatus = p_stat.
        if t_t5asrprocessesstatus = ‘DRAFT’ or t_t5asrprocessesstatus = ‘STARTED’.
          clear t_t5asrprocessescompletion_date.
          clear t_t5asrprocessescompletion_time.
        else.
          t_t5asrprocessescompletion_date = sydatum.
          t_t5asrprocessescompletion_time = syuzeit.
        endif.

        update t5asrprocesses from t_t5asrprocesses.
        if sysubrc eq 0.
          commit work.
          message ‘Update Complete.’ type ‘I’.
          if not ( p_wf is initial ).
            if not ( t_t5asrprocessesstatus = ‘DRAFT’ ) and not ( t_t5asrprocessesstatus = ‘STARTED’ ).
              select single * into t_sww_wi2obj from sww_wi2obj
                 where instid     = t_t5asrprocessescase_guid
                   and catid      = ‘CL’
                   and typeid     = ‘CL_HRASR00_WF_PROCESS_OBJECT’
                   and wi_reltype = ’99’
                   and wi_rh_task like ‘WS%’.
              if sysubrc eq 0.
                call function ‘SWW_WI_ADMIN_CANCEL’
                  exporting
                    wi_id = t_sww_wi2objwi_id.
                if sysubrc = 0.
                  message ‘Update Complete.  WF Cancelled.’ type ‘I’.
                endif.
              endif.
            endif.
          endif.
          exit.
        endif.
      else.
        message ‘Update Can Be Done.’ type ‘I’.
        exit.
      endif.
    endif.
  endif.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Christopher Solomon

    Wow! Very nice. I usually have to do a “Stop Process” process for clients that is similar to this, but this is really nice too! Thanks for sharing and KEEP BLOGGING!

    (0) 
    1. Philip Johnston Post author

      Thanks Smuli.  I may use this function now that you have alerted me to it.  (:->

      However, the code above allows using any status and not just WITHDRAWN.  Also, the other benefit is that there is not an auth check..  But, either way, as long as the job gets done, it’s all about keeping the clients happy.

      (0) 

Leave a Reply