Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SORT & concatenate mutiple records into single records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
mistah kurtz

Active User


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

PostPosted: Mon Nov 18, 2013 3:55 pm    Post subject: SORT & concatenate mutiple records into single records
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Mon Nov 18, 2013 6:12 pm    Post subject: Reply to: SORT & concatenate mutiple records into single
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: 283
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Nov 18, 2013 7:22 pm    Post subject:
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: 283
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Nov 19, 2013 12:00 pm    Post subject:
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: 283
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Nov 19, 2013 12:27 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us