IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Findrep - an identifier to mark the actual replacements


IBM Mainframe Forums -> SYNCSORT
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
RV14

New User


Joined: 21 Jun 2020
Posts: 10
Location: United States

PostPosted: Thu Jan 07, 2021 9:47 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Thu Jan 07, 2021 10:38 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2772
Location: NYC,USA

PostPosted: Thu Jan 07, 2021 11:12 pm
Reply with quote

You can use SS operator and overlay the value you need if it matches else keep the original one.
Back to top
View user's profile Send private message
RV14

New User


Joined: 21 Jun 2020
Posts: 10
Location: United States

PostPosted: Thu Jan 07, 2021 11:16 pm
Reply with quote

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 icon_smile.gif . 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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Thu Jan 07, 2021 11:16 pm
Reply with quote

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
View user's profile Send private message
RV14

New User


Joined: 21 Jun 2020
Posts: 10
Location: United States

PostPosted: Thu Jan 07, 2021 11:18 pm
Reply with quote

I am sorry about the extra lines on output, the preview looked ok.
Back to top
View user's profile Send private message
RV14

New User


Joined: 21 Jun 2020
Posts: 10
Location: United States

PostPosted: Thu Jan 07, 2021 11:19 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Thu Jan 07, 2021 11:28 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2772
Location: NYC,USA

PostPosted: Fri Jan 08, 2021 2:09 am
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Fri Jan 08, 2021 3:04 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2772
Location: NYC,USA

PostPosted: Fri Jan 08, 2021 4:24 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2772
Location: NYC,USA

PostPosted: Fri Jan 08, 2021 4:49 am
Reply with quote

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
View user's profile Send private message
RV14

New User


Joined: 21 Jun 2020
Posts: 10
Location: United States

PostPosted: Fri Jan 08, 2021 5:33 am
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 607
Location: Bamberg, Germany

PostPosted: Fri Jan 08, 2021 10:57 am
Reply with quote

@RV14: You must have at least one logical COND to apply ANY (AFAICR).
Back to top
View user's profile Send private message
RV14

New User


Joined: 21 Jun 2020
Posts: 10
Location: United States

PostPosted: Fri Jan 08, 2021 2:52 pm
Reply with quote

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
View user's profile Send private message
RV14

New User


Joined: 21 Jun 2020
Posts: 10
Location: United States

PostPosted: Fri Jan 08, 2021 2:55 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Mon Jan 11, 2021 10:11 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2772
Location: NYC,USA

PostPosted: Tue Jan 12, 2021 12:04 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Control M features to check string in... Compuware & Other Tools 1
No new posts Unique IMS DB identifier IMS DB/DC 1
No new posts FINDREP Syntax Error DFSORT/ICETOOL 4
No new posts Syncsort version supporting FINDREP c... SYNCSORT 9
No new posts Yesterday's Date using SYMNAMES and F... DFSORT/ICETOOL 2
Search our Forums:

Back to Top