Page 1 of 1

Findrep without affecting other columns

PostPosted: Sat Jul 08, 2017 3:39 pm
by xcspg3
Hi,
I would like to use the findrep parameter to change strings in certain columns without affecting other colums.
The sort is
//SORTIN   DD *                              
1234567890123456789012345678901234567890      
          A   B     C D                      
//SORTOUT  DD SYSOUT=*                        
//SYSIN    DD *                                            
 SORT FIELDS=COPY                                          
 OUTREC FINDREP=(IN=C'   ',OUT=C' ',STARTPOS=11,ENDPOS=20)

The output is
----+----1----+----2----+----3----+----4
1234567890123456789012345678901234567890
          A B   C D                    

The columns beyond 20 are reformatted and I don't like this.

Thanks
Max

Re: Findrep without affecting other columns

PostPosted: Wed Jul 12, 2017 12:53 am
by Robert Sample
If you look in the DFSORT Application Programming Guide manual, you'll see that OUTREC FINDREP supports the STARTPOS and ENDPOS parameters to place bounds on the changes.

Re: Findrep without affecting other columns

PostPosted: Wed Jul 12, 2017 12:02 pm
by Aki88
Hello,

xcspg3 wrote:Hi,
I would like to use the findrep parameter to change strings in certain columns without affecting other colums.
The sort is
//SORTIN   DD *                              
1234567890123456789012345678901234567890      
          A   B     C D                      
//SORTOUT  DD SYSOUT=*                        
//SYSIN    DD *                                            
 SORT FIELDS=COPY                                          
 OUTREC FINDREP=(IN=C'   ',OUT=C' ',STARTPOS=11,ENDPOS=20)

The output is
----+----1----+----2----+----3----+----4
1234567890123456789012345678901234567890
          A B   C D                    

The columns beyond 20 are reformatted and I don't like this.


A query, when you're replacing the spaces between 'A' and 'B' with fewer spaces, there is a displacement of data to left which leaves spaces towards the right columns, which are SHIFTed as a default attribute of FINDREP, how do you want to account for that? What you want to achieve will depend on the answer to this question.
The output that you see is a direct result of just this.

Re: Findrep without affecting other columns

PostPosted: Wed Jul 12, 2017 1:11 pm
by xcspg3
Robert Sample wrote:If you look in the DFSORT Application Programming Guide manual, you'll see that OUTREC FINDREP supports the STARTPOS and ENDPOS parameters to place bounds on the changes.

I use startpos and endpos but the result is not ok. Maybe I don't use the parameter correctly.
Thanks.

Re: Findrep without affecting other columns

PostPosted: Wed Jul 12, 2017 1:21 pm
by xcspg3
Aki88 wrote:Hello,

xcspg3 wrote:Hi,
I would like to use the findrep parameter to change strings in certain columns without affecting other colums.
The sort is
//SORTIN   DD *                              
1234567890123456789012345678901234567890      
          A   B     C D                      
//SORTOUT  DD SYSOUT=*                        
//SYSIN    DD *                                            
 SORT FIELDS=COPY                                          
 OUTREC FINDREP=(IN=C'   ',OUT=C' ',STARTPOS=11,ENDPOS=20)

The output is
----+----1----+----2----+----3----+----4
1234567890123456789012345678901234567890
          A B   C D                    

The columns beyond 20 are reformatted and I don't like this.


A query, when you're replacing the spaces between 'A' and 'B' with fewer spaces, there is a displacement of data to left which leaves spaces towards the right columns, which are SHIFTed as a default attribute of FINDREP, how do you want to account for that? What you want to achieve will depend on the answer to this question.
The output that you see is a direct result of just this.


How can I do to force the effect of the other columns?
Thanks

Re: Findrep without affecting other columns

PostPosted: Wed Jul 12, 2017 1:33 pm
by enrico-sorichetti
You have no reason to complain ...

the findrep to find 3 blanks and substitute them with one blank SHORTENS Your <column> with the consequence of shortening the whole record

so You got what You told sort to do

Re: Findrep without affecting other columns

PostPosted: Wed Jul 12, 2017 2:11 pm
by Aki88
Couldn't think of a direct solution, but with a bit of code:


//SORTIN   DD *                                                    
1234567890123456789012345678901234567890                          
          A   B     C D                                            
//SORTOUT  DD SYSOUT=*                                            
//SYSIN    DD *                                                    
 SORT FIELDS=COPY                                                  
 INREC IFTHEN=(WHEN=INIT,                                          
               OVERLAY=(81:11,10)),                                
       IFTHEN=(WHEN=(11,4,SS,EQ,C'   '),                          
               FINDREP=(INOUT=(C'   ',C' '),STARTPOS=81,ENDPOS=90))
 OUTFIL BUILD=(1,10,81,10,21,60)                                  
/*


Yields:


----+----1----+----2----+----3----+----4----+----5
1234567890123456789012345678901234567890          
          A B       C D                          
 

Re: Findrep without affecting other columns

PostPosted: Fri Jul 14, 2017 4:20 pm
by xcspg3
It's ok.
Your solution solved my problem.
Thanks.
Max.