Page 1 of 1

Card to replace a range of coulmns with another range of col

PostPosted: Fri Mar 22, 2013 5:18 pm
by ghosts
Hi

I want to a card to replace a range of coulmns with another range of columns

My Challenge is to replace SPACES over a range of cols in a PS with another range of columns in the same record. I want to achieve this using sort. please help me

Example:(input record)
...... ....aaa

Expected o/p: (replaced spaces with 'aaa' belonging to same record)
......aaa....aaa

Re: Card to replace a range of coulmns with another range of

PostPosted: Fri Mar 22, 2013 5:25 pm
by enrico-sorichetti
search the forum for the OVERLAY dfsort keyword
( Or the dfsort manuals )

Re: Card to replace a range of coulmns with another range of

PostPosted: Fri Mar 22, 2013 10:40 pm
by skolusu
ghosts,

The following DFSORT JCL will give you the desired results
//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
UPDATE VALUES1                                                       
UPDATE VALUES2                DON'T REPLACE ME                       
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  INREC OVERLAY=(31:1,30)
//*


The above will replace the contents at pos 31 for a length of 30 bytes with whatever you have in position 1 for 30 bytes.

However if your intention is to replace only if the contents are all spaces then you need to use IFTHEN to check for spaces and then replace. something like this
INREC IFTHEN=(WHEN=(31,30,CH,EQ,C' '),OVERLAY=(31:1,30))   

Re: Card to replace a range of coulmns with another range of

PostPosted: Mon Mar 25, 2013 8:51 am
by ghosts
Thanks skolusu, it worked for me.

this is my card, just for others

OPTION COPY                                             
INREC IFTHEN=(WHEN=(55,15,CH,EQ,C' '),OVERLAY=(55:75,15))


What can I do if I want to remove the old column (which was used for replace) from the PS file in the output....here....my file is a RECFM=VB and has a length of 85....

example of requirement:
input:
... ...aaa


expected o/p:
...aaa...

Re: Card to replace a range of coulmns with another range of

PostPosted: Mon Mar 25, 2013 1:04 pm
by BillyBoyo
Use BUILD instead of OVERLAY.
  BUILD=(1,length-of-first-part,next-position-you-want,length-of-second-part)


So,

  BUILD=(1,10,21,20)


Will get bytes one for a length of 10 and 21 for a length of 20. Anything else on the input record "disappears".