I need a variable for the next month

All questions about Control-M jobs definitions
Post Reply
User avatar
Hubba
Nouveau
Nouveau
Posts: 69
Joined: 10 Dec 2007 12:00
Location: Boston

I need a variable for the next month

Post by Hubba » 24 Aug 2010 3:18

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?

User avatar
nicolas_mulot
Nouveau
Nouveau
Posts: 149
Joined: 07 Jan 2010 12:00

Post by nicolas_mulot » 24 Aug 2010 5:10

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

User avatar
Hubba
Nouveau
Nouveau
Posts: 69
Joined: 10 Dec 2007 12:00
Location: Boston

Post by Hubba » 25 Aug 2010 2:17

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?

User avatar
Jayant
Nouveau
Nouveau
Posts: 2
Joined: 04 Jun 2010 12:00

Need a variable for next month

Post by Jayant » 25 Aug 2010 3:05

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

User avatar
Hubba
Nouveau
Nouveau
Posts: 69
Joined: 10 Dec 2007 12:00
Location: Boston

Post by Hubba » 25 Aug 2010 3:08

That works but the monthly job flucuates every month. Could be the 26th, the 28th, etc

User avatar
Walty
Nouveau
Nouveau
Posts: 473
Joined: 20 Jan 2006 12:00

Post by Walty » 25 Aug 2010 3:21

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
Best regards
Walty

User avatar
GNappo
Nouveau
Nouveau
Posts: 70
Joined: 03 Sep 2007 12:00
Location: Italy

Post by GNappo » 25 Aug 2010 3:21

Hi Hubba,

you can try this:

1) set a variable (%%a) with current day
2) set a variable (%%b) %%$CALCDATE %%$DATE - %%a
3) set a variable (%%c) %%$CALCDATE %%b +32
4) set a variable (%%d) SUBSTR %%c 1 6

Best Regards

Giuseppe Nappo

User avatar
nicolas_mulot
Nouveau
Nouveau
Posts: 149
Joined: 07 Jan 2010 12:00

Post by nicolas_mulot » 26 Aug 2010 9: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

Post Reply