Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
SORT Utility to sort based on a condition in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL
Author Message
soumen2255

New User


Joined: 25 Jun 2008
Posts: 47
Location: Pune

PostPosted: Thu Jun 25, 2009 12:16 pm    Post subject: SORT Utility to sort based on a condition in a file
Reply with quote

Hi,

I have the following input file
parameter ID Date
100A xxxxx 2009057
100B 12365 xxxxxxx
100A xxxxx 2009165
100B 65123 xxxxxxx
100B 13495 xxxxxxx
100A xxxxx 2009568
100B 79236 xxxxxxx

My expected output is:

2009057 12365
2009165 65123
2009165 13495
2009568 79236

The objective is :
i) if the parameter is 100A then Pick the date and write in the file and if the parameter is 100B pick the ID and place it against the date in the same record.
ii) If there are two successive 100B then pick the date from 100A and write the two ID in subsequent records against the same date.
Back to top
View user's profile Send private message
References
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 5993
Location: San Jose, CA

PostPosted: Thu Jun 25, 2009 8:35 pm    Post subject:
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
100A          xxxxx    2009057
100B          12365    xxxxxxx
100A          xxxxx    2009165
100B          65123    xxxxxxx
100B          13495    xxxxxxx
100A          xxxxx    2009568
100B          79236    xxxxxxx
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
   OPTION COPY
   INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'100A'),
     PUSH=(24:24,7))
   OUTFIL OMIT=(1,4,CH,EQ,C'100A'),
     BUILD=(24,7,X,15,5)
