|
View previous topic :: View next topic
|
| Author |
Message |
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
that' s what I like in these forum(s)/fora...
the clear and consistent descriptions of the requirements  |
|
| Back to top |
|
 |
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
the requirement is still clear as mud...  |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
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 |
|
 |
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
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
|
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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 |
|
 |
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| 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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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".. . .
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 |
|
 |
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
 |
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 767 Location: Whitby, ON, Canada
|
|
|
|
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"?  |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| 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.  |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| 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 |
|
 |
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| 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 |
|
 |
PeterHolland
Global Moderator

Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
| Quote: |
if You believe that TWO DD statements have that bad influence
|
And how about :
//SYMNOUT DD SYSOUT=*
Thats a whole lot more jcl statements. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
here is a solution without using symnames
it will sort the records in the proper sequence on both fields
only for the AF records it will leave them alone, but in the proper place relative to the others
| Code: |
****** ***************************** Top of Data ******************************
000001 //ENRICO1 JOB NOTIFY=&SYSUID,
000002 // MSGLEVEL=(1,1),CLASS=A,MSGCLASS=X
000003 //*
000004 //ICE1 EXEC PGM=SORT
000005 //SYSPRINT DD SYSOUT=*
000006 //SYMNOUT DD SYSOUT=*
000007 //SYSOUT DD SYSOUT=*
000008 //TOOLMSG DD SYSOUT=*
000009 //DFSMSG DD SYSOUT=*
000010 //SORTIN DD *
000011 AB9
000012 ZQ8
000013 AB7
000014 XB9
000015 YA8
000016 XB7
000017 AF9
000018 AF5
000019 AF2
000020 AF5
000021 //SORTOUT DD SYSOUT=*,DCB=(RECFM=FB,LRECL=80)
000022 //SYSIN DD *
000023 OPTION EQUALS
000024 SORT FIELDS=(81,3,CH,A)
000025 INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'AF'),OVERLAY=(81:1,2,C' ')),
000026 IFTHEN=(WHEN=NONE,OVERLAY=(81:1,2,3,1))
000027 OUTREC BUILD=(1,80)
****** **************************** Bottom of Data **************************** |
result
| Code: |
********************************* TOP OF DATA **********************************
AB7
AB9
AF9
AF5
AF2
AF5
XB7
XB9
YA8
ZQ8
******************************** BOTTOM OF DATA ********************************
|
just a proof of concept, modify the fields positions according to Your needs |
|
| Back to top |
|
 |
PeterHolland
Global Moderator

Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
SORT FIELDS=(FLD1,A,FLD2,A)
tells me nothing about field characteristics, now i have to browse another
dataset for the SYMNAMES definition. A waste of time. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| Quote: |
And how about :
//SYMNOUT DD SYSOUT=*
|
that was already counted in the two...
//SYMNAMES ==>1
//SYMNOUT ==> 2
| Quote: |
SORT FIELDS=(FLD1,A,FLD2,A)
tells me nothing about field characteristics, now i have to browse another
dataset for the SYMNAMES definition. A waste of time. |
You just started a religion war  |
|
| Back to top |
|
 |
PeterHolland
Global Moderator

Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
| Quote: |
You just started a religion war
|
I hope i didnt, its just what i think. Bill Woodger is a Cobol zealot, so i understand he loves to use SYMNAMES to define Cobol like names. Well
whoever wants to use it, thats ok with me. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|