Over my years working with HCM P&F now, I have often been asked if it is possible to start a process from “something” outside of using the “Start Application” (ie. a user…employee, manager, admin,etc… actually kicking off a process). Now with the advent of Ehp6 and HR Renewal, that functionality got a lot easier (although I *gasp* have not got to “play with that functionality just yet….but I bet this solution will even find use in the EhP6+ world). Prior to this, there was nothing standard to allow you to start a process without a user actually manually executing the “Start Application” outside of starting a process from recruitment via PI integration (lots of config!). In the past, I had played with a few ideas I had. Tried to prototype some things. Looked at the standard workflow tasks for things like “check form” in the background to get some clues. But usually, the client changed requirements or something happened that turned the focus away from coming up with a “auto-initiate” solution and just got back to the work at hand….straight, out-of-the-box HCM P&F configuration and development.

     That all changed for me recently however….in two ways. First off, the one specific process I was given to complete hinges on the fact that the process can be kicked off from “elsewhere” (actually, from a workflow triggered by a whole other event outside of HCM itself). The fallback when/if the process does not get initiated is that the user can also start the process manually (as usual). Secondly, due to the clues given to me by the wise sage of a consultant (and friend), Rudy Blanco, who has been doing SAP development for about as long as anyone, I got pointed in the right direction. At last, I found THE solution for starting a process from anywhere…..and the solution was in technology that has been around for at least as long as the “good ol’ days” of PCR’s (the precursor to HCM P&F)….the ISR framework!!!

     The first step is creating our own custom class in which we will create our custom method to trigger from workflow. Now because we are using this class in workflow, there are some things we have to do (using the IF_WORKFLOW interface and implementing the interface methods correctly) but that is outside the scope of this discussion not to mention there are plenty of online tutorials on how to set this all up if this is foreign to you.

    methods2.JPG

Let us assume all those steps have been done and now our focus is on our new custom method….

     For this example, I know that my initial form in my process is very simple as it is not meant to actually be used except in case of an error where our workflow for some reason does not start it and we need to manually initiate the process. In my case, I need only the employee PERNR (the same as if our user were selecting it manually) and a record ID (to look up the record needed for the rest of my process), so those are my only form fields.

/wp-content/uploads/2013/12/form_342655.jpg

    Those fields will then be the only parameters I need for my custom method. We define them with the same types as our form fields.

method_params.JPG

     Inside our method, we need some very basic code. Let’s walk through it…..

code_1.JPG

     First, you see that we need to set some basic information that you would expect if you were telling “something” what process you want to start.

code_2.JPG

     Next, we fill in some of the “special” fields (although you will see we do this again).

code_3.JPG

     Now we get to the real magic….

code_4.JPG

 

Yep! We call the good ol’ ISR framework to do our bidding. (*note: oddly enough, I had used this in the past to allow mobile users to do approval steps in a process but had not thought to try to use it to start a process…doh!) You might wonder why we are looping twice here. The first loop, we send the “event” parameter as empty/blank. This is equivalent to telling our process to “initialize”. The ISR call returns our structures full of our initialized fields and data. So then we set our form field values to what we want them to be (just as if we were keying them into the form), and we set our “event” to “send” at this point. When it goes into the second loop then, it has our fields with the data in them, and we are telling it to “send”…which is like our HCM P&F “send” step after “check and send”. Therefore, our process will be started just as if someone had been sitting there running the “Start Application” as we are all quite use too by now. We could get “fancy” here and add some code to the end to write to the log on errors or some such (look at how the standard “check form” or “save form” background workflow tasks do this), but we do not need this for now.

    But now, where do we put this? How do we use it?

    First, we create a new custom workflow “standard task” (via transaction PFTC_INS). Within our task, we assign our custom class and method to be used.

wf_task.JPG

    Now we have to use our task somewhere. Let’s consider a simple workflow…..say we have the following existing workflow in place…..

workflow_1.JPG

….within our workflow, we add a new step and assign this our new custom task. We set up our bindings so that the workflow passes the information we need to our method.

workflow_2.JPG

….now, when the workflow gets executed and at some point hits our task, our process is initiated…just as if someone had run it manually from the “Start Application”. The first step in our processes’ workflow sends our manager an “edit” task to his UWL….so look what shows up “magically” in our UWL?

UWL.JPG

The initial workflow that triggered our process and its workflow may be still running or ended, but our process workflow is now off doing its thing just as usual.

     That is about all there is to it….write your own class, have a public method that can accept whatever parameters you need as input to set for your form fields In the form scenario “start step”, call the ISR “process event” function module and viola….you have your very own process” trigger” that can be used in any number of ways. Imagine the following possible scenarios….

  • Start process from report :

Imagine if some sales department administrator ran a “top sales people of the month” report and this report checked if certain sales people met their quota and such and if so, it could call your class method and would fire off a start “Monthly Bonus” process for each sales person that met the criteria. Auto-magically! (haha)

  • Start process from mobile device :

So you are a manager on vacation and find out your ace employee just left the company. You need to fill that position fast! Sure wish you could start a recruitment process from your lounge chair on the beach eh? Well, if you can write an app or a simple web “form”, you can send that information right over in any number of ways…plenty of examples around…but there is nothing stopping you from calling your class method “trigger” in there too!

  • Start process from WebDynpro :

