I need to create a variable in a DataFlow and use this variable in a second.
As I don’t want to use a Database-Table or file for just one value, i wanted to use the environment variables as they are unique for a process (see https://bobj-board.org/t/204096).
But I need them in a Batch Job, not Realtime Job.
When I try to set a variable in DataFlow 1 and read it in DataFlow 2, the variable is not read correctly in the second DataFlow.
But when running the job in debug mode, the value is set correctly (and also written correctly in the output file.
So it looks like the 2 DataFlows are processed parallel, even they are designed as serial processing.
When check the environment variable with “if_env_set” it returns 0 in second DataFlow.
Can anyone help me here or at least test if this behavior is the same at your BO environment?
If this is reproduce-able, I would create a SAP-ticket as this is not an expected behavior.
It will never work. Variables within a Dataflow are a copy of the global variable. So if you change it within the Dataflow it won’t affect the global variable at the job level.
The Dataflow has to store the value of the variable in a file or a table.
thanks for your reply, but I’m talking about environment variables.
And when looking into BODS manual about them, they are described as job-call specific:
You can use system-environment variables inside jobs, work flows, or data flows. The get_env, set_env, and is_set_env functions provide access to underlying operating system variables that behave as the operating system allows.
You can temporarily set the value of an environment variable inside a job, work flow or data flow. Once set, the value is visible to all objects in that job.
Checking the description of “set_env()”, it confirms the duration and impact of them:
Sets a system environment variable to a specified value for the duration of a job.
This is also confirmed by manoj in the post linked above.
When I add a script before the dataflows and set the environment variable, I can read the value without problem, but can’t overwrite it.
Also when doing the same in a published Realtime-Job, the environment variables are available (set in Dataflow, not via Script!).
Anyone has an idea?
As from my side, I consider this as bug as the dataflows are linked in a series, so they should not be processed in parallel?
I think this will work for RT job since RT Job runs as a single process, so setting ot env is for that process, and all the objects will see the updated value when calling get_env()
in case of Batch Job each DF runs as a separate process, a child process inherits the env of parent process but if you modify the env variable in child process (in this case DF) the value will not be updated in Parent process, so the vaule of env variable will not be retained once the DF is completed
are you using the similar logic like Real-Time Job in this batch job also (creating a unique id )?
thanks for your answer.
Indeed I tried to use the same logic described by you for RTJs and BJs.
Maybe I’m wrong, but when I start a BJ with multiple DataFlows, I just see one al_engine.exe created as sub-process of the al_jobengine.exe.
So I thought when I use set_env() this is set for the al_engine.exe (as I see the env-variable in properties of al_engine.exe) and so is used for all dataflows.
So maybe a synchronisation of those environment variables between DataFlows of a BJ would be a nice enhancement.
At least the description in the technical manuals should be more detailed (as suggestion for one of the next releases