Page 1 of 1

Adding dates in JCL sort

PostPosted: Wed Apr 10, 2013 9:45 am
by deva_048
I have two input fields such as
File1: Input 1: 2013-08-18
File 2: Input 2: 9th postion i have 2.00

O/p should be 2013-08-20

I tried using sync sort by manually hard coded the day 2. But i need to get the day from 2nd file from 9th position and add it in first file.

SORT FIELDS=COPY
OUTREC FIELDS=(1:C'''',2:DATEADD(1,10,DT=(4MD-),+2,DAY), * 12:C'''', 68X)


Please advice...

Code'd

Re: Adding dates in JCL sort

PostPosted: Wed Apr 10, 2013 11:24 am
by BillyBoyo
Please use the Code tags to preserve spacing.

Is there anything on the 2nd file in any of the positions occupied by the date on the first file which would reliably tell you one record or the other? What are the REFCM and LRECL of your files?

Re: Adding dates in JCL sort

PostPosted: Wed Apr 10, 2013 12:24 pm
by deva_048
No Billy. 2nd file by default 9th postion will have some numbers 2 or 3... LRECL=80 RECFM=FB

Re: Adding dates in JCL sort

PostPosted: Wed Apr 10, 2013 1:51 pm
by BillyBoyo
Concatenate your files on SYSIN, 2nd first, 1st second.

I'm unable to test with DATEADD, but you should see that you have all the information for your BUILD (I'd recommend ignoring OUTREC on OUTFIL, BUILD is entirely the same and will not cause confusion with OUTREC) on the current record by this method.

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
                                                         
  INREC IFTHEN=(WHEN=INIT,
             OVERLAY=(81:SEQNUM,1,ZD)),
  IFTHEN=(WHEN=GROUP,BEGIN=(81,1,CH,EQ,C'1'),
                 PUSH=(82:9,1))
  OUTFIL INCLUDE=(81,1,CH,EQ,C'2'),
           BUILD=(C'JUST FOR DEMO>',1,10,C'<>',82,1,C'<')
//SORTIN   DD *
        7
2013-08-18

Output is:

JUST FOR DEMO>2013-08-18<>7<

Re: Adding dates in JCL sort

PostPosted: Wed Apr 10, 2013 2:49 pm
by deva_048
Finally day should be added right? But i didnt see any added dates in output above.

Re: Adding dates in JCL sort

PostPosted: Wed Apr 10, 2013 2:58 pm
by BillyBoyo
I'm unable to test with DATEADD, but you should see that you have all the information for your BUILD (I'd recommend ignoring OUTREC on OUTFIL, BUILD is entirely the same and will not cause confusion with OUTREC) on the current record by this method.


So, take what you have as FIELDS, make it BUILD on OUTFIL changing the +2 to 82,1 and replacing my BUILD. I've no idea about the syntax error and comments you have on your OUTREC.

  BUILD=(C'''',2:DATEADD(1,10,DT=(4MD-),82,1,DAY)


Note: I've taken off the column (the "1:") as the default for BUILD is to start in column one, so putting in the same thing is not needed, confusing, gives you a chance of introducing an error, all for no benefit.