|
View previous topic :: View next topic
|
| Author |
Message |
ruben.d
New User
Joined: 13 Nov 2007 Posts: 3 Location: india
|
|
|
|
Hi,
Currently we populate the current julian date to the header with the below code
OPTION COPY
OUTFIL REMOVECC,
HEADER1=('H',X,YDDDNS=(4D))
The job A ran on Jan 11th 2012
Current header record of output file:
H 2012011
New requirement:
--------------------
The output file header record should be written with current month 15th julian date irrespective of the current date of job execution.
For example :
Scenario -1
If my job A runs on Jan 20th 2012, then the output file header should have Jan 15th 2012 julian date (2012015)
Scenario -2
If my job A runs on Feb 8th 2012, then the output file header should have Feb 15th 2012 julian date (2012046)
Please let me know how can we achieve this?
Thanks,
Ruben |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
A solution, using the generation of a SYMNAME for the modified date, thus requiring one extra step, but not reading any particular data.
I couldn't get the system date in, day changed to 15 and the date conversion done in one OVERLAY or BUILD within a reasonable amount of time. Doesn't mean it can't be done...
| Code: |
//SYMNGEN EXEC PGM=SORT
//SYSIN DD *
OPTION COPY,STOPAFT=1
OUTFIL IFOUTLEN=80,
IFTHEN=(WHEN=INIT,BUILD=(C'HEADER-DATE,C''',DATE1)),
IFTHEN=(WHEN=INIT,OVERLAY=(21:C'15',
15:15,8,Y4T,TOJUL=Y4T,C''''))
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&SYM,SPACE=(TRK,1),DISP=(,PASS),UNIT=SYSDA
//SORTIN DD *
The sortin for this step could be any dataset you like, as long as it is F and has
at least one record. If it has more than one, the STOPAFT=1 will stop it causing problems
//HEADADD EXEC PGM=SORT
//SYMNAMES DD DSN=&&SYM,DISP=(OLD,PASS)
//SYMNOUNT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=('H',X,HEADER-DATE)
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
TEST1
TEST2
TEST3
TEST4
TEST5
TEST6 |
The symbol generated for the SYMNAMES DD in the next step (pasted from the output of the second step, where it is printed due to the SYMNOUT DD):
| Code: |
------- ORIGINAL STATEMENTS FROM SYMNAMES -------
HEADER-DATE,C'2012015'
------------------ SYMBOL TABLE -----------------
HEADER-DATE,C'2012015' |
The Sort cards from the second step, after symbol substitution, pasted from the sort output messages:
| Code: |
OPTION COPY
OUTFIL REMOVECC,HEADER1=('H',X,C'2012015')
|
The output:
| Code: |
H 2012015
TEST1
TEST2
TEST3
TEST4
TEST5
TEST6 |
I have tested it with other dates up to June this year.
Edit: Maybe the code does not use the IFTHENs: they were part of an "attempt" and they stayed for setting the output record-length to 80. Maybe instead an appropriate number of Xs could be used to get the length. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
ruben.d,
Assuming that your LRECL =80 and RECFM=FB, the following DFSORT JCL will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
TEST1
TEST2
TEST3
TEST4
TEST5
TEST6
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:DATE2,C'15')),
IFTHEN=(WHEN=INIT,OVERLAY=(89:81,8,Y4T,TOJUL=Y4T))
OUTFIL REMOVECC,BUILD=(1,80),
HEADER1=('H',X,89,7)
//* |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|