MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Appending system date to the record

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vkrishna2001
Beginner


Joined: 07 Aug 2003
Posts: 46
Topics: 18
Location: Danbury

PostPosted: Wed Jan 21, 2004 12:43 pm    Post subject: Appending system date to the record Reply with quote

Hi,

I have a file of record length 215. I need to append system date to every record at the end of record. The format of date field is

YYYYMMDD

If after midnight and before 18:00 hours then the date appended is

system date - 1 day

If after 18:00 hours then the date appended is

system date

Is this possible with SYNCSORT. We do not have DFSORT on our machine.

Thanks,
Vijayakrishna
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jan 21, 2004 1:12 pm    Post subject: Reply with quote

Vijay,

Use the following JCl if you have the latest version of syncsort.
Code:

//STEP0100  EXEC  PGM=SORT         
//SYSOUT    DD SYSOUT=*
//SORTIN    DD DSN=YOUR INPUT DSN,
//             DISP=SHR                   
//SORTOUT   DD DSN=YOUR OUTPUT DSN,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
//SYSIN     DD    *                 
  SORT FIELDS=COPY                 
  INREC FIELDS=(1,215,DATE1)         
//*


If you get an error on the DATE1 parm try the following JCl.

Code:


//STEP0100 EXEC PGM=SYNCTOOL                               
//*                                                       
//TOOLMSG   DD SYSOUT=*                                   
//DFSMSG    DD SYSOUT=*                                   
//NULL      DD DUMMY,DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)     
//DATE      DD DSN=&D,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE) 
//IN        DD DSN=YOUR INPUT DSN,
//             DISP=SHR                                           
//CTL3OUT   DD DSN=YOUR OUTPUT DSN,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
//TOOLIN    DD *                                           
  COPY FROM(NULL) USING(CTL1)                               
  COPY FROM(DATE) USING(CTL2)                               
  COPY FROM(IN)   USING(CTL3)                         
//CTL1CNTL  DD *                                         
  OUTFIL FNAMES=DATE,HEADER1=(DATE=(MD4/))                 
//CTL2CNTL  DD *                                           
  OUTFIL FNAMES=CTL3CNTL,                                               
  OUTREC=(C' OUTREC FIELDS=(1,215,C',  $ STRING OUTREC FIELDS=(1,215,C 
          X'7D',                       $ OPENING QUOTE                 
          8,4,                         $ year                           
          2,2,                         $ month                         
          5,2,                         $ day                           
          X'7D',                       $ CLOSING QUOTE                 
          C')',80:X)                                                   
//CTL3CNTL  DD DSN=&T,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)


Hope this helps...

Cheers,

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jan 21, 2004 1:13 pm    Post subject: Reply with quote

vijay,

As I was in a hurry I did not fully read your second requirement. Sorry I will post the updated solution later. sorry about that

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkrishna2001
Beginner


Joined: 07 Aug 2003
Posts: 46
Topics: 18
Location: Danbury

PostPosted: Wed Jan 21, 2004 2:12 pm    Post subject: Reply with quote

Kolusu,

We have SYNCSORT FOR Z/OS 1.1 on our machine.

Regards,
Vijayakrishna
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 22, 2004 6:11 am    Post subject: Reply with quote

Vijay,

Sort products cannot handle date arthimetic.Sometimes you can do simple arthimetic as in your case of just subtracting one day with 99% accuracy. I was able to get everything except for a leap year. I couldn't find a way to determine if the year was a leap year. For the time being I hard coded a value of 29 for feb since the current year is a leap year.

A brief explanation of the job.

The first copy operator will use the date1 and time parameters to get the current date and time from the system and we also use arthimetic functions to subtract 1 from year ,1 from month , 1 from day.

We also split the file into 2 records , C00 & T1

C00 will have a record if the time is greater than 18:00:00. For this we don't have to any subtraction , so we just create a control card with the current date.

Now T1 will contain a record if the time is less than 18:00:00. For this file we need to suntract 1 day. This gets tricky when the current is first of the month. we also need to account for 1st of january where we need to subtract an year. The leap year year comes into picture when the current date is 1st of march.

The second copy operator takes the temp file T1 and splits this into 13 files based on the date. But the best part is that it will create only one file at any given time.

we have subtracted 1 from the month and 1 from the day. so let us say the current date is
2004-01-01 , then subtracting 1 from month and 1 from day makes the month and day 0. so we use this logic to split the files.

The first 12 files (C01 - c12) will account for the current date being the first of every month in the calendar

The last file all will account for all dates of all months.

The final copy step concatenates all these datasets and creates the desired output.

Code:

//STEP0100  EXEC  PGM=SYNCTOOL                 
//TOOLMSG   DD SYSOUT=*                       
//DFSMSG    DD SYSOUT=*                       
//OUT       DD SYSOUT=*                       
//IN        DD DSN=YOUR INPUT DSN,           
//             DISP=SHR                       
//NULL      DD *                             
DUMMY RECORD                                 
//C00       DD DSN=&C00,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//T1        DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C01       DD DSN=&C01,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C02       DD DSN=&C02,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C03       DD DSN=&C03,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C04       DD DSN=&C04,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C05       DD DSN=&C05,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C06       DD DSN=&C06,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C07       DD DSN=&C07,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C08       DD DSN=&C08,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C09       DD DSN=&C09,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C10       DD DSN=&C10,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C11       DD DSN=&C11,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//C12       DD DSN=&C12,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//ALL       DD DSN=&ALL,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//OUT       DD DSN=YOUR OUTPUT DSN,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
//TOOLIN    DD *                                                     
  COPY FROM(NULL) USING(CTL1)                                         
  COPY FROM(T1) USING(CTL2)                                           
  COPY FROM(IN) TO(OUT) USING(CTL3)                                   
//CTL1CNTL  DD *                                                     
  INREC FIELDS=(DATE1,X,TIME)                                         
  OUTREC FIELDS=(1,9,10,2,13,2,16,2,20:+1,SUB,5,2,ZD,EDIT=(TT),       
                +1,SUB,7,2,ZD,EDIT=(TT),25:+1,SUB,1,4,ZD,EDIT=(TTTT))
  OUTFIL FNAMES=C00,INCLUDE=(10,6,ZD,GT,180000),                     
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,8,X'7D',C')',80:X)       
  OUTFIL FNAMES=T1,SAVE
