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

Help needed in sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lanand_hps

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Sat Mar 15, 2008 12:59 pm
Reply with quote

Hi All,
My input file is like
Name Coverage
Name1 Acc.Death
Name1 HMS
Name1 Supp.

Name2 HMS
Name2 Supp.

Name3 Acc.Death
Name3 Dental
Name3 HMS

I need HMS row as the top record for all the employees
The output file should be
Name Coverage
Name1 HMS
Name1 Acc.Death
Name1 Supp.

Name2 HMS
Name2 Supp.

Name3 HMS
Name3 Dental
Name3 Acc.Death

Pl post your views,
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Mar 15, 2008 4:48 pm
Reply with quote

hi
While solving this i have considered this as a 80 byte file(i/p and o/p) with RECFM as FB.

Code:
//*******************************************************       
//STEP001  EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
NAME1 ACC.DEATH                                                 
NAME1 HMS                                                       
NAME1 SUPP.                                                     
NAME2 HMS                                                       
NAME2 SUPP.                                                     
NAME3 ACC.DEATH                                                 
NAME3 DENTAL                                                     
----+----1----+----2----+----3----+----4----+----5----+----6----+
NAME3 HMS                                                       
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,5),
                                    93:SEQNUM,8,ZD)),           
         IFTHEN=(WHEN=(81,8,ZD,EQ,+1),                           
                 OVERLAY=(93:SEQNUM,8,ZD),HIT=NEXT),             
         IFTHEN=(WHEN=(81,8,ZD,NE,+1),                           
                 OVERLAY=(101:SEQNUM,8,ZD,                       
                 93:93,8,ZD,SUB,101,8,ZD,M11,LENGTH=8),HIT=NEXT),
         IFTHEN=(WHEN=(7,3,CH,EQ,C'HMS'),                       
                 OVERLAY=(81:8C'0'),HIT=NEXT),                   
         IFTHEN=(WHEN=(7,3,CH,NE,C'HMS'),                       
                 OVERLAY=(81:8C'9'))                             
   SORT FIELDS=(93,8,ZD,A,81,8,ZD,A,7,15,CH,A)                   
   OUTFIL BUILD=(1,80)                                           
