on 2024 Oct 30 3:49 PM
I have some functions in my model that depend on several functions needing to be executed in a specific order. In particular, I need to write the output of some Join functions in different HANA model tables. I created a Writer function for each Join, and a Join function that takes all the Writers as input, in order to run all the Writers by executing just one function.
Request clarification before answering.
Hello Sergio,
I believe you can achieve this using Rule Hierarchy:
"Join is a data access function that brings together the results of two or more other functions based on defined rules. Each join rule semantically defines the reading of a specific input. Hierarchical join rules are also supported by assigning higher levels. The hierarchy of levels is resolved starting with the highest level, feeding as input to the lower levels and ending with level 0."
But depending on the type of writer you need to sequence, a different solution was necessary in my tests.
Using "Insert" writer type:
Consider this model as example:
Starting with three identical model tables, where initially only 'Model Table 1' (MT01) contains data.
- Writer 1 (W01) copies data from MT01 to MT02.
- Writer 2 (W02) copies data from MT02 to MT03.
Writer 2 should only run after Writer 1 is complete. Writers functions are flagged as 'Sub Function' in Parallel Processing Type setup.
The 'Join - Execution' (J01) will be the executable function. The hierarchy in Join Rules ensures Writer 1 runs before Writer 2, so new entries in MT01 are first written to MT02 and then to MT03.
Additionally, an invalid filter can be applied in the Join Output subview to avoid unnecessary data replication in the J01 underlying Y Hana table (so the function output will be empty).
In my tests this setup respected the desired order of execution. Here is the message log (for a second run) of the Join Function.
Using "Delete and Insert" writer type:
This one is a little trickier, because when a "delete and insert" writer is defined as a sub-function/input for Join, it only performs the insert part. More details on this can be found here: PaPM Writer: Delete and Insert - SAP Community.
When you change the writer to "Executable," it will perform the delete part properly, but run in parallel (the sequence in Join Rules is not respected).
To make this work, I created a new Model Table 4 (MT04) with the same structure, which will be left empty and used to clear MT02 and MT03.
Now we have MT04 as input for the new Writer 0A (Output is MT02) and Writer 0B (Output is MT03), which will run first in our Join Rules Hierarchy, ensuring the previous results are cleared. These writers will be flagged as Executable, since there is no problem if they run in parallel.
Writers 1 and 2 should now be flagged as sub-functions, since they will be inserting data into empty model tables and we no longer need the delete part to function. This will ensure that the Join Rules Hierarchy is respected for the writing part.
With this setup, I was able to achieve the desired output. Find below the run messages and timestamps:
Regards,
Leonardo Silva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leonardo,
Thank you for your effort and for sharing these solutions.
I've analyzed my model to see if I could implement your suggestions, but unfortunately, my setup introduces some additional challenges.
In my case, each of the three Writer functions has multiple dependent functions behind it—such as additional Joins, Writers, Iterative Views, and Joins that read data from Model Tables. I emphasize "Iterative Views" because they require executable functions as input, and these inputs are often Writers. This creates a need to execute the three primary Writer functions in a specific order, while also ensuring that each Writer’s dependencies are processed sequentially, whether they’re set as Sub-Functions or Executable.
In the On-Premise version of PaPM, I managed to resolve this by assigning ascending IDs to the Executable (Delete and Insert) Writer functions. For ordering independent steps executed by each Writer—especially when Iterative Views were involved—I included Iterative Views with a loop from 0 to 0, assigning ascending IDs to these views. This method proved reliable in the long term, but unfortunately, it doesn't work the same way in PaPM Cloud.
Thank you again for your help, and I hope you might have further suggestions to navigate this complexity.
Have a great weekend!
Best regards,
Sergio
User | Count |
---|---|
9 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.