You are at the point where you are running modelling and forecasting with the Unified Demand Forecast as a part of SAP Customer Activity Repository (CAR). You have created many variants for modelling and forecasting which allow you to manage groups of products that you are modelling. All is right with the world.
The process that you developed to run these variants was very methodical and you are very proud of the skills you have developed. At first, running these variants, one after another, gives positive feedback that everything is working correctly. Occasionally, one of the variants has a problem that you need to research and eventually fix and proceed. After doing this a few times, you eventually reach a point where you want to automate this process. Relying on previous experience, you schedule all the variants to run at pre-defined times, so that one variant will end before the next one runs and again everything is again working to your satisfaction.
Then one day, one of the variants fails, and then another; a whole sequence of variants fail. A change was made to some configuration which had an effect in multiple variants and like dominoes, the failures occurred one after another. Nothing to do but fix the problem and rerun the variants, hmmmm? On another day, a configuration was changed and each variant takes longer to run than was expected. The original scheduled time between runs is too short and jobs run overlap, fighting for resources – the reason why you created multiple variants to begin with to solve this problem! What can you do?
I made a lot of assumptions in my example above but do not worry, I’ll start (mostly) from the beginning and describe all the steps, including the assumptions, like already having variants. For the example below, we will use the service ‘Model By Hierarchy’ which models different nodes of the Product (merchandise) hierarchy for all stores. We need to develop a plan which breaks up the work into separate Variants.
Assume that we have a hierarchy Node ID in our plan, such as 1000 FASHION, for which we want to create a Variant. We need to go to the SAP NetWeaver Business Client (NWBC) or to the Portal and select Schedule Model and Forecasts under the Services menu.
From there we need to do the following things to create our Variant:
We have created our first Variant! Write down the name of the Variant we created, we will need it later.
Next we need to ensure that it is possible to execute this service:
Again, we need to go to the SAP NetWeaver Business Client (NWBC) or to the Portal and select Schedule Model and Forecasts under the Services menu. From there we need to do the following things to execute our variant and save the execution parameters to the variant:
A message will display with a Job ID.
Write down the Job ID along with the Job Name, Service Name and Variant you just entered.
You should inspect the results of running this job using ABAP transaction SM37. Select jobs with your user id and the name of this job, restricting it to look within the right timeframe. The status will show on the Job Overview screen. If the job has already been run, it will be in Status ‘Finished’ or “Canceled’; if it has not yet run, it will be in Status ‘Released’.
It is important to verify that each Variant that you create and execute will finish successfully. If it does not, then you should investigate why it failed before scheduling again. You need to troubleshoot any jobs that show “Canceled” before including them in this series of scheduled activities.
Also, once you create a Variant and run it via Schedule Single Execution, the parameters used during the execution are persisted (resaved) in the Variant. This has one major implication: do not edit/reuse this Variant for other purposes by changing the parameters and executing. If you do so, those new parameters will be persisted into the Variant and future execution of the Variant during your scheduled activities will use those new parameter values!
You can now repeat Steps 1 through 3 until you have created all the Variants that you need to run your chain of jobs. At this point, you should have a list of all the following information about each piece you want to run as separate parts of a complete process: Variant Name, Service Name, Job Name and Job ID. Most of this information will be used in the following steps.
Remember that list that we created? One of the pieces of information we saved was the Service Name we used for each Variant. Variants are stored based on the Scheduler Report that uses this service information. In our example, the service we specified was Model By Hierarchy. The Report /dmf/op_mod_hier_job runs a Model By Hierarchy job. Therefore, the Variant that we created in Step 1, MS_MBH_R3051, is saved as a Variant of Report /dmf/op_mod_hier_job. The following list shows the mapping of the service to the Scheduler Report which handles that service:
We now have all the information that we need to execute jobs based on the Variants we created:
From here it is a simple matter of writing your own report using the Background Processing System API calls to open, submit and close each job, sequentially, for each Variant that we created. You can submit your report using transaction SM36 and can be scheduled to run once or recurring periodically.
Since your new report submitted each of the jobs individually using the Background Processing System API calls, we can use ABAP transaction SM37 to verify that each of them completed successfully as described above in Step 3 using their Job Name.
You may also view the messages and statistics for a given job using the Model Status Report (/DMF/MOD_STATUS_REP). But that topic is for another day…
Creating a Report to handle running multiple Variants is a great solution to the two problems we started this article with: 1) being able to schedule jobs at a specific time and, 2) making sure that all these jobs run sequentially without manual intervention. I would like to thank fellow developers Bonnie Barker and Greggory Scherer for their help in compiling the information that I used to write this article.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.