/*




output looks like this:
Code:
NAME1 HMS         
NAME1 ACC.DEATH   
NAME1 SUPP.       
NAME2 HMS         
NAME2 SUPP.       
NAME3 HMS         
NAME3 ACC.DEATH   
NAME3 DENTAL     


let me know if this is ok!
Back to top
View user's profile Send private message
lanand_hps

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Sat Mar 15, 2008 7:08 pm
Reply with quote

Thanks man.
Very difficult to understand but will surely analyse and implement as it is very urgent.
Thanks again..
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Sun Mar 16, 2008 1:37 am
Reply with quote

I'm not sure what Krisprems is doing, but here's a simpler DFSORT job that does what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN                                       
//SYSOUT    DD  SYSOUT=*                                       
//SORTIN DD *                                                   
Name1   Acc.Death                                               
Name1   HMS                                                     
Name1   Supp.                                                   
Name2   HMS                                                     
Name2   Supp.                                                   
Name3   Acc.Death                                               
Name3   Dental                                                 
Name3   HMS                                                     
//SORTOUT DD SYSOUT=*                                           
//SYSIN    DD    *                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),           
        IFTHEN=(WHEN=(9,3,CH,EQ,C'HMS'),OVERLAY=(81:C'0'))     
  SORT FIELDS=(1,5,CH,A,81,1,CH,A,9,12,CH,A)                   
  OUTREC BUILD=(1,80)                                           


SORTOUT will have:

Code:

Name1   HMS             
Name1   Acc.Death       
Name1   Supp.           
Name2   HMS             
Name2   Supp.           
Name3   HMS             
Name3   Acc.Death       
Name3   Dental         
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Sun Mar 16, 2008 3:32 am
Reply with quote

A similar method :
Code:

//STEP0001 EXEC PGM=ICETOOL
//DFSMSG   DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*
//TOOLIN   DD *
  COPY FROM(IN) TO(OUTX) USING(ICE0)
/*
//IN       DD *
NAME1 ACC.DEATH
NAME1 HMS
NAME1 SUPP.
NAME2 HMS
NAME2 SUPP.
NAME3 ACC.DEATH
NAME3 DENTAL
NAME3 HMS
/*
//OUTX     DD SYSOUT=*
//ICE0CNTL DD *
  INREC IFTHEN=(WHEN=INIT,
                OVERLAY=(81:SEQNUM,5,ZD,
                         86:SEQNUM,5,ZD,RESTART=(1,5),
                         81:81,5,ZD,SUB,86,5,ZD,M11,LENGTH=5)),
        IFTHEN=(WHEN=(7,3,CH,EQ,C'HMS'),
                OVERLAY=(86:C'00000'))
  SORT FIELDS=(81,10,ZD,A)
  OUTREC FIELDS=(1,80)
/*

Alain
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Sun Mar 16, 2008 3:37 am
Reply with quote

Oups sorry Frank,

I didn't see your post earlier...

Alain
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sun Mar 16, 2008 11:47 am
Reply with quote

Quote:
I'm not sure what Krisprems is doing,

Hi Frank,
I will explain you why i have complicated the solution. I dont know if the NAME field is in sorted order. So, when we consider an input like this

Code:

ZVJE1   ACC.DEATH
ZVJE1   HMS     
ZVJE1   SUPP.   
AMPE2   HMS     
AMPE2   SUPP.   
PXVE3   ACC.DEATH
PXVE3   DENTAL   
PXVE3   HMS     


Your SORT card gives an output like this:the names are sorted, but the sample o/p provided by lanand_hps retains the same order of i/p.
Code:
AMPE2   HMS     
AMPE2   SUPP.   
PXVE3   HMS     
PXVE3   ACC.DEATH
PXVE3   DENTAL   
ZVJE1   HMS     
ZVJE1   ACC.DEATH
ZVJE1   SUPP.   



Where as my SORT card retains the same order as i/p.This is how my o/p looks.
Code:
ZVJE1 HMS     
ZVJE1 ACC.DEATH
ZVJE1 SUPP.   
AMPE2 HMS     
AMPE2 SUPP.   
PXVE3 HMS     
PXVE3 ACC.DEATH
PXVE3 DENTAL   


lanand_hps: If it is OK to have the names in sorted order then you can use frank's simple solution, else the solution is as complicated as i have shown.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Mon Mar 17, 2008 4:52 am
Reply with quote

Hmmm ... not sure why you assumed the OP wanted something more complicated than the example showed without asking. I usually find its best to assume the simple solution will work or ask for clarification. If the simple solution doesn't work, the burden is on the OP to explain further.

Note that your output, like mine, assumes that the second field is to be sorted in order except that HMS is first. So for Name3 we both have Acc. Death followed by Dental even though the OP shows Dental followed by Acc. Death. I assumed the OP made a mistake there and I assume you did too. If you were going for the more complicated solution, maybe you shouldn't have assumed that either, or asked for the "rules" that could give that output. icon_wink.gif

Quote:
If it is OK to have the names in sorted order then you can use frank's simple solution, else the solution is as complicated as i have shown.


I'm not sure that's true. If the OP says the names have to be in their original order, then I'll take another look at it.
Back to top
View user's profile Send private message
lanand_hps

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Mon Mar 17, 2008 9:46 am
Reply with quote

Guys,
I've fair understanding of the statements now.
But, can you give me a one liner for each of the IFTHEN used for Frank's method? It'll be gr8..


Thanks..
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Mar 17, 2008 10:11 am
Reply with quote

Anand,

Quote:
can you give me a one liner for each of the IFTHEN used for Frank's method? It'll be gr8..

I believe you wanted to know what exactly the ifthen statment does.

First it initializes every record with value '1' at 81 col without any cond verified. In the second ifthen, depending on the condition specified in WHEN clause, '0' is overwritten on '1'.

If you are looking for anything more, let us know.
Back to top
View user's profile Send private message
lanand_hps

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Mon Mar 17, 2008 3:46 pm
Reply with quote

Got it resolved.
Thanks guys!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Mon Mar 17, 2008 8:36 pm
Reply with quote

lanand_hps,

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
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 JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top