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 based on selected strings
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
CJT

New User


Joined: 02 Aug 2007
Posts: 83
Location: Here

PostPosted: Wed Jan 04, 2012 2:19 pm    Post subject: Sorting based on selected strings
Reply with quote

Hi i have a file with LRECL = 100 byte. The following is my requirement

The input file looks like this - below -
the strings AB to AF start from position 10 to 12 -

Code:

XXXXXX.... AB11 YYYYY
XXXXXX.... ACTT YYYYY
XXXXXX.... AD33 YYYYY
XXXXXX.... AEZZ YYYYY
XXXXXX.... AF99 YYYYY


Currently the file is sorted as follows

Code:

Sort fields = (10,2,CH,A,13,1,CH,A) 


We have a new requirement where the strings with 'AF' from 10 to 12 should be included in the first part of the sort - i.e. 10,2,CH,A
but not in the 2nd part of the sort - i.e. 13,1,CH,A

Can you let me know if this is possible in a single sort step?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Wed Jan 04, 2012 2:42 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

Build a seperate key at the end (fixed-length records) or beginning (variable-length records). For your range, blat the second part of the generated key to a standard value (space, for instance). Change your SORT card to use the generated key. Drop off the generated sort afterwards.

This would be some INREC stuff, to generate the key, and an OUTREC BUILD to drop it off.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Wed Jan 04, 2012 2:55 pm    Post subject:
Reply with quote

Hi,

I have no idea what you are talking about.

Your data does match your desciption, AB starts at 12 and not 10.

also AB is only 2 bytes where position 10-12 occupies 3 bytes.


Gerry
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jan 04, 2012 2:56 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

that' s what I like in these forum(s)/fora...
the clear and consistent descriptions of the requirements icon_cool.gif
Back to top
View user's profile Send private message
CJT

New User


Joined: 02 Aug 2007
Posts: 83
Location: Here

PostPosted: Wed Jan 04, 2012 4:04 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

Sorry, gcicchet you are right.

AB starts at 12.

The sort fields is like this

Code:

sort fields=(12,2,CH,A,14,1,CH,A)



String AF must be part of the first part of sort (12,2,CH,A)

But it should not be part of the 2nd part of the sort = 14,1,CH,A[/code]
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jan 04, 2012 4:12 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

the requirement is still clear as mud... icon_evil.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Wed Jan 04, 2012 4:24 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

I have not tried to make sense of the contradictory references, but see if this is somewhere like you want when you decide what is what.
Code:

//SORTABN EXEC PGM=SORT
//SYMNOUT  DD SYSOUT=*
//SYMNAMES DD *
ORIGINAL-KEY-1,10,2,CH
ORIGINAL-KEY-2,13,1,CH
TEST-VALUE-FIELD,12,2,CH
TEST-VALUE-START,'AB'
TEST-VALUE-END,'AF'
ORIGINAL-RECORD,1,21,CH !!! CODE THESE
GENERATED-KEY,*,3,CH    !!! THREE
OVERLAY-START,=         !!! TOGETHER
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
                                                         
 SORT FIELDS=(GENERATED-KEY,A),EQUALS
                                                         
 INREC IFTHEN=(WHEN=(TEST-VALUE-FIELD,GE,TEST-VALUE-START,
                 AND,TEST-VALUE-FIELD,LE,TEST-VALUE-END),
          OVERLAY=(OVERLAY-START:ORIGINAL-KEY-1,X)),
       IFTHEN=(WHEN=NONE,
          OVERLAY=(OVERLAY-START:ORIGINAL-KEY-1,
                                 ORIGINAL-KEY-2))
 OUTREC BUILD=(ORIGINAL-RECORD)
