recurring jobs and date parameters

 6 Replies
 0 Subscribed to this topic
 17 Subscribed to this forum
Sort:
Author
Messages
Greg Moeller
Veteran Member Send Private Message
Posts: 1498
Veteran Member

The need:  Schedule a reccurring job (recdef) to automatically feed in a required date parameter that is always moving.  Users want the job to run every monday with the previous monday's date in it.

Anyone ever fool around with the GEN/JOBSTEP table -specifically the PARAMS column in a script?

I'm told that 2201001041 somehow is representative of 010410  or maybe 01042010, but I can't seem to get the pattern.

Anyone have any suggestions/thoughts/comments ?  Is there an easier way to do this?

Anything is welcome,

-Greg

Greg Moeller
Veteran Member Send Private Message
Posts: 1498
Veteran Member
We are looking at scheduling specifically HR155 but this would come in handy in other jobs as well.
Sam Simpson
Veteran Member Send Private Message
Posts: 239
Veteran Member
I used to create a cobol program to calculate for dates and other variables then submit the job with the cobol program. You can also create a script to submit a job (ie wtsubmit) and that script can be called from a token or within a cobol program.
Deleted User
New Member Send Private Message
Posts: 0
New Member
We do have a script that will rngdbdump out the JOBSTEP table for a specific user / job and then manipulate the parameter fields based upon the needs. If you can calculate the last date, you could simply do a sed search and replace, otherwise you will need to calculate the column number for that specific program/job and manipulate it.

Please note, if any parameters ever change for that job, you will need to revisit the script to ensure the column numbers still remain the same for the parameter you are changing. In regard to the format of the date, it could vary based on how the field is defined in the .scr for the program. By viewing the JOBSTEP table for a specific user/job you should be able to determine the date formatting.
wilcoxmad
Veteran Member Send Private Message
Posts: 87
Veteran Member

I've added code to the COBOL program that says if the parameter date is zero then calculate a date and move it to the parameter date. If the user enters dates on the parameter screen this routine will not override those dates.

In this example I am getting the prior Friday's date and the current Thursday's date

So if I ran it today I would get 20100101 and 20100107:

           MOVE ZERO                    TO WS-NBR-DAYS.

      * IF DERIVING PRM-FROM-DATE FROM SYSTEM-DATE, USE THE PREVIOUS
      * FRIDAY THAT WAY WE ARE PROCESSING THE PRIOR WEEKS DATA.
      * WSDR-WEEKDAY-NBR; 1 = SUNDAY, 7 = SATURDAY

002500     IF (PRM-FROM-DATE = ZERO)
               MOVE  WS-SYSTEM-DATE-YMD TO WSDR-FR-DATE
               PERFORM 900-DAY-FROM-DATE
               COMPUTE WS-NBR-DAYS = WSDR-WEEKDAY-NBR + 2
               IF (WS-NBR-DAYS > 6)
                   SUBTRACT 7              FROM WS-NBR-DAYS.

002500     IF (PRM-FROM-DATE = ZERO)
               MOVE WS-SYSTEM-DATE-YMD TO WSDR-FR-DATE
004900         PERFORM 900-DATE-TO-JULIAN
005000         COMPUTE WSDR-JULIAN-DAYS = WSDR-JULIAN-DAYS - WS-NBR-DAYS
005100         PERFORM 900-JULIAN-TO-DATE
005200         MOVE WSDR-FR-DATE       TO PRM-TO-DATE
005000         COMPUTE WSDR-JULIAN-DAYS = WSDR-JULIAN-DAYS - 6
005100         PERFORM 900-JULIAN-TO-DATE
005200         MOVE WSDR-FR-DATE       TO PRM-FROM-DATE.
005000     DISPLAY "PRM-FROM-DATE = " PRM-FROM-DATE.                                            005000     DISPLAY "PRM-TO-DATE = "   PRM-TO-DATE.

.

John Henley
Send Private Message
Posts: 3351
That is a common technique, but since require a retrofit every time the program is updated via a CTP or MSP or upgrade, I prefer a wrapper approach to create and submit the job with the desired date.

Thanks for using the LawsonGuru.com forums!
John
Greg Moeller
Veteran Member Send Private Message
Posts: 1498
Veteran Member
Since we really don't have a programming dept here, and I was in kind of a hurry, I did successfully write a mod of the JOBSTEP table into my script. Basically just does a rngdbdump a sed manipulation and an importdb back into JOBSTEP.

Thanks for all of your suggestions, though. If time permits I'd like to investigate the wrapper approach.