|
View previous topic :: View next topic
|
| Author |
Message |
RV14
New User
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.
| Code: |
INREC IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=('AA','PP','BB','QQ')))
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=('CC','RR','DD','SS')))
|
There are far too many FINDREPS and 'groups' of them belong together and hence I am separating them out this way.
When a record on input ends up with any of the replacements, can we add
a constant character sequence to cols 73-80?
Thanks! |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
Your description is too messy, and the terminology hardly matches those used by SORT utilities.
Please, provide some examples of input/output data. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| You can use SS operator and overlay the value you need if it matches else keep the original one. |
|
| Back to top |
|
 |
RV14
New User
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
|
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| RV14 wrote: |
When a record on input ends up with any of the replacements, can we add
a constant character sequence to cols 73-80? |
What is “a constant character sequence”?? |
|
| Back to top |
|
 |
RV14
New User
Joined: 21 Jun 2020 Posts: 12 Location: United States
|
|
|
|
| I am sorry about the extra lines on output, the preview looked ok. |
|
| Back to top |
|
 |
RV14
New User
Joined: 21 Jun 2020 Posts: 12 Location: United States
|
|
|
|
| sergeyken wrote: |
| RV14 wrote: |
When a record on input ends up with any of the replacements, can we add
a constant character sequence to cols 73-80? |
What is “a constant character sequence”?? |
Hope I have clarified a little more. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| Code: |
INREC IFTHEN=(WHEN=(1,72,SS,EQ,L(C’AA’,C’BB’,C’CC’,C’DD’)),
FINDREP=(INOUT=('AA','PP','BB','QQ',
'CC','RR','DD','SS'))),
IFTHEN=(WHEN=ANY,
OVERLAY=(73:C’CHANGED’)) |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Code: |
//S1 EXEC PGM=SORT
//SORTIN DD *
MMMM AA
XXXXXXXXXXXXX
NNNN DD
LLLLLLLLLLLLLL
//SORTOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,72,SS,EQ,C'AA',OR,
1,72,SS,EQ,C'DD'),OVERLAY=(73:C'CHANGED'))
OUTREC IFTHEN=(WHEN=(1,72,SS,EQ,C'AA',OR,
1,72,SS,EQ,C'DD'),
FINDREP=(INOUT=(C'AA',C'PP',C'DD',C'SS'))) |
| Code: |
COMMAND INPUT ===> SCROLL ===> CSR
********************************* TOP OF DATA **********************************
MMMM PP CHANGED
XXXXXXXXXXXXX
NNNN SS CHANGED
LLLLLLLLLLLLLL
******************************** BOTTOM OF DATA ******************************** |
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
Logically wrong approach:
Step 1: mark all records requiring change as already CHANGED,
Step 2: proceed with the change of (hopefully, the same) records. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Single Pass-
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,72,SS,EQ,C'AA',OR,
1,72,SS,EQ,C'DD'),
FINDREP=(INOUT=(C'AA',C'PP',C'DD',C'SS')),HIT=NEXT),
IFTHEN=(WHEN=(1,72,SS,EQ,C'PP',OR,1,72,SS,EQ,C'SS'),
OVERLAY=(73:C'CHANGED')) |
|
|
| Back to top |
|
 |
RV14
New User
Joined: 21 Jun 2020 Posts: 12 Location: United States
|
|
|
|
| sergeyken wrote: |
| Code: |
INREC IFTHEN=(WHEN=(1,72,SS,EQ,L(C’AA’,C’BB’,C’CC’,C’DD’)),
FINDREP=(INOUT=('AA','PP','BB','QQ',
'CC','RR','DD','SS'))),
IFTHEN=(WHEN=ANY,
OVERLAY=(73:C’CHANGED’)) |
|
Thanks! this worked with HIT=NEXT.
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.
| Code: |
INREC IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C’AA’,C’PP’))),
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C’DD’,C’SS’))),
IFTHEN=(WHEN=ANY,
OVERLAY=(73:C’CHANGED’))
|
Any thoughts? |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| @RV14: You must have at least one logical COND to apply ANY (AFAICR). |
|
| Back to top |
|
 |
RV14
New User
Joined: 21 Jun 2020 Posts: 12 Location: United States
|
|
|
|
| Joerg.Findeisen wrote: |
| @RV14: You must have at least one logical COND to apply ANY (AFAICR). |
ok makes sense. Is there any way around this? maybe a dummy logical COND statement? Will try it out. |
|
| Back to top |
|
 |
RV14
New User
Joined: 21 Jun 2020 Posts: 12 Location: United States
|
|
|
|
| Rohit Umarjikar wrote: |
Single Pass-
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,72,SS,EQ,C'AA',OR,
1,72,SS,EQ,C'DD'),
FINDREP=(INOUT=(C'AA',C'PP',C'DD',C'SS')),HIT=NEXT),
IFTHEN=(WHEN=(1,72,SS,EQ,C'PP',OR,1,72,SS,EQ,C'SS'),
OVERLAY=(73:C'CHANGED')) |
|
Thanks Rohit. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| Rohit Umarjikar wrote: |
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... |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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 |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|