//SORTIN   DD *
XXXXXX...09ACTT YYYYY
XXXXXX...06AF99 YYYYY
XXXXXX...06AEZZ YYYYY
XXXXXX...09AD33 YYYYY
XXXXXX...09AB11 YYYYY
XXXXXX...09BCTT YYYYY
XXXXXX...06BF99 YYYYY
XXXXXX...06BEZZ YYYYY
XXXXXX...09BD33 YYYYY
XXXXXX...09BB11 YYYYY


I have put 06 and 09 at the first key position you mentioned and the second sort key is the field after the two-char field you want to identify. The AB-AF records are in different order to the BB-BF records (which are the same, except for the B).

Output:
Code:

XXXXXX...06AF99 YYYYY
XXXXXX...06AEZZ YYYYY
XXXXXX...06BEZZ YYYYY
XXXXXX...06BF99 YYYYY
XXXXXX...09ACTT YYYYY
XXXXXX...09AD33 YYYYY
XXXXXX...09AB11 YYYYY
XXXXXX...09BB11 YYYYY
XXXXXX...09BCTT YYYYY
XXXXXX...09BD33 YYYYY
Back to top
View user's profile Send private message
CJT

New User


Joined: 02 Aug 2007
Posts: 83
Location: Here

PostPosted: Wed Jan 04, 2012 4:32 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

Hi Bill

Thank you so much for your time on this. However, I was looking for a little more simpler sort as this sort card seems to take time when run in batch
Back to top
View user's profile Send private message
CJT

New User


Joined: 02 Aug 2007
Posts: 83
Location: Here

PostPosted: Wed Jan 04, 2012 4:58 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

Enrico, thank you - the main problem is i cannot post company data or requirement explicitly on this website so that is why the data is masked and my requirement is not clear.

The requirement - put simply is as below.

Say in a file we have 2 Fields - Fld 1 and Fld 2
the sort field sorts by Fld 1 and then by Fld 2

Code:

Sort fields (fld 1, Fld 2)


However i want a particular string (say Fld 1 = 3 ) not to be sorted based on Fld 2 and still appear in the output file. the rest of the strings need to be sorted on both Fld 1 and Fld 2. Only Fld 1 = 3 should be sorted on Fld 1 and not on Fld3
I hope i am clear.


Code:


File looks like this

A1
1C
2E
3B
EX
D5
B6

Here by Fld 1 i mean the first byte. Field 2 is the 2nd byte.
Fld 1 Fld 2
A      1
1      C
2      E
3      B
E      X
D      5
B      6
Code:
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Wed Jan 04, 2012 6:38 pm    Post subject: Re: Reply to: Sorting based on selected strings
Reply with quote

Bill Woodger wrote:
[...]
Code:

ORIGINAL-RECORD,1,21,CH !!! CODE THESE
GENERATED-KEY,*,3,CH    !!! THREE
OVERLAY-START,=         !!! TOGETHER


Although the coding of OVERLAY-START like that, to get a constant value (22 in this case) "works", I don't think I should rely on it. Better like this:

Code:
OVERLAY-START,=,1,CH    !!! TOGETHER


In the documentation it is explicit that when used for a column the processing of the SYMNAME will only use the starting position value from the definition. I think my previous attempt was a little "fudge" as, when I tried to re-arrange it (OVERLAY first then GENERATED) I got an error. Now it should be possible to re-arrange.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Wed Jan 04, 2012 7:25 pm    Post subject:
Reply with quote

Bill,

With all due respect to your Sort coding abilities, I find the use of SYNAMES confusing to the novice user.

These posters can barely code the basics, and you throw these advance techniques at them. It is way over their heads (and mine).

It is like putting a kid on a high-tech road bicycle, when they still have training wheels on their Huffy.

While your solutions are excellent, I am sure they are mostly ignored. Is that what you intend?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Wed Jan 04, 2012 8:14 pm    Post subject:
Reply with quote

On the banner at the top of the page it says 'EXPERT FORUM' so it should not be beyond these people to skim the manual to find out about SYMNAMES. In depth reading would be required to get into all the nooks and crannies and, possibly, a manual in their native language - if they do not have such things.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Wed Jan 04, 2012 8:33 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

