Page 1 of 1

getting current year while using SORT PROC

PostPosted: Tue May 18, 2010 10:03 pm
by pradeep007
In a JCL using SORT PROC, I was concatenating some datasets(SORTIN) and writing to O/P(SORTOUT). The O/P dataset should have current year minus one in heading - which I was specifying in SYSIN, but some how ending with error. Please help me with this.

Re: getting current year while using SORT PROC

PostPosted: Tue May 18, 2010 11:24 pm
by dick scherrer
Hello and welcome to the forum,

So, what have you posted that someone can use to help you? Umm, ahhh, welll, pretty much nothing. . .

You need to post some sample input, sample output from that input, and the "rules for getting from the input to the output. You also need to post the jcl and control statements you used along with the diagnostic information.

Also mention the dsorg and lrecl of all files.

Use the "Code" tag to preserve alignment.

Re: getting current year while using SORT PROC

PostPosted: Tue May 18, 2010 11:34 pm
by pradeep007
I just want syntax for retrieving system date(year specifically) subtract 1 from that. That's it.

Re: getting current year while using SORT PROC

PostPosted: Wed May 19, 2010 1:12 am
by dick scherrer
Hello,

And we just want to you learn/follow the proper way to ask for help. . .

So, post the requested info. . .

Re: getting current year while using SORT PROC

PostPosted: Wed May 19, 2010 12:34 pm
by pradeep007
ok, here is code snippet

//STEP04 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&TEMP1,DISP=(OLD,DELETE,DELETE)
// DD DSN=&&TEMP2,DISP=(OLD,DELETE,DELETE)
// DD DSN=&&TEMP3,DISP=(OLD,DELETE,DELETE)
//SORTOF1 DD DSN=P8768.T3.STATE.FILE,DISP=SHR
//* DISP=(NEW,CATLG),
//* SPACE=(TRK,(1,5),RLSE),UNIT=DISK,
//* DCB=(RECFM=FB,BLKSIZE=27920,LRECL=80)
//SORTOF2 DD DUMMY
//SYSIN DD *
OPTION COPY
OUTFIL FILES=1,
HEADER1=(1:' ',/,
22:'Heading here followed by (here I want current year minus one)',/,
1:' '),
REMOVECC
/*

Temp dataset attributes are same as of SORTOF1

Re: getting current year while using SORT PROC

PostPosted: Wed May 19, 2010 10:59 pm
by Frank Yaeger
You can use a DFSORT job like the following to do what I think you're asking for:

//SETSYM EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
CURYR,S'&YR4.'
//SORTIN DD *
RECORD
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,BUILD=(CURYR)),
     IFTHEN=(WHEN=INIT,
       BUILD=(C'PREVYR,''',1,4,ZD,SUB,+1,EDIT=(TTTT),C'''',80:X))
//STEP04 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN   DD DSN=&&TEMP1,DISP=(OLD,DELETE,DELETE)
//         DD DSN=&&TEMP2,DISP=(OLD,DELETE,DELETE)
//         DD DSN=&&TEMP3,DISP=(OLD,DELETE,DELETE)
//SORTOF1  DD DSN=P8768.T3.STATE.FILE,DISP=SHR
//*           DISP=(NEW,CATLG),
//*           SPACE=(TRK,(1,5),RLSE),UNIT=DISK,
//*           DCB=(RECFM=FB,BLKSIZE=27920,LRECL=80)
//SORTOF2  DD DUMMY
//SYSIN DD *
  OPTION COPY
  OUTFIL FILES=1,
    HEADER1=(1:' ',/,
   22:'HEADING HERE FOLLOWED BY ',PREVYR,/,
     1:' '),
   REMOVECC
/*

Re: getting current year while using SORT PROC

PostPosted: Thu May 20, 2010 1:00 am
by dick scherrer
Hello,

ok, here is code snippet
But you did not post the diagnostic information showing all of the messages and the message ids :(

When you want help (whether it is here or at various vendor support sites) you need to provide as complete information as possible on the first iteration. In the long run, it is mostly your time that is saved. . .

Re: getting current year while using SORT PROC

PostPosted: Thu May 20, 2010 9:05 am
by pradeep007
Thanks Frank it helped, but can that be done in one step instead of two.

Once again thanks alot for helping, Frank.

Also, thanks to Dick for his timely helpful suggestions.

Re: getting current year while using SORT PROC

PostPosted: Thu May 20, 2010 10:45 pm
by Frank Yaeger
but can that be done in one step instead of two.


Why? The first step only reads and writes one record. Why is that a problem?

Re: getting current year while using SORT PROC

PostPosted: Fri May 21, 2010 1:14 pm
by pradeep007
Frank Yaeger wrote:
Why? The first step only reads and writes one record. Why is that a problem?


Just wondering, if by including some lines in SYSIN of my STEP will do the job.