//CTL2CNTL  DD *   
  OUTFIL FNAMES=C01,INCLUDE=(20,4,CH,EQ,C'0000'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',25,4,C'1231',X'7D',C')',80:X)
  OUTFIL FNAMES=C02,INCLUDE=(20,4,CH,EQ,C'0100'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0131',X'7D',C')',80:X)
  OUTFIL FNAMES=C03,INCLUDE=(20,4,CH,EQ,C'0200'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0228',X'7D',C')',80:X)
  OUTFIL FNAMES=C04,INCLUDE=(20,4,CH,EQ,C'0300'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0331',X'7D',C')',80:X)
  OUTFIL FNAMES=C05,INCLUDE=(20,4,CH,EQ,C'0400'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0430',X'7D',C')',80:X)
  OUTFIL FNAMES=C06,INCLUDE=(20,4,CH,EQ,C'0500'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0531',X'7D',C')',80:X)
  OUTFIL FNAMES=C07,INCLUDE=(20,4,CH,EQ,C'0600'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0630',X'7D',C')',80:X)
  OUTFIL FNAMES=C08,INCLUDE=(20,4,CH,EQ,C'0700'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0731',X'7D',C')',80:X)
  OUTFIL FNAMES=C09,INCLUDE=(20,4,CH,EQ,C'0800'),                       
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0831',X'7D',C')',80:X)
  OUTFIL FNAMES=C10,INCLUDE=(20,4,CH,EQ,C'0900'),                     
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'0930',X'7D',C')',80:X)
  OUTFIL FNAMES=C11,INCLUDE=(20,4,CH,EQ,C'1000'),                     
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'1031',X'7D',C')',80:X)
  OUTFIL FNAMES=C12,INCLUDE=(20,4,CH,EQ,C'1100'),                     
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,C'1130',X'7D',C')',80:X)
  OUTFIL FNAMES=ALL,SAVE,                                             
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,6,22,2,X'7D',C')',80:X)   
//CTL3CNTL  DD DSN=&C00,DISP=OLD,VOL=REF=*.C00   
//          DD DSN=&C01,DISP=OLD,VOL=REF=*.C01   
//          DD DSN=&C02,DISP=OLD,VOL=REF=*.C02   
//          DD DSN=&C03,DISP=OLD,VOL=REF=*.C03   
//          DD DSN=&C04,DISP=OLD,VOL=REF=*.C04   
//          DD DSN=&C05,DISP=OLD,VOL=REF=*.C05   
//          DD DSN=&C06,DISP=OLD,VOL=REF=*.C06   
//          DD DSN=&C07,DISP=OLD,VOL=REF=*.C07   
//          DD DSN=&C08,DISP=OLD,VOL=REF=*.C08   
//          DD DSN=&C09,DISP=OLD,VOL=REF=*.C09   
//          DD DSN=&C10,DISP=OLD,VOL=REF=*.C10   
//          DD DSN=&C11,DISP=OLD,VOL=REF=*.C11   
//          DD DSN=&C12,DISP=OLD,VOL=REF=*.C12   
//          DD DSN=&ALL,DISP=OLD,VOL=REF=*.ALL   
/*


I would suggest an alternate solution to cover the leap year also. Use DB2 and unload a single with current date and current - 1 day from sysibm.sysdummy1. use the dates in sort step to get the desired results.

Code:

//STEP0100 EXEC PGM=IKJEFT01                                 
//SYSTSPRT DD  SYSOUT=*,DCB=BLKSIZE=121                     
//SYSPRINT DD  SYSOUT=*                                     
//SYSTSIN  DD  *                                             
  DSN SYSTEM(XXXX)                                           
  RUN PROGRAM(DSNTIAUL) -                                   
      PLAN(DSNTIAUL)    -                                   
      PARMS('SQL')      -                                   
      LIB('DB2P.RUNLIB.LOAD')                               
//SYSREC00 DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//SYSPUNCH DD DUMMY                                         
//SYSIN    DD  *                                             
 SELECT CURRENT DATE                                         
       ,DATE(CURRENT DATE - 1 DAY)                           
   FROM SYSIBM.SYSDUMMY1                                     
   ;                                                         
//STEP0200  EXEC  PGM=ICETOOL                             
//TOOLMSG   DD SYSOUT=*                                   
//DFSMSG    DD SYSOUT=*                                   
//DATE      DD DSN=&T1,DISP=OLD                           
//IN        DD DSN=YOUR INPUT DSN,           
//             DISP=SHR                       
//C1        DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//C2        DD DSN=&C2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT       DD DSN=YOUR OUTPUT DSN,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
//TOOLIN    DD  *                                                     
  COPY FROM(DATE) USING(CTL1)                                         
  COPY FROM(IN) TO(OUT) USING(CTL2)                                   
//CTL1CNTL  DD  *                                                     
  INREC FIELDS=(1,20,X,TIME)                                           
  OUTREC FIELDS=(1,21,22,2,25,2,28,2)                                   
  OUTFIL FNAMES=C1,INCLUDE=(10,6,ZD,LT,180000),                         
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,6,2,9,2,X'7D',C')',80:X)
  OUTFIL FNAMES=C2,SAVE,                                               
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',11,4,16,2,19,2,X'7D',C')',   
          80:X)                                                         
//CTL2CNTL  DD DSN=&C1,DISP=OLD,VOL=REF=*.C1                           
//          DD DSN=&C2,DISP=OLD,VOL=REF=*.C2                           
/*

Hope this helps..

cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkrishna2001
Beginner


Joined: 07 Aug 2003
Posts: 46
Topics: 18
Location: Danbury

PostPosted: Wed Jan 28, 2004 1:22 pm    Post subject: Reply with quote

Hi Kolusu,

I am sorry I did not respond to your solution. The first solution is overwhelming. It may be difficult to understand for the people here whoever is going to maintain this. I tried the second one. STEP100 gave some problem which I will try to sort out later. As I know the output of this step I simulated that for the second step. The record length of input file changed from 215 to 221 and so I changed the parameter accordingly. It worked well. I do not want to bother you much. We use SYNCSORT in lot of applications but I did not find any JOBS in which SYNCTOOL is executed. Is there a reference manual available somewhere for SYNCTOOL. Please let me know.

Once again thanks for the solution.

Regards,
Vijayakrishna
Back to top
View user's profile Send private message Send e-mail
ofer71
Intermediate


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Wed Jan 28, 2004 2:46 pm    Post subject: Reply with quote

Hi

Here is a REXX solution:
Code:
/* REXX */                                         
                                                   