Imagine that an employee is changing or adding an address using their ESS WebDynpro ABAP app. In that WDA, you have some checks in place that will see if the new/changed address has tax implications. If so, it calls your class method and initiates the “Employee Change of Address” process which allows other admins to check/change/correct any tax related settings for the address. Otherwise, the change happens immediately and the employee is none the wiser….nor does an HR Admin get notified every time someone changes their address.

  • Start process from web service :

Imagine if we have some web service…maybe, say something we have written for integration to other products…like say SuccessFactors….maybe when a change of some sort occurs in SF, our web service gets called via PI integration and kicks off our own nice on-premise HCM process. Triggering HCM P&F from SF? Yep! BOO-YAH!!!!

  • Start process from another process:

The examples for this almost write themselves. How many times have you want to trigger another HCM P&F process to start while in the workflow of another process? Yep…you can do <insert your scenario here> now.

…and I am sure you good HCM P&F folks can think up even more use cases!!! 😉

So that’s it. Now you know. You have the power in your capable hands. Go forth! Blaze a trail as you put this new found knowledge to use! Take HCM P&F into the farthest reaches in ways never imagined! Make me proud! (haha) In the meantime, as always, I will keep blogging as long as you keep reading. Till then…

To report this post you need to login first.

20 Comments

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

    1. Christopher Solomon Post author

      Yeh, the “Process Execute” FM is the engine behind HCM P&F runtime, but the ISR function abstracts that for us a bit….and is much easier to call. 😉

      …and this solution above works in situations prior to “HRASR_PROCESS_EXECUTE” becoming available (as of HR Renewal FP4?).

      (0) 
  1. Manoj Sasidharan

    Thanks for the information Chris..

    I remember painstakingly examining the code used within methods P&F XI interface proxy classes(eg.CL_HRASR00_HIRE_REQUEST) for building a Function module for the same purpose in a non Renewal system as the “process execute” FM was not available then. Seems things have become easier now with Renewal..

    (0) 
    1. Christopher Solomon Post author

      Yes. Renewal made this pretty much “painless”. Prior to it though (which still a LOT of folks are living), I am glad I finally found a way…which really is pretty simple too!

      (0) 
      1. Ravi Kumar

        Fantastic stuff Chris,

        We also implemented the HCM forms in our client place.

        Some times ‘Managers’ want the form to be ‘WITHDRAWN’ from SAP R3 instead of using Portal.

        I am seeking your help in this regard that, is there anyway using SWIA withdraw the form’s workflow as well as the form. I doubt deletion of workflow would not really roll back the form.

        Appreciate your inputs.

        Thanks,

        Ravi

        (0) 
        1. Manoj Sasidharan

          Use the transaction HRASR_TEST_PROCESS. Give the reference number and workitem id in selection screen. execute and withdraw using the function in toolbar.. Functions would appear only as what is set for the workitem.

          Manoj

          (0) 
          1. Ravi Kumar

            Thanks Manoj.

            But when I try to execute HRASR_TEST_PROCESS in quality system, encountering error ‘Do not run this program in the productive system‘.

            Obviously this transaction is not meant for productive environment. Are you using this transaction in production system ?

            RKP…!

            (0) 
      2. Sudhir Gupta

        Let me convince my clients to use this function.. they are planning to keep each DEV/QA system in a separate DMZ zone.. tough sale you might say 😛

        (0) 
  2. Ritin Jain

    Hi Chris,

    Is there any equivalent method for FPM process in place of ISR_PROCESS_EVENT.

    Thanks

    Ritin

    (0) 
    1. Christopher Solomon Post author

      Well….kind of…..the new HRASR_PROCESS_EXECUTE (as of HR Renewal…I think as of feature pack 4)….but you see it mention for “external UI” (ie. alternative form interface)….


      HCM, Administrative Services 04 – Human Capital Management – SAP Library


      Creating a Form Using an External UI – HCM Processes and Forms – SAP Library

      As SAP says in the doc above…. “For information about HRASR_PROCESS_EXECUTE, see the function module documentation in Function Builder in the ABAP Workbench.” If you goe and look, the function is VERY well documented on how to do just about anything with HCM P&F processes with it.

      (0) 
  3. Bruno Nunes

    Hello Chris, thanks for all your content available online, it’s been very helpfull.

    I’m new user of P&F, so, i’m reading a lot stuff online, specially the ones posted by you.

    As expected, i’m facing a few difficulties, i’ve been doing well most of the times though.

    Looking forward to improve myself.

    I’d like to ask for you help and also to the other experts to build a screen with two “Expand menu” (I don’t know how it’s called) as shown in the printed screen (FIG 1.1).

    I tried two ways, I first used two forms in one scenario form (FIG 1.1), but both forms are show in one “expand menu” (FIG 1.2).

    After that I tried to use two form scenarios with one form each, but with no success (FIG 2.1), the second form scenario is not presented.

    Is it possible to do that?

    Sorry for some words in portuguese on the screen, I could not build a new screen in english.

    Thanks,

    Bruno NunesFIG_1.1.png

    FIG_1.2.png

    FIG_2.1.png

    (0) 
  4. Federica Marini

    Hi Christopher,

    thanks for your post…this is exactly our issue for a client: starting a process not from the launchpad…but i have few questions: your code is only for Adobe Form? we should trigger a process with FPM form connected…How could we do?

    Thanks

    Federica

    (0) 

Leave a Reply