Page 1 of 1

Replace text for a specified column in all the records

PostPosted: Fri Jul 04, 2008 8:43 pm
by J4Jessy
Hi all,

I want to relpace the text for a specified column range (for example from cloumn 3 to column 8) and replace it with some other text (for example COBOL) for all the records in a P.S. file

Sample P.S. file layout:
123456789-->column positions
sagjhfgfq
sdfsdhdfh
hfdghdfkh
jkgjchdfg
tyuiujhdf


Now I need to replace the text for the column positions ranging from 3 to 8 with "COBOL" for all the records irrespective of whatsoever maybe the text in that column range. I need the requirement by specifing the INPUT file in the JCL (but not as instream data) as there are thousands of records in the file.

Re: Replace text for a specified column in all the records

PostPosted: Sat Jul 05, 2008 4:06 am
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file (FB)
//SORTOUT DD DSN=...  output file (FB)
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(3:C'COBOL ')
/*


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/servers/storage/supp ... tmpub.html

Re: Replace text for a specified column in all the records

PostPosted: Tue Jul 08, 2008 2:06 pm
by J4Jessy
Thanks Yaeger for your solution..but I am getting an error "E1 8 DSS10065E PARAMETER 'OVERLAY' IS UNIDENTIFIED." while checking the program for errors using "jj" command and also can I know what is the importance of 'C' in INREC OVERLAY=(3:C'COBOL ') is it the same 'C' if we want to replace specific columns with numbers (apart from characters (like COBOL)). Below is the program that I checked for errors where I got the above described error.
//AB54815# JOB 00301,'SAMPLE',
// CLASS=U,
// NOTIFY=&SYSUID,
// MSGCLASS=Z
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=AB54815.NONX.FINAL,DISP=SHR
//SORTOUT DD DSN=AB54815.NONX.FINAL.SAMPLE,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(500,500),RLSE),
// DCB=(,RECFM=FB)
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(3:C'COBOL ')
/*

Re: Replace text for a specified column in all the records

PostPosted: Tue Jul 08, 2008 8:50 pm
by Frank Yaeger
"E1 8 DSS10065E PARAMETER 'OVERLAY' IS UNIDENTIFIED."


This is NOT a DFSORT error message. I don't know what 'jj' does but it may not understand DFSORT's control statements. Make sure OPTION and INREC statement in column 2, not column 1. I don't know if that will satisfy whatever program gave that error, but it's worth a try. OVERLAY is, of course, recognized by DFSORT. Seems like something else is getting in the way.

can I know what is the importance of 'C' in INREC OVERLAY=(3:C'COBOL ') is it the same 'C' if we want to replace specific columns with numbers (apart from characters (like COBOL)).


C means character string. DFSORT can handle constants for many types of "numbers" (ZD, PD, BI, FI, etc). How you would code a constant for a specific number depends on the format of the number. For example if you wanted to use a constant of PL5'12345', you could code it as:

    INREC OVERLAY=(3:+12345,TO=PD,LENGTH=5)


or as:

    INREC OVERLAY=(3:X'12345C')


You'll need to be more specific about the type of number constant you want before I can provide more specific help.

Re: Replace text for a specified column in all the records

PostPosted: Wed Jul 09, 2008 1:06 pm
by J4Jessy
OK Yaeger, now I got the desired output. But one question that tickles my mind is that in "INREC OVERLAY=(3:C'COBOL ')", what are all the other options (just like you used 'X' in your previous reply) which we can use in place of 'C' and their functions(use). I would be thankful if you let me know the same and I also could not know what was PL5 in PL5'12345' which you were explaining in the previous post. I also tried giving '12345 ', 'abc12 ', '123ab ' in place of COBOL in "INREC OVERLAY=(3:C'COBOL ')", to my surprise all worked fine in the output file as I was thinking only characters would be replaced if we are using 'C' which is a character string. So, could you please provide me some explanation for this...

Re: Replace text for a specified column in all the records

PostPosted: Wed Jul 09, 2008 9:46 pm
by Frank Yaeger
C'string' is a character constant - you can use any character in string.

X'hh...' is a hexadecimal constant - hh is a pair of hexadecimal characters (00-FF).

+n is a positive decimal constant.
-n is a negative decimal constant.

PL5'12345' is the Assembler notation for a 5-byte PD value of 12345.

You can look up everything about DFSORT syntax in "z/OS DFSORT Application Programming Guide" which you can access from:

http://www.ibm.com/servers/storage/supp ... tmpub.html

Re: Replace text for a specified column in all the records

PostPosted: Thu Jul 10, 2008 2:40 pm
by J4Jessy
Thank you once again for your help and support Yaeger...