Question & Answer
Question
How do I automatically change the parameter data for a parameter that should always contain the last day of the previous month?
Answer
You will use a user-defined parameter (Previous date - PRVDATE) that contains the last day of the previous month. You will set up a job to run on the first day of every month. On the Schedule page of the job properties, select Monthly from within Dates to run. Select a month that has the first day available. Days that are not available are shown as dark gray. Click Day 1. This will cause the day to become green. Select the Specified days of each month option under Details from within Dates to run. The command to process for the job would be as follows:
CHGDTAJS PARM(PRVDATE) PARMDATA('&PYMD')
Note: The PYMD parameter specified within this command is converted to the previous date in year month day format. Now all jobs that use the PRVDATE parameter will receive the last day of the previous month in year month day format..
Another way would be to create a user-defined parameter that uses a formula to calculate the last day of the previous month. To create the parameter, you should complete the following:
1. | In IBM i Navigator, select Work Management. |
2. | Right click Advanced Job Scheduler and select Properties, Advanced Job Scheduler Properties displays. |
3. | Select Command Variables. A list of the current command variables is displayed. |
4. | Click New to go to the New Command Variable display. |
5. | Specify the name of the new command variable. |
6. | Specify 6 as the replacement length. |
7. | Select the Use Formula button. |
8. | Specify *QYMD(d=1,d-1) as the formula. The Q in the formula means to start with the system date as a base. If an A was used (*AYMD(d=1,d-1), it would use the submit date as the base. The YMD means to return the date in year, month, and day format. The d=1 sets the date to the first day of the month and the d-1 subtracts 1 from the date, giving the last day of the previous month. |
9. | When you are finished specifying all the pertinent information, click OK to add the command variable to the list of existing variables. |
Related Information
Was this topic helpful?
Document Information
Modified date:
18 December 2019
UID
nas8N1020333