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 

append DB2 timestamp to all records

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


Joined: 21 Apr 2004
Posts: 12
Topics: 9

PostPosted: Sun May 02, 2004 11:13 am    Post subject: append DB2 timestamp to all records Reply with quote

Can we insert a DB2 timestamp in an existing file using JCl? I have an input file and I want to append timestamp(yyyy-mm-dd-hh.mm.ss.nnnnnn) for all the records.The timestamp is the last column in the file. I need this urgently Question

Tia

murali
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Sun May 02, 2004 9:52 pm    Post subject: Reply with quote

Murali,

Please follow the rules. Avoid putting "urgent" or "urgently" in your topics. Sort products till date have no ability of producing the micro seconds portion in the time stamp. The micro seconds is a number between 0 and 99999. But you can eitehr default a value like '000000' to the micro seconds portion or generate dynamically by assigning a sequence number of sort.

You haven't provided any details like lrecl and recfm of your input file. Assuming that your input file is of lrecl=80 and recfm=fb, the following jcl will give you the desired results.

Solution: 1

Code:

//STEP0100  EXEC PGM=SORT                 
//SYSOUT    DD SYSOUT=*                   
//SORTIN    DD DSN=YOUR INPUT FILE,
//             DISP=SHR                         
//SORTOUT   DD DSN=YOUR OUTPUT FILE,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y,),RLSE)                   
//SYSIN     DD *
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,80,DATE4,C'.',SEQNUM,6,ZD)
/*



If you get an error on DATE4 parm then you are probably using an older version of DFSORT. try this job.
Code:

//STEP0100  EXEC PGM=SORT                 
//SYSOUT    DD SYSOUT=*                   
//SORTIN    DD DSN=YOUR INPUT FILE,
//             DISP=SHR                         
//SORTOUT   DD DSN=YOUR OUTPUT FILE,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y,),RLSE)                   
//SYSIN     DD *
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,80,DATE=(4MD-),C'-',TIME(24.),C'.',SEQNUM,6,ZD)
/*


If you still get an error on date field then you are probably using the OLDEST version of sort available.Then in that case you can try this job.

Code:

//STEP0100  EXEC PGM=ICETOOL               
//TOOLMSG   DD SYSOUT=*                   
//DFSMSG    DD SYSOUT=*                   
//NULL      DD *
DUMMY RECORD
//IN        DD DSN=YOUR INPUT FILE,
//             DISP=SHR
//T1        DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT       DD DSN=YOUR OUTPUT FILE,
//             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 *                                           
  OUTFIL FNAMES=T1,NODETAIL,                               
  HEADER1=(DATE=(4MD-),'-',TIME(24.))                     
//CTL2CNTL  DD *                                           
  OUTFIL FNAMES=CTL3CNTL,                                 
  OUTREC=(C' OUTREC FIELDS=(1,80,',C'C''',2,19,             
          C'.''',C',SEQNUM,6,ZD',C')',80:X)               
/*


If none of the jobs work then you better code a cobol program beacuse you are having a sort version that can be refered as very very old. I don't know what features it supports.

However on the flip side if you have the latest version of syncsort z/os with the latest feature of db2 support then the following JCL will give you the timestamp as in db2. The first step unloads the timestamp from db2 and creates a control card for the next sort step.

Code:

//STEP0100 EXEC PGM=SORT,PARM='DB2=YOUR DB2 REGION'         
//SYSOUT   DD SYSOUT=*                           
//SORTOUT  DD SYSOUT=*                           
//SORTDBIN DD *                                 
SELECT CHAR(' OUTREC FIELDS=(1,80,C''')                   
      ,CURRENT TIMESTAMP                                 
      ,CHAR(''')')                                       
      ,CHAR(' ')                                         
       FROM                                               
       SYSIBM.SYSDUMMY1
//SORTOUT  DD DSN=USERID.UNLOAD.TIMESTMP,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(TRK,(1,1),RLSE)
//*
//STEP0200  EXEC PGM=SORT                 
//SYSOUT    DD SYSOUT=*                   
//SORTIN    DD DSN=YOUR INPUT FILE,
//             DISP=SHR                         
//SORTOUT   DD DSN=YOUR OUTPUT FILE,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y,),RLSE)                   
//SYSIN     DD DSN=USERID.UNLOAD.TIMESTMP,DISP=OLD
//$ORTPARM  DD *                 
  OPTION COPY                     
/*



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
murali
Beginner


Joined: 21 Apr 2004
Posts: 12
Topics: 9

PostPosted: Thu May 06, 2004 2:39 am    Post subject: Reply with quote

will do that. I used the third example
Back to top
View user's profile Send private message
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