ADDRESS TSO "EXECIO * DISKR INFILE (STEM IN. FINIS"
                                                   
IF TIME('H') < 18 THEN                             
  CURRDATE = DATE('S',DATE('C') - 1,'C')           
ELSE                                               
  CURRDATE = DATE('S')                             
                                                   
DO I = 1 TO IN.0                                   
  IN.I = IN.I CURRDATE                             
END                                                 
                                                   
ADDRESS TSO "EXECIO * DISKW OUTFILE (STEM IN. FINIS"
                                                   
EXIT                                               


O.
________
buy vapormatic


Last edited by ofer71 on Sat Feb 05, 2011 11:11 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jan 28, 2004 7:16 pm    Post subject: Reply with quote

Vijay,

SYNCTOOL is an unsupported feature of syncsort and there is no documentation at all. Syncsort inc claims that they provide synctool as a mere compatibility tool to DFSORT'S ICETOOL. Icetool is very powerful and it has many features. A vast majority of the features of ICETOOL aren't supported by synctool.

You can split the synctool job into a regular sort job but it would involve more steps.

Code:

//STEP0200  EXEC  PGM=SORT                             
//SYSOUT    DD SYSOUT=*                                   
//SORTIN    DD DSN=&T1,DISP=OLD                           
//C1        DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//C2        DD DSN=&C2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN     DD  *                                                     
  INREC FIELDS=(1,20,X,TIME)                                           
  OUTREC FIELDS=(1,21,22,2,25,2,28,2)                                   
  OUTFIL FNAMES=C1,INCLUDE=(10,6,ZD,LT,180000),                         
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',1,4,6,2,9,2,X'7D',C')',80:X)
  OUTFIL FNAMES=C2,SAVE,                                               
  OUTREC=(C' OUTREC FIELDS=(1,215,C',X'7D',11,4,16,2,19,2,X'7D',C')',   
          80:X)                                                         
/*
//STEP0300  EXEC  PGM=SORT                             
//SYSOUT    DD SYSOUT=*                                   
//SORTIN    DD DSN=YOUR INPUT DSN,           
//             DISP=SHR                       
//SORTOUT   DD DSN=YOUR OUTPUT DSN,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
//SYSIN     DD DSN=&C1,DISP=OLD,VOL=REF=*.C1                           
//          DD DSN=&C2,DISP=OLD,VOL=REF=*.C2                           
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group