Joined: 21 Jun 2020 Posts: 12 Location: United States
Hi,
If I am using a series of FINDRECs in a SORT card (using WHEN=INIT), is there a way to add a constant pattern, say in the 73-80 columns, to indicate that those were the records that were changed as a result of the FINDREPs? Just a single constant pattern will do.
Joined: 21 Jun 2020 Posts: 12 Location: United States
sergeyken wrote:
Your description is too messy, and the terminology hardly matches those used by SORT utilities.
Please, provide some examples of input/output data.
ok . let me try again.
My code has a number of FINDREPs. All I want is an indication of which records were changed as a result of the sort - so 'CHANGED' should be added to any changed record starting in col 73. ( This is like ISPF edit where doing a 'C ALL A B' will flag any changed row with <CHG> tag.
Does that make sense? Below is the output
Input:
Code:
MMMM AA
XXXXXXXXXXXXX
NNNN DD
LLLLLLLLLLLLLL
Output:
Code:
MMMM PP CHANGED
XXXXXXXXXXXXX
NNNN SS CHANGED
LLLLLLLLLLLLLL
COMMAND INPUT ===> SCROLL ===> CSR
********************************* TOP OF DATA **********************************
MMMM PP CHANGED
XXXXXXXXXXXXX
NNNN SS CHANGED
LLLLLLLLLLLLLL
******************************** BOTTOM OF DATA ********************************
I tried to tweak my sort card to handle this. For certain reasons, I am using
multiple FINDREPS and so I have to use WHEN=INIT. Sort does not like if I add WHEN=ANY to that, not sure why.
It works, there are many other ways to do it and one should explore if interested.
I have a DFSORT , the one you posted is seems untested as gives me syntax error and doesn't look like will give the expected results.
1. In my example really the parameter HIT=NEXT was missing; at the expert forum such missing commas should be easily handled by the TS.
All the rest works fine
Code:
//SORTDATE EXEC PGM=SORT
//SYNOUT DD SYSOUT=*
//SORTIN DD *
AA BB CC DD EE
ZZ YY XX UU VV
//*
//SORTOUT DD SYSOUT=*
//*
//SYSIN DD *
INREC IFTHEN=(WHEN=(1,72,SS,EQ,L(C'AA',C'BB')),
FINDREP=(INOUT=(C'AA',C'11',
C'BB',C'22')),
HIT=NEXT),
IFTHEN=(WHEN=ANY,
OVERLAY=(73:C'CHANGED'))
SORT FIELDS=COPY
END
//*
Code:
********************************* TOP OF DATA ***********************************
11 22 CC DD EE CHANGED
ZZ YY XX UU VV
******************************** BOTTOM OF DATA *********************************
2. Regarding calling your example "It works, …" - in response to my note about logically wrong approach:
Whenever some results seem to be correct, this does not mean the original approach was correct as well. This situation described by Lewis Carroll, explaining "another way" to calculate 2+1:
Lewis Carrol wrote:
"Two added to one—if that could but be done,"
It said, "with one's fingers and thumbs!"
Recollecting with tears how, in earlier years,
It had taken no pains with its sums.
"The thing can be done," said the Butcher, "I think.
The thing must be done, I am sure.
The thing shall be done! Bring me paper and ink,
The best there is time to procure."
So engrossed was the Butcher, he heeded them not,
As he wrote with a pen in each hand,
And explained all the while in a popular style
Which the Beaver could well understand.
"Taking Three as the subject to reason about—
A convenient number to state—
We add Seven, and Ten, and then multiply out
By One Thousand diminished by Eight.
"The result we proceed to divide, as you see,
By Nine Hundred and Ninety and Two:
Then subtract Seventeen, and the answer must be
Exactly and perfectly true.
"The method employed I would gladly explain,
While I have it so clear in my head,
If I had but the time and you had but the brain—
But much yet remains to be said.
"In one moment I've seen what has hitherto been
Enveloped in absolute mystery,
And without extra charge I will give you at large
A Lesson in Natural History."
Although the result is really correct:
(2 + 1) = (3 + 7 + 10) * (1000 - 8) / 992 - 17 = 3
the "method employed" can hardly be called a right one...
Missing HIT=NEXT is a bug and not a comma missed, the next logical condition is skipped and results are not as expected.
Anyways, This is all difficult for you to understand but for me it’s simple to pick any of the approach and it’s not as complicated as you are imagining with this note. All the solutions are simple to understand and are sequentially performed when conditions are met, unless you prove it don’t work or has any performance issues there is no point in discussion further as TS got many ways achieve what was requested. Thanks