IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

Control break and select 1st max timestamp set record in JCL


 
IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Suceender Kumar

New User


Joined: 10 Jan 2008
Posts: 29
Location: Chennai, India

PostPosted: Mon Mar 25, 2013 2:48 pm
Reply with quote

Hi,

I have the following input file in which i need to select the max timestamp records based on the EMP# and TASK ID. We need to use SORT, SYNCSORT and not icetool. Please see the example below.

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

Code:

EMP#         TASK ENTERED                TASK ID     TASK NAM  MANAGER
22215687     2013-02-16-06.30.16.071719  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.631131  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.724981  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.919678  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.982218  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.982418  0000001122  DESG CHG  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-11-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-11-23.32.52.982418  0000001123  BONUS AD  CAROL R


Output File
------------

Code:

EMP#         TASK ENTERED                TASK ID     TASK NAM  MANAGER
22215687     2013-02-16-06.30.16.071719  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.631131  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.724981  0000001122  DESG CHG  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R


Thanks in advance.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1689
Location: Tiruppur, India

PostPosted: Mon Mar 25, 2013 3:04 pm
Reply with quote

Hello,
Quote:
select the max timestamp records based on the EMP# and TASK ID.

For the same EMP# and TASK ID there are multiple entries on the output, But you said you wanted only the maximum timestamp.

A little more explanation would certainly help.
Code:
22215687     2013-02-16-06.30.16.071719  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.631131  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.724981  0000001122  DESG CHG  CAROL R
Back to top
View user's profile Send private message
Suceender Kumar

New User


Joined: 10 Jan 2008
Posts: 29
Location: Chennai, India

PostPosted: Mon Mar 25, 2013 3:12 pm
Reply with quote

Sorry. I need the max date recrods. So you can consider the first 10 byte of TASK ENTERED field.

Group By EMP#, TASK ID.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Tue Mar 26, 2013 4:43 pm
Reply with quote

Hi Kumar,

Try this code...

Code:

//STEP01 EXEC PGM=SORT                                               
//SYSPRINT DD SYSOUT=*                                               
//SYSOUT   DD SYSOUT=*                                               
//SORTOUT  DD DSN=&&TEMP1,DISP=(,PASS,DELETE),SPACE=(CYL,(1,1),RLSE) 
//SORTXSUM DD DSN=&&TEMP2,DISP=(,PASS,DELETE),SPACE=(CYL,(1,1),RLSE) 
//SORTIN   DD *                                                       
22215687     2013-02-16-06.30.16.071719  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.631131  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.724981  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.919678  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.982218  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.982418  0000001122  DESG CHG  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-11-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-11-23.32.52.982418  0000001123  BONUS AD  CAROL R
//SYSIN   DD *                     
  SORT FIELDS=(1,8,CH,A,42,10,CH,A)
  SUM FIELDS=NONE,XSUM             
//*
//STEP02 EXEC PGM=SORT                                               
//SYSPRINT DD SYSOUT=*                                               
//SYSOUT   DD SYSOUT=*                                               
//SORTJNF1 DD DSN=&&TEMP1,DISP=SHR                                   
//SORTJNF2 DD DSN=&&TEMP2,DISP=SHR                                   
//OUTPUT1  DD DSN=&&TEMP3,DISP=(,PASS,DELETE),SPACE=(CYL,(1,1),RLSE)
//SYSIN   DD *                                                       
  JOINKEYS FILES=F1,FIELDS=(1,8,A,42,10,A,14,10,A)                   
  JOINKEYS FILES=F2,FIELDS=(1,8,A,42,10,A,14,10,A)                   
  REFORMAT FIELDS=(F1:1,80,F2:1,80)                                 
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(151:81,80,81:1,8,14,26,42,10,     
                                    81:SEQNUM,2,ZD,RESTART=(81,44))),
        IFTHEN=(WHEN=(81,2,ZD,GE,+2),OVERLAY=(1:151,80,151:80X))
           OUTFIL FNAMES=OUTPUT1,OUTREC=(1,80,/,151,80)
//*                                           
//STEP03 EXEC PGM=SORT                         
//SYSPRINT DD SYSOUT=*                         
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD DSN=&&TEMP3,DISP=SHR             
//SORTOUT DD SYSOUT=*                         
//SYSIN   DD *                                 
  SORT FIELDS=COPY                             
  OMIT COND=(1,1,CH,EQ,C' ')


Thanks
-3nadh
Back to top
View user's profile Send private message
Suceender Kumar

New User


Joined: 10 Jan 2008
Posts: 29
Location: Chennai, India

PostPosted: Mon Apr 01, 2013 3:46 pm
Reply with quote

Thanks a lot bodatrinadh! It worked! Sorry for my late reply.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Mon Apr 01, 2013 5:30 pm
Reply with quote

You might like to try this:

Code:
//STEP01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN   DD *
  OPTION COPY
* OPTION EQUALS
* SORT FIELDS=(1,8,CH,A,42,10,CH,A,14,10,CH,D)
  OUTREC IFTHEN=(WHEN=INIT,
                   OVERLAY=(81:
                             001,008,
                             042,010,
                             SEQNUM,3,ZD,
                              RESTART=(81,18))),
         IFTHEN=(WHEN=GROUP,BEGIN=(99,3,CH,EQ,C'001'),
                  PUSH=(103:14,10))
  OUTFIL INCLUDE=(14,10,CH,EQ,103,10,CH),BUILD=(1,80)
//*
//SORTIN   DD *
22215687     2013-02-16-06.30.16.071719  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.631131  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.724981  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.919678  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.982218  0000001122  DESG CHG  CAROL R
22215687     2013-02-14-23.32.52.982418  0000001122  DESG CHG  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-11-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-11-23.32.52.982418  0000001123  BONUS AD  CAROL R


This gives:
Code:

22215687     2013-02-16-06.30.16.071719  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.631131  0000001122  DESG CHG  CAROL R
22215687     2013-02-16-06.30.16.724981  0000001122  DESG CHG  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R
22215687     2013-02-12-23.32.52.982418  0000001123  BONUS AD  CAROL R


It uses RESTART (as SyncSort does not have KEYBEGIN) to identify the first record of a "group" (emp and task) then identifies the first record to form a GROUP, putting the date from the first record to all members of the GROUP.

Then OUTFIL selects the records whose date is the same as the date of the first record.

If your data is not already in sequence, uncomment the SORT statement and the OPTION EQUALS and delete the OPTION COPY. If it is in sequence, delete the commented SORT statement and OPTION EQUALS, and you can also change OUTREC to INREC, though not vital.
Back to top
View user's profile Send private message
Suceender Kumar

New User


Joined: 10 Jan 2008
Posts: 29
Location: Chennai, India

PostPosted: Wed Apr 03, 2013 11:05 am
Reply with quote

Hello Bill,

It worked as expected! Thanks for the detailed explanation.
Thanks Everyone!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> JCL & VSAM
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. Splice JCL into one record for DD sta... SYNCSORT 2
No new posts Copying data from prev record using SORT SYNCSORT 19
No new posts Break a record into fields, each fiel... SYNCSORT 2
No new posts Creating a single-record file with CO... DFSORT/ICETOOL 8
No new posts SYNCSORT Error - CONTROL FIELD BEYOND... SYNCSORT 10

Back to Top