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

SORT & concatenate mutiple records into single records


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

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Nov 18, 2013 3:55 pm
Reply with quote

Hi,

I have a requirement. There is an Input File, which has dates in two formats: YYYY-MM-DD and Julian Date in Packed Decimal format.
Code:
000001 2013-11-22   %
       FFFF6FF6FF2136
       2013011022032C
---------------------
000002 2013-11-21   *
       FFFF6FF6FF2135
       2013011021032C
---------------------
000003 2013-11-20   <
       FFFF6FF6FF2134
       2013011020032C
---------------------
000004 2013-11-19   
       FFFF6FF6FF2133
       2013011019032C
---------------------
000005 2013-11-18   
       FFFF6FF6FF2132
       2013011018032C

In my output I want first three dates which are greater than or equal to the Current Date in MMDDYY format, concatenated as a single string, i.e.
Code:
111813111913112013

Currently I'm doint it in two pass: first Step to SORT the dates and then Next step to concatenate the first three in single String.

1st Step:
Code:
//SYSIN    DD *                                                 
       SORT    FIELDS=(11,4,PD,A)                               
       OUTFIL  INCLUDE=(11,4,PD,GE,DATE3P),
               BUILD=(1:3,2,3:6,2,5:9,2)

2nd Step:
Code:
//SORTIN   DD *                                                     
131118                                                             
131119                                                             
131120                                                             
131121                                                             
131122                                                             
//SORTOUT  DD SYSOUT=*                                             
//SYSOUT   DD SYSOUT=*                                             
//SYSIN    DD *                                                     
    OPTION   COPY,STOPAFT=3                                         
    INREC    IFTHEN=(WHEN=INIT,OVERLAY=(7:SEQNUM,3,ZD)),           
             IFTHEN=(WHEN=INIT,OVERLAY=(10:7,3,ZD,MOD,+3,EDIT=(T))),
             IFTHEN=(WHEN=GROUP,END=(10,1,ZD,EQ,0),PUSH=(11:ID=1)),
             IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,1),PUSH=(15:1,6)),
             IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,2),PUSH=(21:1,6)),
             IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,0),PUSH=(27:1,6))
    OUTFIL   INCLUDE=(10,1,ZD,EQ,0),BUILD=(1:15,18)                 


All the files are LRECL=80,RECFM=FB.
I'm using SYNCSORT. Is there any way to achieve it in single pass or more efficient than the way I'm doing it now?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Mon Nov 18, 2013 6:12 pm
Reply with quote

How many records can be on the file? Can it have duplicate dates?

Your second step only reads three records. Not so heavy :-)

The resource-hogger is the SORT.

First, you should always OMIT/INCLUDE to get rid of stuff you are not going to need before the SORT (or other processing).

To look at getting rid of the SORT, be aware that BEGIN can be more complex than you have used. You have something working, so can spend a little time thinking and experimenting.

I would start with storing the date from the record in three places. Then each record can be tested against closest, next closest, last closest.

In OUTFIL, you can use NODETAIL,REMOVECC and TRAILER1 to write something only at the end of the OUTFIL.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Nov 18, 2013 7:22 pm
Reply with quote

No of records would be around 15000 at max. No It will not have duplicates.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Nov 19, 2013 12:00 pm
Reply with quote

Quote:
First, you should always OMIT/INCLUDE to get rid of stuff you are not going to need before the SORT (or other processing).

I have changed my first step. I guess this is what you've suggested.
Code:
  INCLUDE COND=(11,4,PD,GE,DATE3P)
  SORT    FIELDS=(11,4,PD,A)       
  OUTREC  BUILD=(1:3,2,3:6,2,5:9,2)
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Nov 19, 2013 12:27 pm
Reply with quote

I have changed the 2nd step as:
Code:
    OPTION   COPY,STOPAFT=3                                         
    INREC    IFTHEN=(WHEN=INIT,OVERLAY=(7:SEQNUM,3,ZD)),           
             IFTHEN=(WHEN=INIT,OVERLAY=(10:7,3,ZD,MOD,+3,EDIT=(T))),
             IFTHEN=(WHEN=GROUP,END=(10,1,ZD,EQ,0),PUSH=(11:ID=1)),
             IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,1),PUSH=(15:1,6)),
             IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,2),PUSH=(21:1,6)),
             IFTHEN=(WHEN=GROUP,BEGIN=(10,1,ZD,EQ,0),PUSH=(27:1,6))
    OUTFIL   REMOVECC,NODETAIL,TRAILER1=(1:15,18)                   

Quote:
be aware that BEGIN can be more complex than you have used.

I didn't quite understand what you are implying by this.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts SYNCSORT/ICETOOL JOINKEYS SORT Statem... DFSORT/ICETOOL 13
No new posts Installing sort utilities on hercules... DFSORT/ICETOOL 4
No new posts Add column to existing records using ... JCL & VSAM 2
No new posts Syncsort- Merging two records into on... SYNCSORT 3
This topic is locked: you cannot edit posts or make replies. Sort card help to prepare status report DFSORT/ICETOOL 13
Search our Forums:

Back to Top