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

JCL sort to populate O/P based on dynamic input field


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

New User


Joined: 21 Feb 2007
Posts: 3
Location: india

PostPosted: Wed May 30, 2012 7:10 pm
Reply with quote

We have a scenario wherein there are a set of department IDs(maximum of 10 departments allowed) seperated by semicolon and followed by some data in the input file:

I/P file:
200;201 AAA
204;205;206;207 BBB
208 CCC

We need to write each of the department along with the info in separate lines as given below sorted on dept ID:

O/P file:
200 AAA
201 AAA
204 BBB
205 BBB
206 BBB
207 BBB
208 CCC

Are there any possiblities of achieving the above using only JCl sort instead of going for a separate EZT or REXX program?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 30, 2012 7:13 pm
Reply with quote

Quote:
JCl sort


no, this is a syncsort forum,
there is a dfsort forum,
also in this forum (snycsort, CA-SORT)
but we have no specialists in JCL sort.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed May 30, 2012 7:22 pm
Reply with quote

Recfm/lrecl of input and output?

Yes, it can be done.
Back to top
View user's profile Send private message
mishra

New User


Joined: 21 Feb 2007
Posts: 3
Location: india

PostPosted: Wed May 30, 2012 7:42 pm
Reply with quote

Both Input and output are FB format.

The input file length for the given example is 43 bytes (as multiple dept allowed dept filed length is 39 bytes+1 space+3 bytes) and the output LRECL will be 7.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed May 30, 2012 8:14 pm
Reply with quote

Use the lack of seperator to determine how many records you want going out and where your other data is.

You'll need about 10 IFTHENs on OUTFIL so you can use the "/" slash-operator to output multiple records.
Back to top
View user's profile Send private message
Naish

New User


Joined: 07 Dec 2006
Posts: 82
Location: UK

PostPosted: Wed May 30, 2012 10:30 pm
Reply with quote

Have used OP's data and also assuming the fixed position of data separated by semicolon:
Code:
//STEP001 EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTIN  DD *
200;201 AAA
204;205;206;207 BBB
208 CCC
123;122;121;120 DDD
000;111;222;333;444;555;666;777;888;999 EEE
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
  SORT FIELDS=COPY

  INREC PARSE=(%01=(STARTAFT=C' ',FIXLEN=3)),
        BUILD=(1:1,43,45:%01)

  OUTFIL IFOUTLEN=7,
         IFTHEN=(WHEN=(4,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3)),
         IFTHEN=(WHEN=(8,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3)),
         IFTHEN=(WHEN=(12,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3,/,
                 1:9,3,5:45,3)),
         IFTHEN=(WHEN=(16,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3,/,
                 1:9,3,5:45,3,/,
                 1:13,3,5:45,3)),
         IFTHEN=(WHEN=(20,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3,/,
                 1:9,3,5:45,3,/,
                 1:13,3,5:45,3,/,
                 1:17,3,5:45,3)),
         IFTHEN=(WHEN=(24,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3,/,
                 1:9,3,5:45,3,/,
                 1:13,3,5:45,3,/,
                 1:17,3,5:45,3,/,
                 1:21,3,5:45,3)),
         IFTHEN=(WHEN=(28,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3,/,
                 1:9,3,5:45,3,/,
                 1:13,3,5:45,3,/,
                 1:21,3,5:45,3,/,
                 1:25,3,5:45,3)),
         IFTHEN=(WHEN=(32,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3,/,
                 1:9,3,5:45,3,/,
                 1:13,3,5:45,3,/,
                 1:17,3,5:45,3,/,
                 1:21,3,5:45,3,/,
                 1:25,3,5:45,3,/,
                 1:29,3,5:45,3)),
         IFTHEN=(WHEN=(36,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3,/,
                 1:9,3,5:45,3,/,
                 1:13,3,5:45,3,/,
                 1:17,3,5:45,3,/,
                 1:21,3,5:45,3,/,
                 1:25,3,5:45,3,/,
                 1:29,3,5:45,3,/,
                 1:33,3,5:45,3)),
         IFTHEN=(WHEN=(40,1,CH,EQ,X'40'),
          BUILD=(1:1,3,5:45,3,/,
                 1:5,3,5:45,3,/,
                 1:9,3,5:45,3,/,
                 1:13,3,5:45,3,/,
                 1:17,3,5:45,3,/,
                 1:21,3,5:45,3,/,
                 1:25,3,5:45,3,/,
                 1:29,3,5:45,3,/,
                 1:33,3,5:45,3,/,
                 1:37,3,5:45,3))

O/P:
Code:
200 AAA
201 AAA
204 BBB
205 BBB
206 BBB
207 BBB
208 CCC
123 DDD
122 DDD
121 DDD
120 DDD
000 EEE
111 EEE
222 EEE
333 EEE
444 EEE
555 EEE
666 EEE
777 EEE
888 EEE
999 EEE
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed May 30, 2012 10:49 pm
Reply with quote

You don't need all the columns, it makes it easier to read without them, but it'll do, Naish. Let's hope you get some thanks from the TS, even saved him the typing :-)
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed May 30, 2012 11:56 pm
Reply with quote

Naish,

Very good work indeed
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu May 31, 2012 12:19 am
Reply with quote

With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct,2010), you can now use the new RESIZE operator of DFSORT's ICETOOL to easily create larger records from smaller records, or smaller records from larger records.

Code:

//STEP0100 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN       DD *                                                       
200;201 AAA                                                           
204;205;206;207 BBB                                                   
208 CCC                                                               
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
209;111;222;333;444;555;666;777;888;999 000                           
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                       
  RESIZE FROM(IN) TO(OUT) TOLEN(7) USING(CTL1)                         
//CTL1CNTL DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,                                             
  PARSE=(%01=(ENDBEFR=C' ',FIXLEN=40),%02=(FIXLEN=3)),BUILD=(%01,%02)),
  IFTHEN=(WHEN=INIT,                                                   
  PARSE=(%03=(ENDBEFR=C';',FIXLEN=3),%04=(ENDBEFR=C';',FIXLEN=3),     
         %05=(ENDBEFR=C';',FIXLEN=3),%06=(ENDBEFR=C';',FIXLEN=3),     
         %07=(ENDBEFR=C';',FIXLEN=3),%08=(ENDBEFR=C';',FIXLEN=3),     
         %09=(ENDBEFR=C';',FIXLEN=3),%10=(ENDBEFR=C';',FIXLEN=3),     
         %11=(ENDBEFR=C';',FIXLEN=3),%12=(ENDBEFR=C';',FIXLEN=3)),     
  BUILD=(%03,X,41,3,%04,X,41,3,%05,X,41,3,%06,X,41,3,%07,X,41,3,       
         %08,X,41,3,%09,X,41,3,%10,X,41,3,%11,X,41,3,%12,X,41,3))     
                                                                       
  OUTFIL FNAMES=OUT,OMIT=(1,3,CH,EQ,C' ')                             
//*


The output from this is
Code:

200 AAA
201 AAA
204 BBB
205 BBB
206 BBB
207 BBB
208 CCC
209 000
111 000
222 000
333 000
444 000
555 000
666 000
777 000
888 000
999 000
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top