Findrep without affecting other columns



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Findrep without affecting other columns

Postby xcspg3 » Sat Jul 08, 2017 3:39 pm

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
xcspg3
 
Posts: 29
Joined: Tue Sep 25, 2007 6:34 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Findrep without affecting other columns

Postby Robert Sample » Wed Jul 12, 2017 12:53 am

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Findrep without affecting other columns

Postby Aki88 » Wed Jul 12, 2017 12:02 pm

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.
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Findrep without affecting other columns

Postby xcspg3 » Wed Jul 12, 2017 1:11 pm

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.
xcspg3
 
Posts: 29
Joined: Tue Sep 25, 2007 6:34 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Findrep without affecting other columns

Postby xcspg3 » Wed Jul 12, 2017 1:21 pm

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
xcspg3
 
Posts: 29
Joined: Tue Sep 25, 2007 6:34 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Findrep without affecting other columns

Postby enrico-sorichetti » Wed Jul 12, 2017 1:33 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Findrep without affecting other columns

Postby Aki88 » Wed Jul 12, 2017 2:11 pm

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                          
 
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Findrep without affecting other columns

Postby xcspg3 » Fri Jul 14, 2017 4:20 pm

It's ok.
Your solution solved my problem.
Thanks.
Max.
xcspg3
 
Posts: 29
Joined: Tue Sep 25, 2007 6:34 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post