/*
Back to top
View user's profile Send private message
soumen2255

New User


Joined: 25 Jun 2008
Posts: 47
Location: Pune

PostPosted: Fri Jun 26, 2009 11:44 am    Post subject: Reply to: SORT Utility to sort based on a condition in a fil
Reply with quote

Hi Frank,

Thanks a lot for the help.But this was not working.
Please find first 10 records of my input file:

Input -

Code:
cols>   ----+----1----+----2----+----3-
00001 100A 125632521       2004412
00002 100B 10039568945655554040404
00003 100A 121212121       2006086
00004 100B 10035645654522224040404
00005 100A 121632121       2008147
00006 100B 10035498652366664040404
00007 100B 10034795623177774040404
00008 100B 10013695452422584040404
00009 100A 123651233       2007563
00010 100B 10034965236523654040404

The output file is expected as :
Output -

Code:
cols>   ----+----1----+----2----+----3
00001 1003956894565555 2004412
00002 1003564565452222 2006086
00003 1003549865236666 2008147
00004 1003479562317777 2008147
00005 1001369545242258 2008147
00006 1003496523652365 2007563
Back to top
View user's profile Send private message
soumen2255

New User


Joined: 25 Jun 2008
Posts: 47
Location: Pune

PostPosted: Fri Jun 26, 2009 4:42 pm    Post subject:
Reply with quote

Sorry the i/p and o/p data are :

Input -

Code:
Code:
cols> ----+----1----+----2----+----3-
00001 100A 125632521       2004412
00002 100B 10039568945655554040404
00003 100A 121212121       2006086
00004 100B 10035645654522224040404
00005 100A 121632121       2008147
00006 100B 10035498652366664040404
00007 100B 10034795623177774040404
00008 100B 10013695452422584040404
00009 100A 123651233       2007563
00010 100B 10034965236523654040404

The output file is expected as :
Output -

Code:
Code:
cols>   ----+----1----+----2----+----3
00001 1003956894565555 2004412
00002 1003564565452222 2006086
00003 1003549865236666 2008147
00004 1003479562317777 2008147
00005 1001369545242258 2008147
00006 1003496523652365 2007563
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 5395
Location: italy

PostPosted: Fri Jun 26, 2009 5:03 pm    Post subject: Reply to: SORT Utility to sort based on a condition in a fil
Reply with quote

please learn to use the code tag
Your posts were edited for that
I hope You noticed the difference.
the code tag is used to preserve alignment
Back to top
View user's profile Send private message
soumen2255

New User


Joined: 25 Jun 2008
Posts: 47
Location: Pune

PostPosted: Fri Jun 26, 2009 5:41 pm    Post subject:
Reply with quote

Thanks a lot enrico!! I am using this Forum for the first time.

Now I am using the Code tag:

The input file is :

Code:

cols> ----+----1----+----2----+----3-
00001 100A 125632521        2004412
00002 100B 1003956894565555 4040404
00003 100A 121212121        2006086
00004 100B 1003564565452222 4040404
00005 100A 121632121        2008147
00006 100B 1003549865236666 4040404
00007 100B 1003479562317777 4040404
00008 100B 1001369545242258 4040404
00009 100A 123651233        2007563
00010 100B 1003496523652365 4040404


The o/p file should be:
Code:

cols> ----+----1----+----2----+----3
00001 1003956894565555 2004412
00002 1003564565452222 2006086
00003 1003549865236666 2008147
00004 1003479562317777 2008147
00005 1001369545242258 2008147
00006 1003496523652365 2007563


Please note that both the input and output ar VB files.

Someone please help me.I need to do this through the JCL and not through program?
Back to top
View user's profile Send private message
Skolusu

DFSORT Developer


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

PostPosted: Fri Jun 26, 2009 6:37 pm    Post subject: Reply to: SORT Utility to sort based on a condition in a fil
Reply with quote

soumen2255 wrote:
Thanks a lot for the help.But this was not working.
Please find first 10 records of my input file:


soumen2255,

If only you had done a better job of specifying your requirements you wouldn't have a problem. The job Frank provided DOES give you the desired results from your initial post. Go look at your first post regarding the output and compare it against your latest desired output. In your first post you wanted the output swapping the columns and in the latest output you don't swap the columns. How are we supposed to provide solutions with a moving target?

Secondly you never mentioned anything about the input being a variable block file. So from next time make sure that you provide all the details.

Here is the job which would give you the desired results

Code:

//STEP0200 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=your input vb file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,4,CH,EQ,C'100A'),PUSH=(27:27,7))
  OUTFIL OMIT=(5,4,CH,EQ,C'100A'),BUILD=(1,4,10)
//*
Back to top
View user's profile Send private message
soumen2255

New User


Joined: 25 Jun 2008
Posts: 47
Location: Pune

PostPosted: Fri Jun 26, 2009 6:59 pm    Post subject: Reply to: SORT Utility to sort based on a condition in a fil
Reply with quote

I am extreamly for the confusion.

But now I am getting the following error:

Code:
                                                      z/OS   1.9.0
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 2584F, MODEL 2094 721         
SYSIN :
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,4,CH,EQ,C'100A'),PUSH=(27:27,7))
                     *
  OUTFIL OMIT=(5,4,CH,EQ,C'100A'),BUILD=(1,4,10)
WER268A  INREC STATEMENT   : SYNTAX ERROR
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Back to top
View user's profile Send private message
Skolusu

DFSORT Developer


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

PostPosted: Fri Jun 26, 2009 8:48 pm    Post subject:
Reply with quote

soumen2255,

The error messages indicate that you are using syncsort. I am a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
Back to top
View user's profile Send private message
Moved: Fri Jun 26, 2009 8:50 pm by enrico-sorichetti From DFSORT/ICETOOL to JCL
dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 13593
Location: 221 B Baker St

PostPosted: Fri Jun 26, 2009 10:21 pm    Post subject:
Reply with quote

Hello,

It appears you are not using the current version of Syncsort. Suggest you talk with your system support to install the current release.
Back to top
View user's profile Send private message
Arun Raj

Senior Member


Joined: 17 Oct 2006
Posts: 1564
Location: Chennai, India

PostPosted: Thu Jul 02, 2009 6:45 pm    Post subject:
Reply with quote

soumen2255,

Or may be you can try this SYNCTOOL job which should work for your SyncSort version.
Code:
//STEP0100 EXEC PGM=SYNCTOOL                                       
//DFSMSG   DD SYSOUT=*                                             
//TOOLMSG  DD SYSOUT=*                                             
//IN       DD DSN= Input  VB file
//OUT      DD DSN= Output VB file
//TOOLIN   DD *                                                   
  SPLICE FROM(IN) TO(OUT) ON(5,8,CH) WITH(1,42) WITHALL -         
         KEEPNODUPS USING(CTL1)                                   
//CTL1CNTL DD *                                                   
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,SEQNUM,8,ZD,8X,5)),           
        IFTHEN=(WHEN=(21,4,CH,EQ,C'100A'),                         
        OVERLAY=(5:SEQNUM,8,ZD)),                                 
        IFTHEN=(WHEN=NONE,                                         
        OVERLAY=(13:SEQNUM,8,ZD,5:5,8,ZD,SUB,13,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT,BUILD=(1,4,26)                                 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL All times are GMT + 6 Hours
Page 1 of 1