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 

Formatting the date field using SORT

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


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Fri Jul 02, 2004 4:33 pm    Post subject: Formatting the date field using SORT Reply with quote

Hi
Please tell me whether I can reformat the date as follows

Input File
----------

Code:

5/28/99
5/14/99
1/3/00
2/2/04
4/15/99
3/15/99
11/1/02
3/31/99
4/22/99


Output File

Code:

05/28/99
05/14/99
01/03/00
02/02/04
04/15/99
03/15/99
11/01/02
03/31/99
04/22/99

This field is at poistion 97 and length of 8.
File format is FB and LRECL is 655.
Appreciate any help ..
_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Jul 02, 2004 5:21 pm    Post subject: Reply with quote

Somu,

This DFSORT/ICETOOL job will give you what you want.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T3 DD DSN=&&T3,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T4 DD DSN=&&T4,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//    DD DSN=*.T3,VOL=REF=*.T3,DISP=(OLD,PASS)
//    DD DSN=*.T4,VOL=REF=*.T4,DISP=(OLD,PASS)
//OUT DD DSN=...   output file
//TOOLIN DD *
  COPY FROM(IN) USING(CTL1)
  SORT FROM(CON) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
* Add a sequence number to each record
  INREC FIELDS=(1,655,656:SEQNUM,8,ZD)
* IN->T1: Get records with d/m/yy and convert to 0d/0m/yy
  OUTFIL FNAMES=T1,
    INCLUDE=(98,1,CH,EQ,C'/',AND,100,1,CH,EQ,C'/'),
    OUTREC=(1,96,97:C'0',97,2,C'0',99,4,105,559)
* IN->T2: Get records with dd/m/yy and convert to dd/0m/yy
  OUTFIL FNAMES=T2,
    INCLUDE=(99,1,CH,EQ,C'/',AND,101,1,CH,EQ,C'/'),
    OUTREC=(1,96,97:97,3,C'0',100,4,105,559)
* IN->T3: Get records with d/mm/yy and convert to 0d/mm/yy
  OUTFIL FNAMES=T3,
    INCLUDE=(98,1,CH,EQ,C'/',AND,101,1,CH,EQ,C'/'),
    OUTREC=(1,96,97:C'0',97,7,105,559)
* IN->T4: Get records with dd/mm/yy
  OUTFIL FNAMES=T4,
    SAVE
/*
//CTL2CNTL DD *
* T1/T2/T3/T4->OUT:  Sort on sequence number to get records
* back in their original order.  Remove sequence numbers.
  SORT FIELDS=(656,8,ZD,A)
  OUTREC FIELDS=(1,655)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort


Last edited by Frank Yaeger on Tue Jan 04, 2005 2:02 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
somuk
Beginner


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Tue Jul 06, 2004 5:21 pm    Post subject: Reply with quote

Thank You Frank.
_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Jan 04, 2005 2:13 pm    Post subject: Reply with quote

With z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 Dec, 2004), you can use DFSORT's new IFTHEN clauses to do this more easily and efficiently as follows:

Code:

//S2    EXEC  PGM=ICEMAN
//SYSOUT DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
* Get records with d/m/yy and convert to 0d/0m/yy
  INREC IFTHEN=(WHEN=(98,1,CH,EQ,C'/',AND,100,1,CH,EQ,C'/'),
     BUILD=(1,96,97:C'0',97,2,C'0',99,4,105,551)),
* Get records with dd/m/yy and convert to dd/0m/yy
    IFTHEN=(WHEN=(99,1,CH,EQ,C'/',AND,101,1,CH,EQ,C'/'),
     BUILD=(1,96,97:97,3,C'0',100,4,105,551)),
* Get records with d/mm/yy and convert to 0d/mm/yy
    IFTHEN=(WHEN=(98,1,CH,EQ,C'/',AND,101,1,CH,EQ,C'/'),
     BUILD=(1,96,97:C'0',97,7,105,551))
/*


This DFSORT job only takes one COPY pass whereas the DFSORT/ICETOOL job I showed above takes one COPY pass and one SORT pass.

For complete information on all of the new DFSORT and ICETOOL functions available with these DFSORT PTFs, see:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
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