Hi Dave,

Thanks for the comments. I don't agree about the efficacy of my solutions, by the way :-)

To me, SYMNAMES are to make things easier: to understand; to maintain.

You can take a Cobol (or whatever) record-layout, generate DFSORT symbols from it, and use the identical names/definitions in DFSORT without having to do any counting, referring to datamaps on listings, using browse with COLS or whatever technique.

When you have written the sort code, you can far-better understand it, spot "obvious" errors, avoid stupid typos/miscountings, "move" a field which is referenced in several places by only changing the definition in one place, etc.

If anyone is happier doing all the counting and stuff, that's fine by me. DFSORT lists the sort cards once the symbols have been resolved, so someone can take that as the solution if they like.

I think the symnames are easier. Anyone been called at 2am by OPS? "OK, do you think you are up to changing some sort cards?" you say, or you are thinking "what the heck is at position 48 for a length of five and is packed?" when you haven't looked at a particular part of the system for a couple of years.

I wish symnames had been around 32 years ago. Would have been much easier, and I don't think it would have made understanding position, length and type any more difficult.

Yes, it takes longer to code initially by hand. Doesn't take as long with generated symbols. Once you have the symbols, I find it is quicker to write the sort cards, certainly easier to understand and maintain.

OK, "understand" can be a personal thing. "I can see what it says, but what does it do?" maybe, but that cuts both ways, symnames or "classic".

Symnames make me think about the data content, not about the position of the data.

The main problem with my sort "solutions" is whether they are fit for purpose, not about the symnames. I leave a lot of useless clutter for Frank and Kolusu to wade through unnecessarily. Sorry about that guys.

If people don't know about DFSORT symbols, they won't use them for sure. If they do know, they might, and they may well benefit from it.

If they want the classic, just look at the output and paste it over the input sort cards :-)
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: Wed Jan 04, 2012 9:13 pm    Post subject:
Reply with quote

Hello,

