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

Sorting input records on length of characters.


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

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Dec 04, 2013 10:03 am
Reply with quote

Hi,

if I understand it correctly, you want the full name ie. first name initial and last name reversed and sorted with longest name first
ie. longest name=lastname + initial + first name

Code:
//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=input-file                             
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  SORT FIELDS=(1,255,BI,D)                               
  INREC IFTHEN=(WHEN=INIT,                               
        PARSE=(%01=(ENDAT=X'40',FIXLEN=126),             
               %02=(ENDAT=X'40',FIXLEN=1),               
               %03=(ENDAT=X'40',FIXLEN=126)),             
             BUILD=(%03,C'?',%02,C'?',%01)),             
        IFTHEN=(WHEN=(1,1,CH,EQ,1,1,CH),                 
             BUILD=(1,255,SQZ=(SHIFT=RIGHT)))             
 OUTFIL IFOUTLEN=130,                                     
        IFTHEN=(WHEN=INIT,BUILD=(1,255,SQZ=(SHIFT=LEFT))),
        IFTHEN=(WHEN=INIT,                               
                FINDREP=(INOUT=(C'?',X'40')))             



Gerry
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Dec 04, 2013 4:31 pm
Reply with quote

Gerry, thanks a lot.......you have made my day...... icon_biggrin.gif
Can you please help me why length is fixed at 126 when file's length is 130 ?
what does below do?
Code:

WHEN=(1,1,CH,EQ,1,1,CH)


Thanks again.
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 Dec 04, 2013 6:40 pm
Reply with quote

Ramsri,

I think Gerry was just showing an example, since you've kept any details to yourself.

You, surely, know what the maximum length of the elements of the name can be, and that gives you the theoretical maximum length needed. If your field already exists in that form (firstname, initial, lastname) only, then it is just the length of that field itself that you need to work with. The maximum length for an individual item for the FIXLEN is (field-length - 1 - 1 - 1 - 1). 130 seems a reasonable length, to guess, that would hold all your data, and may be much longer than need. You know your data, we don't.

The IFTHEN is just getting a "true", so is unconditional. I think another IFTHEN=(WHEN=INIT would be better.

I suggested JFY rather than SQZ due to the potential of embedded blanks in names. I assumed you had the rearrangement dealt with and were just keeping it a secret.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Dec 05, 2013 7:14 am
Reply with quote

Hi Ramsri,

Quote:
Can you please help me why length is fixed at 126 when file's length is 130 ?

With a file of LRECL=130, neither firstname or last name can exceed length of 126.

eq. firstname = 126 + 1 (space) + 1 (initial) +1 (space) + 1 (lastname)= 130, anything greater than 126 would exceed the input LRECL of 130.


Quote:
I suggested JFY rather than SQZ due to the potential of embedded blanks in names


If embedded blanks appeared in names, this process would not work.


Gerry
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Sun Dec 08, 2013 9:14 am
Reply with quote

Thanks a lot Gerry.......it is always very interesting to learn technical things.
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 How to split large record length file... DFSORT/ICETOOL 7
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top