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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: JCL sort to populate O/P based on dynamic input field
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: 6968
Location: porcelain throne

PostPosted: Wed May 30, 2012 7:13 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed May 30, 2012 7:22 pm    Post subject: Reply to: JCL sort to populate O/P based on dynamic input fi
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    Post subject: Reply to: JCL sort to populate O/P based on dynamic input fi
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed May 30, 2012 8:14 pm    Post subject: Reply to: JCL sort to populate O/P based on dynamic input fi
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed May 30, 2012 10:49 pm    Post subject: Reply to: JCL sort to populate O/P based on dynamic input fi
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

Moderator


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

PostPosted: Wed May 30, 2012 11:56 pm    Post subject:
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    Post subject: Reply to: JCL sort to populate O/P based on dynamic input fi
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    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 Changing sort Card Dynamically vickey_dw DFSORT/ICETOOL 4 Sat Aug 19, 2017 2:33 pm
No new posts Getting Mutiple input from Panels vidyaa CLIST & REXX 12 Mon Aug 14, 2017 1:28 pm
No new posts How do you create Eclipse based dialogs jasorn IBM Tools 0 Thu Aug 03, 2017 5:05 pm
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am


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