Quote:
On the banner at the top of the page it says 'EXPERT FORUM'
Unfortunately, we are an expert forum in name only (even though we do have an entire separate forum for "Students and Beginners".. . . icon_sad.gif

Only rarely do true experts post questions here. Which is unfortunate as we have several people who can/do provide help/information for these "heavier" questions.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Wed Jan 04, 2012 9:14 pm    Post subject:
Reply with quote

Bill,

I understand the why SYNAMES is a better solution in many cases.

My point is that using this method is different concept that is beyond the grasp of many of the 'non-expert' posters on this 'expert forum.

In most of the solutions, Frank and Kolusu could provide a SYNAMES solutions, but they choose not to.

My guess as to why is that the solution needs to be catered to the user it is provided for.

I am not taking anything away from the excellence of the solutions, just that it often does not match the audience.

Nic,

While it says this is an 'expert' forum, we know that is often not the case.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Wed Jan 04, 2012 9:26 pm    Post subject:
Reply with quote

I'm with you Bill, I love DFSORT symbols. I have never understood why it is so difficult to convince people to use them. In our shop there are over 8,000 jobs in production that use DFSORT; less than 30 of them use SYMNAMEs.

Symbols have been around since 1998. How old does a feature need to be before it can no longer be considered "new"? icon_cool.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Jan 05, 2012 1:29 am    Post subject:
Reply with quote

Quote:
Symbols have been around since 1998. How old does a feature need to be before it can no longer be considered "new"?


DFSORT's ICETOOL has been available since 1991 and some people still consider it too "new" to use. icon_rolleyes.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Jan 05, 2012 1:37 am    Post subject:
Reply with quote

Quote:
In most of the solutions, Frank and Kolusu could provide a SYNAMES solutions, but they choose not to.

My guess as to why is that the solution needs to be catered to the user it is provided for.


While I agree that SYMNAMES is a better way to go (well, I did "invent" it), I generally choose NOT to show solutions with SYMNAMES because it requires the reader to understand one more level of "abstraction" which some have trouble with. I figure that the more capable/interested people in this group will use SYMNAMES themselves without me showing them how. Of course, if anyone has specific questions about how to use SYMNAMES, I would be glad to respond.
Back to top
View user's profile Send private message
CJT

New User


Joined: 02 Aug 2007
Posts: 83
Location: Here

PostPosted: Thu Jan 05, 2012 1:23 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

Hi Bill,

thanks for the solution to posted but as i mentioned before i cannot use Sym names - because this sort card would be placed in a job that has around 10 million records accessing it daily. so we needed a more simple method.

Frank, is there another possible solution to this - thank you for your time on this.

Nic,

Quote:

On the banner at the top of the page it says 'EXPERT FORUM' so it should not be beyond these people to skim the manual to find out about SYMNAMES. In depth reading would be required to get into all the nooks and crannies and, possibly, a manual in their native language - if they do not have such things.


Definitely our skills are nothing compared to the vast expertise and knowledge that many in this group have but we do have a basic knowledge of English and that is why we are Cobol programmers and a lot of companies trust us to handle their processes. Most of the cases due to dearth of time we may not be able to dig into these manuals.
I did not mean any offence to anyone here but a little respect would not harm anyone - thank you.
Thank you all again for your time and solutions.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Jan 05, 2012 1:48 pm    Post subject: Reply to: Sorting based on selected strings
Reply with quote

Quote:
thanks for the solution to posted but as i mentioned before i cannot use Sym names - because this sort card would be placed in a job that has around 10 million records accessing it daily. so we needed a more simple method.


utter horse manure ...
symnames is just a way of making things more readable
I am not a dfsort expert, but I strongly believe that
they do not have any performance implications .


A sort using SYMNAMES would look like
Code:

 000006 //SYMNOUT   DD SYSOUT=*
 ...
 000010 //SYMNAMES  DD *                                                       
 000011 FLD1,01,10,CH                                                           
 000012 FLD2,11,10,CH                                                           
 000013 //SORTIN    DD *                                                       
 000014 22222222221111111111                                                   
 000015 22222222222222222222                                                   
 000016 22222222223333333333                                                   
 000017 11111111111111111111                                                   
 000018 11111111112222222222                                                   
 000019 11111111113333333333                                                   
 000020 //SORTOUT   DD SYSOUT=*,DCB=(RECFM=FB,LRECL=80)                         
 000021 //SYSIN     DD *                                                       
 000022   SORT FIELDS=(FLD1,A,FLD2,A)                                           
 ****** **************************** Bottom of Data ****************************


instead of ....
Code:

 000013 //SORTIN    DD *                                                       
 000014 22222222221111111111                                                   
 000015 22222222222222222222                                                   
 000016 22222222223333333333                                                   
 000017 11111111111111111111                                                   
 000018 11111111112222222222                                                   
 000019 11111111113333333333                                                   
 000020 //SORTOUT   DD SYSOUT=*,DCB=(RECFM=FB,LRECL=80)                         
 000021 //SYSIN     DD *                                                       
 000022   SORT FIELDS=(1,10,CH,A,11,10,CH,D)                                           
 ****** **************************** Bottom of Data ****************************


a properly defined SYMBOL library is like a COBOL COPYBOOK LIBRARY
OK... if You want to be picky the jcl might become a bit more complicated
if You believe that TWO DD statements have that bad influence
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 -> DFSORT/ICETOOL 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 Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
This topic is locked: you cannot edit posts or make replies. Job to wait and continue based on reply yugendran COBOL Programming 5 Wed Oct 05, 2016 1:46 pm
No new posts how to split records based on specifi... Venkata Ramayya DFSORT/ICETOOL 6 Wed Sep 28, 2016 3:20 am


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