I need a variable for the next month
I need a variable for the next month
I have a distributed job that the user wants a variable of the next month. If the job runs on the 26th of August, the current month would be 08. They want to use a September variable as 09. How can I do this in the set panel?
- nicolas_mulot
- Nouveau
- Posts: 149
- Joined: 07 Jan 2010 12:00
Hubba,
The longest month in the year is 31 days.
The fisrst of month plus a minimum of 31 day will usually fall somewhere in the beginning of the following month. The following sequence will return “09” in %%NEXT_MONTH if you run it today
%%FIRST_CUR_MONTH=%%OYEAR.%%OMONTH.01
%%SOME_DATE_NEXT_MONTH=%%CALCDATE %%FIRST_CUR_MONTH +32
%%NEXT_MONTH=%%SUBSTR %%SOME_DATE_NEXT_MONTH 3 2
Cheers
Nicolas_Mulot
The longest month in the year is 31 days.
The fisrst of month plus a minimum of 31 day will usually fall somewhere in the beginning of the following month. The following sequence will return “09” in %%NEXT_MONTH if you run it today
%%FIRST_CUR_MONTH=%%OYEAR.%%OMONTH.01
%%SOME_DATE_NEXT_MONTH=%%CALCDATE %%FIRST_CUR_MONTH +32
%%NEXT_MONTH=%%SUBSTR %%SOME_DATE_NEXT_MONTH 3 2
Cheers
Nicolas_Mulot
Thanks Nicolas but.......
It gets better. We have a close date every 21 work days. This date flucuates every month. As an example, A daily job runs every day with say.... parm of 201008, until the 25th. The monthly job runs on the 26th of the month. On the 27th, the daily job runs and we want to use the following month parm, which would be 201009. Any Ideas?
It gets better. We have a close date every 21 work days. This date flucuates every month. As an example, A daily job runs every day with say.... parm of 201008, until the 25th. The monthly job runs on the 26th of the month. On the 27th, the daily job runs and we want to use the following month parm, which would be 201009. Any Ideas?
Need a variable for next month
1. Get the current month in a variable
2. Get the current day in another variable
3. if the current day is greater than 27
a. if current month is 12 then set current month to 1
b. else set current month to current month + 1
4. This also means that if the day is <= 27 then just dont do anything. the value set in point 1 will suffice
Jayant
2. Get the current day in another variable
3. if the current day is greater than 27
a. if current month is 12 then set current month to 1
b. else set current month to current month + 1
4. This also means that if the day is <= 27 then just dont do anything. the value set in point 1 will suffice
Jayant
Hi,
In this case i propose to use the '%%LIBMEMSYM' variable in the AutoEdit Assignment to set a 'text file' containing a list of your AutoEdit assignments. This file referenced by %%LIBMEMSYM variable enables you to centralise one 'file' containing AutoEdit assignment statements that can be read by many job processing definitions.
Important: The %%LIBMEMSYM must reside on the Control-M/Server and the full <path name> is case sensitive.
Little example:
1) Define the content about your %%LIBMEMSYM <file>
###############
# Get Next Month
###############
%%MYMONTH_01 = 02
%%MYMONTH_02 = 03
%%MYMONTH_03 = 04
%%MYMONTH_04 = 05
%%MYMONTH_05 = 06
%%MYMONTH_06 = 07
%%MYMONTH_07 = 08
%%MYMONTH_08 = 09
%%MYMONTH_09 = 10
%%MYMONTH_10 = 11
%%MYMONTH_11 = 12
%%MYMONTH_12 = 01
2) Define a job and in SET panel put this:
%%LIBMEMSYM = full_path_name for the file (crated in step 1)
%%PARM1 = %%SUBSTR %%MYMONTH_%%OMONTH 1 2
Now, job pass variable %%PARM1 to it
ie:
echo Next month is : $1(unix)
echo Next month is : %1 (windows)
Result : 09 if order date is today
You can read this AutoEdit assignment statements by many job on your processing definitions
In this case i propose to use the '%%LIBMEMSYM' variable in the AutoEdit Assignment to set a 'text file' containing a list of your AutoEdit assignments. This file referenced by %%LIBMEMSYM variable enables you to centralise one 'file' containing AutoEdit assignment statements that can be read by many job processing definitions.
Important: The %%LIBMEMSYM must reside on the Control-M/Server and the full <path name> is case sensitive.
Little example:
1) Define the content about your %%LIBMEMSYM <file>
###############
# Get Next Month
###############
%%MYMONTH_01 = 02
%%MYMONTH_02 = 03
%%MYMONTH_03 = 04
%%MYMONTH_04 = 05
%%MYMONTH_05 = 06
%%MYMONTH_06 = 07
%%MYMONTH_07 = 08
%%MYMONTH_08 = 09
%%MYMONTH_09 = 10
%%MYMONTH_10 = 11
%%MYMONTH_11 = 12
%%MYMONTH_12 = 01
2) Define a job and in SET panel put this:
%%LIBMEMSYM = full_path_name for the file (crated in step 1)
%%PARM1 = %%SUBSTR %%MYMONTH_%%OMONTH 1 2
Now, job pass variable %%PARM1 to it
ie:
echo Next month is : $1(unix)
echo Next month is : %1 (windows)
Result : 09 if order date is today
You can read this AutoEdit assignment statements by many job on your processing definitions
Best regards
Walty
Walty
- nicolas_mulot
- Nouveau
- Posts: 149
- Joined: 07 Jan 2010 12:00
Hubba,
If I understand your statement:
1°) your closing job runs once a month, the 21st working day every month.
2°) your accounting application uses other jobs which use:
a) the current month before the closing job has run and which should use
b) the next month after the closing job has run.
If this is true, the closing job should act as a trigger to set the value.
The calculation I gave you in my previous post is still valid, but should be applied only on the closing job. As a reminder:
%%FIRST_CUR_MONTH=%%OYEAR.%%OMONTH.01
%%SOME_DATE_NEXT_MONTH=%%CALCDATE %%FIRST_CUR_MONTH +32
%%NEXT_MONTH=%%SUBSTR %%SOME_DATE_NEXT_MONTH 3 2
Then, the result of the calculation should be used by the closing job to set a global variable which in turn, will be used by the other jobs of the application until the next closing.
To achieve that, just add in the “steps” tab of the closing job:
On stmt * codes *
Do set_var %%\ACCOUNT_MONTH = %%NEXT_MONTH
Your other jobs should now use the reference to %%ACCOUNT_MONTH, either in the “Set” tab or in command line.
Cheers
Nicolas Mulot
If I understand your statement:
1°) your closing job runs once a month, the 21st working day every month.
2°) your accounting application uses other jobs which use:
a) the current month before the closing job has run and which should use
b) the next month after the closing job has run.
If this is true, the closing job should act as a trigger to set the value.
The calculation I gave you in my previous post is still valid, but should be applied only on the closing job. As a reminder:
%%FIRST_CUR_MONTH=%%OYEAR.%%OMONTH.01
%%SOME_DATE_NEXT_MONTH=%%CALCDATE %%FIRST_CUR_MONTH +32
%%NEXT_MONTH=%%SUBSTR %%SOME_DATE_NEXT_MONTH 3 2
Then, the result of the calculation should be used by the closing job to set a global variable which in turn, will be used by the other jobs of the application until the next closing.
To achieve that, just add in the “steps” tab of the closing job:
On stmt * codes *
Do set_var %%\ACCOUNT_MONTH = %%NEXT_MONTH
Your other jobs should now use the reference to %%ACCOUNT_MONTH, either in the “Set” tab or in command line.
Cheers
Nicolas Mulot