Replace text for a specified column in all the records



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

Replace text for a specified column in all the records

Postby J4Jessy » Fri Jul 04, 2008 8:43 pm

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.
J4Jessy
 
Posts: 4
Joined: Fri Jul 04, 2008 8:20 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Frank Yaeger » Sat Jul 05, 2008 4:06 am

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
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

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

Postby J4Jessy » Tue Jul 08, 2008 2:06 pm

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 ')
/*
J4Jessy
 
Posts: 4
Joined: Fri Jul 04, 2008 8:20 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Frank Yaeger » Tue Jul 08, 2008 8:50 pm

"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.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

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

Postby J4Jessy » Wed Jul 09, 2008 1:06 pm

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...
J4Jessy
 
Posts: 4
Joined: Fri Jul 04, 2008 8:20 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Frank Yaeger » Wed Jul 09, 2008 9:46 pm

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
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

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

Postby J4Jessy » Thu Jul 10, 2008 2:40 pm

Thank you once again for your help and support Yaeger...
J4Jessy
 
Posts: 4
Joined: Fri Jul 04, 2008 8:20 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post