Académique Documents
Professionnel Documents
Culture Documents
I have a requirement to send a file. The filename contains a Sequence number (start value=001) which is
increment by 1 each time a file is sent within a day(say: if it is sent 3 time on the same day the nnn value of
filename would be 001,002,003). The sequence has to RESET for the files sent the next day(start value=001,
inc by 1).
The possible solution i can think of is to declare a parameter variable to store the session_run count(seq) and
use it further in the Expression transformation to compute the seq based on the condition. But i'm not sure how
to proceed. Can you please guide?
Filename: ABCD.EFnnn.YYYYMMDD.HHMMSS
eg: ABCD.EF001.20170328.111840
ABCD.EF002.20170329.125500
where,
ABCD.EF = static, will pass it as a string.
nnn = sequence number
YYYYMMDD = date of file generated, TO_CHAR(SYSDATE,'YYYYMMDD')
HHMMSS = timestamp of file generate, TO_CHAR(SYSDATE,'HHMMSS')
o_filename = 'ABCD.EF'||nnn||'.'||YYYYMMDD||'.'||HHMMSS
Nico Heinze Mar 28, 2017 10:41 AM (in response to Vidya Nagaraj)
It would be good to know whether this mapping will be used in one workflow only or whether it may be used
in n mappings. The best (safest / only possible) strategy to implement this "running number per day" depends
on this info.
Furthermore, will the workflow(s) run continuously? Or will it/they run n number of times per day?
And if there may be e.g. two workflows running in parallel executing this mapping, is it necessary to keep the
running number unique per workflow? Or must this running number be shared between the workflows?
Regards,
Nico
o
o Like Show 0 Likes(0)
o Actions
2. Re: Generate a sequence based on session run date.
Vidya Nagaraj Mar 28, 2017 10:50 AM (in response to Nico Heinze)
Thank for responding back.
This mapping will be used in only 1 workflow.
The job will be scheduled to run twice a month. During this time, it may run multiple times say 3 to 4 times a
day. Hope this details helps....
Thanks.
o
o Like Show 0 Likes(0)
o Actions
Correct Answer3. Re: Generate a sequence based on session run date.
Nico Heinze Mar 29, 2017 2:39 AM (in response to Vidya Nagaraj)
Hi Vidya,
So here's my approach.
As you need to keep track of when this workflow ran for the last time, it makes sense to keep this "last run
day" in a mapping variable. However, dealing with mapping variables (in particular with their initial value
during a mapping run) isn't too easy, so I prefer using a mapping parameter (to hand over the last run date as a
mapping parameter to the mapping) and a mapping variable (to hand over the start day of the current mapping
run to the workflow) plus a persistent workflow variable which keeps this current run day for the next
workflow run.
This means:
1. The workflow hands over the day of the last workflow run to the mapping as a mapping parameter.
2. The workflow will compare this "last run day" to the current day and deal with the running number of the file
per day (we'll come to that later).
3. At the end of the session run the mapping will hand over the start day of this session back to the workflow
variable.
These steps are repeated for the next workflow run. This way the mapping can always safely identify whether
it's currently running for the first time on that day or whether that's a next run during that day.
The same principle holds true for the current file number:
4. The last file number produced during the previous run is handed over from the workflow to this
session as a mapping parameter.
5. Based on the last run day and the current day the mapping can now identify whether it has to increase the
running file number by one (namely if the mapping already has been executed earlier that same day) or
whether the file number has to be reset to 1 (because it's the first run on a new day).
Regards,
Nico
HELPFUL
Like Show 2 Likes(2)
Actions
4. Re: Generate a sequence based on session run date.
Vidya Nagaraj Mar 30, 2017 11:59 AM (in response to Nico Heinze)
Appreciate your help Nico!!
I'm not so familiar working on parameters but your explanation helped me clear basics and built the solution
for it. I was able to set the mapping variables ($$NEXT_START_VALUE, $$CURRENT_START_DATE)
and populate the sequence number but i'm missing a link to connect/pass the values of a mapping_varaible to
parameter,thus the condition on resetting seq (if the date change RESET the counter) ain't working.
thanks,
Vidya.
Like Show 0 Likes(0)
Actions
5. Re: Generate a sequence based on session run date.
NEERAJ RATHORE Mar 30, 2017 12:59 PM (in response to Vidya Nagaraj)
Hi Vidya
As Nico has mentioned use YYYYMMDD format for holding the date of the previous session run in all
the variables and parameters . As I can see you are using time stamp format and comparing
previous start date and current start date but it will not work because hr min sec will change during
multiple run on same day and it will reset the file number counter to 1 every time.
Thanks
Neeraj
HELPFUL
Like Show 1 Like(1)
Actions
6. Re: Generate a sequence based on session run date.