Page 1 of 1

How to insert a character in a specific position?

PostPosted: Wed Jul 15, 2009 12:39 am
by kihaho
I have a flat file that is 22 bytes long.
It has 136 lines of data in it.
I'd like to insert "D" in the position 1 on all 136 lines.
Is there any JCL that I could run to insert "D" electronically, instead manually?
Thank you!!!

Re: How to insert a character in a specific position?

PostPosted: Wed Jul 15, 2009 12:58 am
by Frank Yaeger
Here's a DFSORT job that will do what you asked for "electronically". :)

//S1    EXEC  PGM=SORT                             
//SYSOUT    DD  SYSOUT=*                           
//SORTIN DD DSN=...  input file (FB/22)               
//SORTOUT DD DSN=...  output file (FB/22)         
//SYSIN    DD    *                                 
  OPTION COPY                                     
  INREC OVERLAY=(1:C'D')                           
/*


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/support/docview.wss? ... g3T7000080

Re: How to insert a character in a specific position?

PostPosted: Wed Jul 15, 2009 1:02 am
by kihaho
Hi Frank,
Thank you so much for the quick response.
This is exactly what I needed.
Thanks again!!!
:D

Re: How to insert a character in a specific position?

PostPosted: Wed Jul 15, 2009 6:38 pm
by kihaho
Hi Frank,
I just used the JCL you've given me and realized that it overlaid the first byte of the flat file, rather than pushing the existing rows to right by 1 byte and inserting "D" in the pos. 1.
Could you please tell me what command I should use to accomplish this?
Thank you!!!

Re: How to insert a character in a specific position?

PostPosted: Wed Jul 15, 2009 7:12 pm
by Mahalakshmi R
Hi,

use the following statements in SYSIN

   SORT FIELDS=COPY
   INREC FIELDS=(1:C'D',2:1,XXX)


Here, XXX - input record length.

Along with that output record length should be XXX + 1.

Re: How to insert a character in a specific position?

PostPosted: Wed Jul 15, 2009 7:58 pm
by kihaho
Hi Mahalakshmi,
Thanks so much for sharing the info. :)

Re: How to insert a character in a specific position?

PostPosted: Wed Jul 15, 2009 9:03 pm
by Frank Yaeger
I'd like to insert "D" in the position 1 on all 136 lines.


I guess I took "insert" to mean "overlay". Try to be clearer next time. An example of input and expected output always helps.

Since your input file has RECFM=FB and LRECL=22, you could use this DFSORT job:

//S1    EXEC  PGM=SORT                             
//SYSOUT    DD  SYSOUT=*                           
//SORTIN DD DSN=...  input file (FB/22)               
//SORTOUT DD DSN=...  output file (FB/23)         
//SYSIN    DD    *                                 
  OPTION COPY                                     
  INREC BUILD=(C'D',1,22)                           
/*

Re: How to insert a character in a specific position?

PostPosted: Wed Jul 15, 2009 9:05 pm
by Frank Yaeger
Mahalakshmi Rajendran,

When posting in this Forum, please use ubb tags around your code (I put them in for you) and use more modern syntax (e.g. BUILD instead of FIELDS).

Re: How to insert a character in a specific position?

PostPosted: Thu Jul 16, 2009 11:10 am
by Mahalakshmi R
Thanks Frank for the modern syntax. This is the learning for a (DFSORT)beginner like me and keep providing more syntaxes for us.

Please correct me if i'm wrong.