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
 

 

Sorting input records on length of characters.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Nov 28, 2013 5:22 pm    Post subject: Sorting input records on length of characters.
Reply with quote

Hi,

I have a file (LRECL=130,RECFM=FB) with names in it and want to sort it on first name's length. Is it possible with SYNCSORT?

Input:
Code:

XAVIER P ROMOZ
RAO T CHINTAKINDI
PRASANNA K SEENAIAH
SULEIMAN V JEHANGHIR


Output:
Code:

CHINTAKINDI T RAO
JEHANGHIR V SULEIMAN
ROMOZ P XAVIER
SEENAIAH K PRASANNA


Please help.

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

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Nov 28, 2013 5:50 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

Yes, what you have written should be possible, but your output seems to disagree that that is what you want.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Nov 28, 2013 6:22 pm    Post subject: ???
Reply with quote

I don't understand you icon_confused.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Thu Nov 28, 2013 6:43 pm    Post subject:
Reply with quote

ramsri

Is your example input first name, initial, last name? The confusion arises because you have changed the sequence of the fields on the output but this is not mentioned in your requirement.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Nov 28, 2013 6:58 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

XAVIER is the second-shortest first name, but appears third in your expected output. Therefore, your expected output is not sorted on length of first name (the first "word" in your data).
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Nov 29, 2013 8:28 am    Post subject:
Reply with quote

Hello,

What "rule" did you use to get from your input to your output?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Fri Nov 29, 2013 3:16 pm    Post subject:
Reply with quote

It looks as though your input is in surname/initial/forename and when you sort you transpose your data to be forename/initial./surname and sort on forename on output. But.. what if a person has no initial?
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Nov 29, 2013 5:35 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

The rule is to sort names on first character on ascending order. Not seen a name without an initial in that dataset !
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Nov 29, 2013 5:51 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

You want to sort on the first character of the third "word" on your input? And rearrange your data? Use PARSE and SQZ in INREC to rearrange your data. SORT FIELDS=(1,1,CH,A).

Obviously this will pickle with no initial, or with embedded blanks in a name (first or last) so ensure that you either can't have those or that you can deal with them.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Nov 29, 2013 6:23 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

Bill, your IDEA given me results -

Code:

//STEP0001 EXEC PGM=SORT                     
//SORTIN   DD *                               
XAVIER P ROMOZ                               
RAO T CHINTAKINDI                             
PRASANNA K SEENAIAH                           
SULEIMAN V JEHANGHIR                         
//SYSOUT   DD SYSOUT=*                       
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                               
 INREC PARSE=(%01=(ENDBEFR=C' ',FIXLEN=8),   
              %02=(ENDBEFR=C' ',FIXLEN=1),   
              %03=(ENDBEFR=C' ',FIXLEN=11)), 
       BUILD=(%03,X,%02,X,%01)               
 SORT FIELDS=(1,1,CH,A)                       
 OUTREC BUILD=(1,22,SQZ=(SHIFT=LEFT,MID=C' '))


I tried but did not work. Is it possible to get this done using INREC alone? Or, must to use both INREC and OUTREC?

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Nov 29, 2013 7:03 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

Ramsri, you know that "it doesn't work" is useless without showing us what doesn't work.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Dec 02, 2013 6:07 am    Post subject:
Reply with quote

Hello,

You posted
Quote:
I have a file (LRECL=130,RECFM=FB) with names in it and want to sort it on first name's length

then
Quote:
The rule is to sort names on first character on ascending order.

You need to post a better set of sample input data and the output you want from that sample input.

What you have posted so far is incomplete, incorrect, and rather confusing.

No one should waste more time on this until a proper situation (understandable request and desired output) has been posted.

d
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 73
Location: Boston

PostPosted: Mon Dec 02, 2013 1:35 pm    Post subject:
Reply with quote

Quote:
Is it possible to get this done using INREC alone? Or, must to use both INREC and OUTREC?


An alternate way of doing it only with INREC is below. But makes me wonder why you insist to do away with OUTREC? icon_confused.gif
Code:

//SYSIN    DD *                               
  INREC IFTHEN=(WHEN=INIT,                     
       PARSE=(%01=(ENDBEFR=C' ',FIXLEN=8),     
              %02=(ENDBEFR=C' ',FIXLEN=1),     
              %03=(ENDBEFR=C' ',FIXLEN=11)),   
       BUILD=(%03,X,%02,X,%01)),               
        IFTHEN=(WHEN=INIT,                     
        BUILD=(1,22,SQZ=(SHIFT=LEFT,MID=C' ')))
  SORT FIELDS=(1,1,CH,A)                       


Thanks,
Ashwin.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Mon Dec 02, 2013 3:35 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

Ashwin, thanks.....I did not want to "do away" but wonder if it was possible...and you have shown that it was possible icon_smile.gif Whenever I tried combination of INREC with OUTREC, I end up getting "INEFFICIENT USE OF INREC" warning in SYSOUT because I would have written but could not figure out.

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

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Mon Dec 02, 2013 3:40 pm    Post subject:
Reply with quote

Dick, yes, I have deviated from what I originally asked....I wanted to SORT the names on their length after rearranging them.

Input-
Code:

XAVIER P ROMOZ
RAO T CHINTAKINDI
PRASANNA K SEENAIAH
SULEIMAN V JEHANGHIR


Expected Output-
Code:

JEHANGHIR V SULEIMAN
SEENAIAH K PRASANNA
CHINTAKINDI T RAO
ROMOZ P XAVIER


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

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Mon Dec 02, 2013 6:54 pm    Post subject:
Reply with quote

Quote:
SORT the names on their length


Is that the entire length - forename/initial(s)/surname - or just one of these?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Mon Dec 02, 2013 11:13 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

Ramsri,

Extend your records by a new field (INREC) that is the same as the maximum length of the names, populated by using your name field as the source for JFY with SHIFT=RIGHT. SORT on the new field. Looks like you want it descending. Chop the extension off afterwards (OUTREC or OUTFIL) with BUILD (of IFOUTLEN if you already happen to have IFTHEN processing).

Please try to have a complete, clear, question, with sample data which is representative and which exercises what you want to do.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Dec 03, 2013 6:24 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

Quote:

xtend your records by a new field (INREC) that is the same as the maximum length of the names


How do I know the max. length of a record? For example sake it is easy to find though icon_surprised.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Dec 03, 2013 6:45 pm    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

If you can't remember the DCB info for the datasets you are working on, then you need to use your fingers and eyes (type and read).

If you don't feel up to that you could always define your SORT key as each individual byte in your field, in reverse order, and remember that you seem to want, or seemed to want at the time of the particular post, descending.

This is getting nowhere, slowly. Unless something magical happens at your end, this topic will be locked.
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 8:05 am    Post subject: Reply to: Sorting input records on length of characters.
Reply with quote

Bill, I understand what has confused you.....Its not the length of dataset but the length of longest name in that dataset is the basis I am looking for.......ideas please.
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 1 Tue Dec 06, 2016 8:04 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm


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