Friday 27 December 2019

Workflow: Purchase Order/Requisition Approvers Simulation

Have you wondered how, after you’ve finalized your release strategy configuration (for Purchase Order and Requisition as an example), how the approvers for each code are ACTUALLY found?

If you’re using the standard Workflows, they’re using Rules (PFAC) to do so. One thing in common between these 2 rules (PO and PR) is that they both execute the FM ME_REL_GET_RESPONSIBLE to actually find the approvers for the Workflows (FIORI or SBWP).

SAP ABAP Tutorial and Materials, SAP ABAP Online Exam, SAP ABAP Certifications

As you can see, it selects approvers data… It could also call Customer Functions…

Both rules (you can check them out on PFAC Transaction):

SAP ABAP Tutorial and Materials, SAP ABAP Online Exam, SAP ABAP Certifications

SAP ABAP Tutorial and Materials, SAP ABAP Online Exam, SAP ABAP Certifications

Let’s create a use case to demonstrate the process… I’m assuming that you have your release strategy already configured (with approvers) from SPRO (not covering this part here).

Let’s say we have a PO, and i want to SIMULATE the approvers for a code, how can i do that?

First option, you can simulate using the standard RULE. Go to PFAC using the PO rule (screen above), click on view and them Simulate:

SAP ABAP Tutorial and Materials, SAP ABAP Online Exam, SAP ABAP Certifications

Using the F4 Search help on the Purchase Order field, enter your PO… Same thing with the Release Code:

SAP ABAP Tutorial and Materials, SAP ABAP Online Exam, SAP ABAP Certifications

Click on simulate (F8), you’ll see the approvers list below(if found correctly), like below:

SAP ABAP Tutorial and Materials, SAP ABAP Online Exam, SAP ABAP Certifications

A second option, would be to execute the simulate report that i’ve created, entering PO and Release Code:

SAP ABAP Tutorial and Materials, SAP ABAP Online Exam, SAP ABAP Certifications

It will list the Approves like PFAC:

SAP ABAP Tutorial and Materials, SAP ABAP Online Exam, SAP ABAP Certifications

You can get the code here:

*&---------------------------------------------------------------------*
*& Report  ZMM_GET_APPROVERS
*& For Linkedin :) by José Sequeira http://bit.ly/2PbRleX
*&---------------------------------------------------------------------*

report  zmm_get_approvers.

include <cntn01>.

"Little Hack...
types: begin of ty_cont,
      logsys    type char10,
      objtype   type char10,
      objkey    type char70,
      describe  type char10,
       end of ty_cont.
"Little Hack...

data: gr_table type ref to cl_salv_table.

data: lt_actor type table of swhactor,
      lt_cont  type table of swcont,
      s_cont   type ty_cont,
      ls_obj   type swc_object,
      ls_cont  type swcont,
      ls_actor type swhactor.

parameters: p_ebeln type ebeln obligatory,
            p_code  type frgco obligatory.

start-of-selection.
*--------------------------------------------------------------------*
* Getting stuff done...
*--------------------------------------------------------------------*

  "Litle Hack here, just to move the data between the program and FMs...
  s_cont-objtype = 'BUS2012'.
  s_cont-objkey  = p_ebeln.

  swc_set_element lt_cont 'purchaseorder' s_cont.
  swc_set_element lt_cont 'ReleaseCode' p_code.

  call function 'ME_REL_GET_RESPONSIBLE'
    tables
      actor_tab    = lt_actor
      ac_container = lt_cont
    exceptions
      nobody_found = 1
      others       = 2.
  if sy-subrc eq 0.
    "Showing simple ALV...
    cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = lt_actor ).
    gr_table->display( ).
  else.
    message 'No Approvers found, something is wrong...' type 'S' display like 'E'.
  endif.

Now you can explore the simulation program, create one for PR, etc… etc…

The main goal is to always monitor your release strategy for “misconfigurations” that could cause Workflow not finding the correct approvers…

No comments:

Post a Comment