Page 1 of 2

want some help on findrep

PostPosted: Tue Jul 16, 2019 2:39 pm
by shub2204
I have a file FB lrecl 458 , on column 300 to 339 i want to replace comma with spaces and comma can be present anywhere in between this position.
here is my sortcard but it is not giving correct results

SORT FIELDS=COPY
OUTREC TFTHEN=(WHEN=INIT
FINDREP=(STARTPOS=300,ENDPOS=339,INOUT=(C',',C' '))
 

Any help will be appreciated

Re: want some help on findrep

PostPosted: Tue Jul 16, 2019 3:21 pm
by NicC
Try posting in the correct forum first of all. A sort question goes to one of the sort forums, not Site Announcements.
Also use the code tags to present your sort control statements, data, JCL program code and anything else that needs a fixed pitch font. I have fixed it up for you this time.
What do you mean by "not giving correct results"? Show any error messages or sample input and incorrect output.

Re: want some help on findrep

PostPosted: Tue Jul 16, 2019 6:24 pm
by NicC
INREC IFTHEN=(WHEN=INIT,
FINDREP=(STARTPOS=300,ENDPOS=339,IN=X'6b',OUT=X'40'))


You have a couple of typos in your post - you should cut and paste instead of re-writing:
TFTHEN instead of IFTHEN
Comma missing after INIT

Re: want some help on findrep

PostPosted: Tue Jul 16, 2019 6:34 pm
by shub2204
Hi Nic,

Thank for quick reply..here is my input record.

input

300col                                  339 col(on comma it is 340)
AMAZON EU SAR, UK BRANCH                 ,datatdatdatatatattaatta
AMAZON EU SAR, UK BRANCH                 ,datatatattatatatatatataa    
 


i want to remove any comma coming in between position 300 to 339 to spaces.
using above sort card result look like this


AMAZON EU SAR  UK BRANCH                 ,datatdatdatatatattaatta
AMAZON EU SAR, UK BRANCH                  datatatattatatatatatataa
 


commas are getting replaced randomly..like it is replacing commas with spaces in columns which are not in start and end pos

Re: want some help on findrep

PostPosted: Tue Jul 16, 2019 6:56 pm
by NicC
Unfortunately the version of DFSort that I have access to is so old that it does not appear to support FINDREP. Maybe someone else can come up with a solution.

Re: want some help on findrep

PostPosted: Wed Jul 17, 2019 3:19 am
by willy jensen
This seems to work
//S1       EXEC PGM=SORT                                              
//SYSOUT   DD SYSOUT=*                                                
//SORTOUT  DD SYSOUT=*                                                
//SORTIN   DD *                                                        
AMAZON EU SAR, UK BRANCH                 ,datat,dat,datata,tattaatta  
AMAZON EU SAR, UK BRANCH                 ,datatat,at,tatat,atatatataa  
//SYSIN    DD *                                                        
 SORT FIELDS=COPY                                                      
 INREC IFTHEN=(WHEN=INIT,                                              
 FINDREP=(STARTPOS=20,ENDPOS=60,IN=C',',OUT=C' '))                    

Result:
AMAZON EU SAR, UK BRANCH                  datat dat datata tattaatta  
AMAZON EU SAR, UK BRANCH                  datatat at tatat atatatataa  

Re: want some help on findrep

PostPosted: Wed Jul 17, 2019 1:52 pm
by shub2204
Hi Willy

Thanks for reply..
i have a file length of 480 and i want to remove comma and replace them with spaces ..if they occur anywhere between position 300 to 339
using above sort card my commas are replacing randomly like anywhere in pos 2 then in pos 41 wherever it is encountering comma,,but randomly for next record it is not replacing comma at 2 and 41..then for next it is replacing at other location.

Re: want some help on findrep

PostPosted: Wed Jul 17, 2019 2:41 pm
by willy jensen
Ok I set up a test with a FB 480 dataset and control data
SORT FIELDS=COPY                                      
 INREC IFTHEN=(WHEN=INIT,                              
 FINDREP=(STARTPOS=300,ENDPOS=339,IN=C',',OUT=C' '))  

Input
   WJ.DS.FB480                                     Columns 00295 00366
+----0----+----1----+----2----+----3----+----4----+----5----+----6----+-
a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,
b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,
c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,

output
   WJ.DS.FB480.OUT                                 Columns 00295 00366
+----0----+----1----+----2----+----3----+----4----+----5----+----6----+-
a,a,a a a a a a a a a a a a a a a a a a a a a,a,a,a,a,a,a,a,a,a,a,a,a,a,
b,b,b b b b b b b b b b b b b b b b b b b b b,b,b,b,b,b,b,b,b,b,b,b,b,b,
c,c,c c c c c c c c c c c c c c c c c c c c c,c,c,c,c,c,c,c,c,c,c,c,c,c,

Still looks ok to me. Are you absolutely sure that you are using control data like shown here?

Re: want some help on findrep

PostPosted: Wed Jul 17, 2019 4:18 pm
by NicC
shub2204 - (STARTPOS=300,ENDPOS=339,INOUT=(C',',C' '))
Willy - (STARTPOS=300,ENDPOS=339,IN=C',',OUT=C' '))
Note the difference.

Re: want some help on findrep

PostPosted: Wed Jul 17, 2019 4:49 pm
by shub2204
hi Willy,

Let me show you using images..as paste is disabled via remote desktop


check the images here:
[url]
https://photos.app.goo.gl/W3FTABcbrjuEdgwb9
[/url]

as i image you can see instead of spaces to be replaced by comma , commas are getting replaced at other positions..can't seem to figure out what is the issue..though sort card is perfect.