How to insert a character in a specific position?



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

How to insert a character in a specific position?

Postby kihaho » Wed Jul 15, 2009 12:39 am

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!!!
kihaho
 
Posts: 19
Joined: Tue May 06, 2008 11:13 pm
Has thanked: 0 time
Been thanked: 0 time

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

 

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

Postby Frank Yaeger » Wed Jul 15, 2009 12:58 am

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
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: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

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

Postby kihaho » Wed Jul 15, 2009 1:02 am

Hi Frank,
Thank you so much for the quick response.
This is exactly what I needed.
Thanks again!!!
:D
kihaho
 
Posts: 19
Joined: Tue May 06, 2008 11:13 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby kihaho » Wed Jul 15, 2009 6:38 pm

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!!!
kihaho
 
Posts: 19
Joined: Tue May 06, 2008 11:13 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Mahalakshmi R » Wed Jul 15, 2009 7:12 pm

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.
Thanks,
Mahalakshmi Rajendran
Mahalakshmi R
 
Posts: 13
Joined: Mon Jul 13, 2009 4:50 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby kihaho » Wed Jul 15, 2009 7:58 pm

Hi Mahalakshmi,
Thanks so much for sharing the info. :)
kihaho
 
Posts: 19
Joined: Tue May 06, 2008 11:13 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Frank Yaeger » Wed Jul 15, 2009 9:03 pm

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)                           
/*
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: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

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

Postby Frank Yaeger » Wed Jul 15, 2009 9:05 pm

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).
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: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

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

Postby Mahalakshmi R » Thu Jul 16, 2009 11:10 am

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.
Thanks,
Mahalakshmi Rajendran
Mahalakshmi R
 
Posts: 13
Joined: Mon Jul 13, 2009 4:50 pm
Has thanked: 0 time
Been thanked: 0 time


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post