Page 1 of 1

DFSORT - How to replace a file prefix with another String

PostPosted: Tue Jan 13, 2015 2:40 am
by Natasha
Hello,

This is quite simple to code programatically (in Cobol, rexx ect), but I wonder if it can be done through DFSORT ?

I have a file containing a file name (up to 44 bytes), followed by a 8 byte string (always in pos 46). I want to replace the 'high level qualifier' in position 1, with the 8 byte string, for example.

Input
PROD.MY.TEST.FILE                 TEST
TEST.ANOTHER.FILE.OF.MINE         DEV


Output
TEST.MY.TEST.FILE
DEV.ANOTHER.FILE.OF.MINE



I've looked at the DFSORT manual, PARSE, OVERLAY, FINDREP, but I can't quite get this to work. I could write some rexx to do this, but is it possible in DFSORT ?

Thank you.

Re: DFSORT - How to replace a file prefix with another Strin

PostPosted: Tue Jan 13, 2015 3:56 am
by BillyBoyo
Yes, it can be done. PARSE is what you want. Can you show the code you tried for PARSE so we can fix it up?

Re: DFSORT - How to replace a file prefix with another Strin

PostPosted: Wed Jan 14, 2015 1:10 am
by Natasha
Hello,

I finally got it to work although it might not be the most elegant solution. I was attempting to code the PARSE, SQZ and BUILD all within the OUTREC command, until I realised that I could use INREC and OUTREC.
I like to use utilities whenever possible so I was determined to get it to work.

  OPTION COPY                                                 
  INREC  PARSE=(%01=(STARTAT=C'.',ENDAT=C' ',FIXLEN=44)),     
      BUILD=(46,8,%01)                                       
  OUTREC BUILD=(1,60,SQZ=(SHIFT=LEFT))                         
  END         


Thanks

Re: DFSORT - How to replace a file prefix with another Strin

PostPosted: Wed Jan 14, 2015 6:18 pm
by BillyBoyo
That's a serviceable solution.

You can two IFTHEN=(WHEN=INIT prefixing the PARSE and the two BUILDs to get them all on INREC.

I'm not sure why you have 1,60. It only needs to be 1,50. Note that you may be building a DSN longer than is allowed. You can check for that if you feel it may be an issue with your particular data.