Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
jose_sequeira
Active Participant
19,877
Hello World,

This time let's talk a little about what's new and what's "old" on ECC to S/4HANA On-Premise migrations, focusing on the Workflow area (and Approvers selection).


As you know, SAP created Flexible Workflows to bring a "new age" for the Workflow Engine in SAP solutions, but "Classic" Workflows are still running hot. In a fast way, SAP is bringing to customers more and more standard scenarios for those ho wants to migrate to the Flexible Workflow and it's benefits, but with this changes may come new challenges as well.

For example, by monitoring Fiori Apps Library we can see a evolution in standard Flexible Workflows scenarios available:


 

This time i'm focusing on the standard Flexible Workflows, but what we'll discuss it here will serve as well for custom ones.

To bring a long history short, Flexible Workflows gives to the customer more "power" to create their own process and steps in their required approval scenario... it's like their made to be configured, not like the Classic Workflows where we design the process and steps itself there. The "switch" technically it's not hard, but it comes with this different approach when defining and working with the customer.

One of the first Flexible Workflows created, and a "main player" in all SAP Customers that uses Workflows, was the Purchase Order Approval scenario. Let's use this scenario to explain one of this "challenges" when migrating to the Flexible Approach, the Approvers selection. With that being said, one of the goals of this blog is to serve as a reference and guide for the Approvers selection in all Flexible Workflows, ok?

So let's go...

In 2019 i wrote a blog about getting the release strategy details (approvers) on a Purchase Order standard Classic Workflow scenario, like this:


Using the standard BAPI: BAPI_PO_GETRELINFO to accomplish that.

But as you know (please find all details about Flexible Workflow on Purchase Orders here) the Flexible Workflow does not uses Release Strategy on POs anymore, it's all for the customer to decide how many steps, approvers, etc. Using many ways to accomplish that in the Workflow configuration.

So how does the screen above looks on a Flexible Workflow PO?


It creates a new subscreen called Flexible Workflow, and inside you will find all current/final details regarding the approval process. On the example above, one step was configured and designed to get the approvers by BADI. If you double click it, get's all the approvers (2) and other details:


So will the "old" BAPI still bring the desired approvers data? No...as it's based on the release strategy (not used in Flexible Workflow):


And will the Workflow link work on ME23n?


Not in S/4 version 2021 as of now... (maybe they'll fix it in the future).

So where to go if you want to know details about the Workflow related to the purchase order? Let's go!

The key here are 2 standard SAP tables: SWWFLEXPROC and SWW_WI2OBJ, as they both will have the link between the object key (Purchase Order ID is this example) and the WF ID (Workitems as we called, for the main Workflow).

The first one was created together with the Flexible Workflows, but the second it's still there for ECC.

So now if we select the data there using the PO key:


We'll get Workitem IDs (can be more that one, as each of them represents a approval process that the document was a part of), in this example we have 2... so we need to get the newest one:


The same way that one of the standard SAP (for Flexible Workflow) classes does:


And here is where he filters for the newest one:


As you can see, it look's for the new table but also on the "old (but gold)" table as well... that we could use like this:


And get the same data:


Note: If you go through the documentation on Flexible Workflow (here) for PO, you'll note that the Workflow ID is WS00800238 and the Task ID is TS00800531:


Workflow ID is the main "task" of the Workflow (like a father ID), and the Task ID above is the approval step (1 or many) of the same. Workitem ID is generated at runtime when Workflows runs...

Together with the changes and the creation of the Flexible Workflow, SAP created many ABAP Classes that can you help you accomplish all types of scenarios, classes like:

CL_SWF_FLEX_WEBGUI_WORKFLOW

CL_SWF_FLEX_IFS_FACTORY

CL_SWF_FLEX_BADI_UTILS

CL_SWF_FLEX_IFS_INST_WORKFLOW

Some of then remain "hidden", as if you look for them in the code you'll get no usage hits:


And there are many of them:


Not even found (also the SWWFLEXPROC table) on the official SAP documentation:


Going back to the scenario, if you use this Workitem ID (WI_ID) on transactions like SWI1/SWIA, you'll get all of the details of the Workflow process (use the Technical details button to see the view below):


As we could see on ME23n, it had 2 approval steps and it's now completed (fully approved), also note the "child" Workitems.

But where could we get ALL of the details, just like it's showed on ME23n? Just like we had in the past using the BAPI mentioned above...

The key here are the classes described above, where in places like here (class->method):


We could find details like Comment, Update, Processors, etc:


Here for Last Update and Comments:


And if you debug it, and study a little bit of the data selection, you'll find that you can get the same output here as displayed on ME23n for the first screen:


And when you double click for the approvers, here:


The same values:


After taking a look at the code you can conclude that this classes will serve all of the Flexible Workflow Scenario needs... not only for a specific scenario (like it was before, we had a BAPI for PO, PR, etc), so this time SAP also created something really helpfull. The main key here is reusability, so any screen of any object that uses Flexible Workflow can get Workflow details the same way.

Also, the CL_SWF_FLEX_WEBGUI_WORKFLOW class will even create the ALV/GRID for the screens, just like magic 🙂

Another thing that you will discover there but i can deliver faster here for you, with main Workitem ID (in the example here 33104) you can get the Approval Steps here:


WI_TYPE 'W' = User Decision Task


And in WI_AAGENT field get the final approver for the step (also note the WI_STAT field for Status).

Want another example? How does it look when the PO is still pending approval:


Like this... and also looking at the class code, we can see that you can get the current approvers (after the actions is executed it wont get displayed here, but on the WI_AAGENT above) for the step like this:


And voilá:


Flexible Workflows are here to stay! With the learning above you could create your own functions, CDS Views, etc... to retrieve approvers and many other nice things that can be found on CL_SWF_FLEX* classes! What else could we create? Drop a comment below and let's work together!

Hope you've enjoyed and it can be of any help for you.

PS: Hopefully this blog will show on help.sap when looking for any of the above 😎.

If you have any questions, please drop them below.

Best regards.
10 Comments
Labels in this area