IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

maximum timestamp value


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Tue Jun 09, 2009 5:22 pm
Reply with quote

Hi

I've an input file with timestamps and bank names as shown below.

I/P file has 3 fields ( 1 to 8 is timestamps ) , ( 13 to 5 is acquired bank name) , ( 20 to 5 is issues bank names)

----+----1----+----2----+----3-
***************************** T
12:00:01 BANK1 BANK2
12:00:01 BANK1 BANK4
12:00:01 BANK2 BANK3
12:00:01 BANK2 BANK1
12:00:01 BANK2 BANK4
12:00:02 BANK1 BANK2
12:00:02 BANK1 BANK4
12:00:03 BANK2 BANK3
12:00:04 BANK1 BANK2
12:00:04 BANK1 BANK4
12:00:04 BANK2 BANK3
12:00:04 BANK2 BANK1
12:00:04 BANK2 BANK4
12:00:04 BANK1 BANK4
12:00:04 BANK2 BANK3
12:00:04 BANK2 BANK1
12:00:04 BANK2 BANK4

So my output should have the following:

The highest timestamp value :
The bank name which appears max times in that timestamp set :
The count of the same bank in acquired column :
The count of the same bank in issued column :

hence the output should be as follows :

MAX TS = 12:00:04
MAX BANK OCCURENCE IS = BANK2
ACQUIRED = 6
ISSUED = 1
TOTAL = 7

How can this be done using DFSORT ?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 09, 2009 10:12 pm
Reply with quote

Ambili S,

The following DFSORT JCL will give you the desired results


Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=your input file,DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE) 
//SYSIN    DD *                                             
  SORT FIELDS=(1,8,CH,D,13,5,CH,A,20,5,CH,A)               
  OUTREC IFTHEN=(WHEN=INIT,                                 
  OVERLAY=(25:SEQNUM,8,ZD,RESTART=(01,8),X,                 
              SEQNUM,8,ZD,RESTART=(13,5),X,                 
              SEQNUM,8,ZD,RESTART=(20,5),X)),               
  IFTHEN=(WHEN=GROUP,BEGIN=(25,8,ZD,EQ,1),PUSH=(52:ID=8))   
                                                           
  OUTFIL INCLUDE=(52,8,ZD,EQ,1),                           
  REMOVECC,NODETAIL,BUILD=(80X),                           
  TRAILER1=('TCNT,C''',MAX=(34,8,ZD,M11,LENGTH=8),C'''',/, 
            'STMP,C''',1,8,C'''',/,                         
            'NAME,C''',13,5,C'''',80:X)                     
/*                                                         
//STEP0200 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SYMNAMES DD DSN=&&T1,DISP=SHR 
//SORTIN   DD DSN=your input file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  INCLUDE COND=(1,8,CH,EQ,STMP,AND,20,5,CH,EQ,NAME)     
  SORT FIELDS=COPY                                     
  OUTREC OVERLAY=(TCNT,SEQNUM,8,ZD,                     
                  1,8,ZD,ADD,9,8,ZD,M11,LENGTH=8,80:X) 
  OUTFIL REMOVECC,NODETAIL,                             
  TRAILER1=('MAX TIME STAMP        = ',STMP,/,         
            'MAX BANK OCCURENCE IS = ',NAME,/,         
            'ACUIRED               = ',TCNT,/,         
            'ISSUED                = ',9,8,/,           
            'TOTAL                 = ',17,8)           
/*


The output from this job is :

Code:

MAX TIME STAMP        = 12:00:04   
MAX BANK OCCURENCE IS = BANK2     
ACUIRED               = 00000006   
ISSUED                = 00000001   
TOTAL                 = 00000007   
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Wed Jun 10, 2009 8:03 am
Reply with quote

Hi Skolusu

Thanks for this. It would really be of great help if you could explain me the same , especially the OVERLAY and TRAILER in step0100 .
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 10, 2009 11:09 pm
Reply with quote

Ambili S,

I forgot to remove some unnecessary stuff in step0100 as I was playing around to get everything done in a single step. But it is not possible to get everything done in single step, we can use the following job

Explanation of the control cards:

1.Sort the Timestamp field D and Bank name ascending

2.Now we have the max time stamp values at the top. we put a seqnum at pos 25 for every changing timestamp value using restart parm. We also put another seqnum at pos 33 for every changing bank name using the restart parm.

we use the seqnum at pos 25 to group the similar records of same timestamp with when=group statement. By doing this the max timestamp field records will have group id of 1 at pos 41 and these are the only records which we are interested in. so we write these records to another temp file named max rec which we will use in step0200 as input instead of spinning thru the entire file once again.

Now we create 3 symbols to get the records for the bank name in issued column. Pos33 which has the max seqnum will give you the bank name. So inorder to get the max record value we use reporting features and create 3 symbols.

TCNT will have the max value of a bank for that timestamp set.
STMP will have the max timestamp
Name will have the name of the bank that occurred max times in that set.

Now we use these symbols in step0200 which gives you the desired results

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=your input file,DISP=SHR
//SORTOUT  DD DSN=&&S1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)           
//MAXREC   DD DSN=&&I1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)           
//SYSIN    DD *                                                       
  SORT FIELDS=(1,8,CH,D,13,5,CH,A)                                   
  OUTREC IFTHEN=(WHEN=INIT,                                           
  OVERLAY=(25:SEQNUM,8,ZD,RESTART=(01,8),SEQNUM,8,ZD,RESTART=(13,5))),
  IFTHEN=(WHEN=GROUP,BEGIN=(25,8,ZD,EQ,1),PUSH=(41:ID=8))           

  OUTFIL FNAMES=MAXREC,INCLUDE=(41,8,ZD,EQ,1),BUILD=(1,24)             
                                                                     
  OUTFIL INCLUDE=(41,8,ZD,EQ,1),                                     
  REMOVECC,NODETAIL,BUILD=(80X),                                     
  TRAILER1=('TCNT,C''',MAX=(33,8,ZD,M11,LENGTH=8),C'''',/,           
            'STMP,C''',1,8,C'''',/,                                   
            'NAME,C''',13,5,C'''',80:X)                               
/* 
//STEP0200 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SYMNAMES DD DSN=&&S1,DISP=SHR                         
//SORTIN   DD DSN=&&I1,DISP=SHR                         
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  INCLUDE COND=(20,5,CH,EQ,NAME)     
  SORT FIELDS=COPY                                       
  OUTREC OVERLAY=(TCNT,SEQNUM,8,ZD,                     
                  1,8,ZD,ADD,9,8,ZD,M11,LENGTH=8,80:X)   
  OUTFIL REMOVECC,NODETAIL,                             
  TRAILER1=('MAX TIME STAMP        = ',STMP,/,           
            'MAX BANK OCCURENCE IS = ',NAME,/,           
            'ACUIRED               = ',TCNT,/,           
            'ISSUED                = ',9,8,/,           
            'TOTAL                 = ',17,8)             
//*
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Thu Jun 11, 2009 11:22 am
Reply with quote

Thank u .this gave me a clear picture now.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
No new posts Timestamp difference and its average ... DB2 11
No new posts SORT ERROR PARAMETER VALUE EXCEEDS M... DFSORT/ICETOOL 12
No new posts To get previous month from current ti... SYNCSORT 7
Search our Forums:

Back to Top