Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replacing A string in file using JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Hari Kumar

New User


Joined: 28 Jul 2005
Posts: 19

PostPosted: Tue Oct 04, 2005 12:43 pm    Post subject: Replacing A string in file using JCL
Reply with quote

Hi All,

How to replace a string for example ?01? to ?10? in a file using JCL.
I need only the particular position like 23rd column.
In the i/p file the values are with ?01? in column 23..
I need the o/p file with values ?10? in 23 column.
Give solution for this problem.
Let me know if you need more Information.

Thanks & Regards
Hari B

Enjoy your life today because yesterday had gone and tomorrow may
never come
Back to top
View user's profile Send private message

angelalpe
Warnings : 1

New User


Joined: 22 Sep 2005
Posts: 32

PostPosted: Tue Oct 04, 2005 2:14 pm    Post subject:
Reply with quote

Tests this: in the line of commands writes


CHANGE '01' '10' 23 ALL


If you write ALL does the changes in all the JCL, if you do not write ALL changes only in the first case
Back to top
View user's profile Send private message
Hari Kumar

New User


Joined: 28 Jul 2005
Posts: 19

PostPosted: Tue Oct 04, 2005 2:22 pm    Post subject:
Reply with quote

Hi,

Thanks for your Reply.I need JCL Step for this.

I think using SORT it is possible. Can anyone give solution for this.

Thanks in Advance,
Hari B
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Oct 04, 2005 8:42 pm    Post subject:
Reply with quote

Here are two different ways to do this with DFSORT:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(23,2,CH,EQ,C'01'),OVERLAY=(23:C'10'))
/*


Code:

//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(23:23,2,CHANGE=(2,C'01',C'10'),NOMATCH=(23,2))
/*


You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's IFTHEN and OVERLAY functions. Only DFSORT has these functions, so if you don't have DFSORT, you won't be able to use them. If you do have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/
Back to top
View user's profile Send private message
rikshi

New User


Joined: 03 Oct 2005
Posts: 8

PostPosted: Tue Oct 04, 2005 9:28 pm    Post subject: Re: Replacing A string in file using JCL
Reply with quote

INREC IFTHEN=(WHEN=(23,2,CH,EQ,C'01'),OVERLAY=(23:C'10')) Hardcoding 10 is fine.If that position keeps changing each and every run,then how do we replace the changed variable in that position?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Oct 04, 2005 10:36 pm    Post subject:
Reply with quote

I don't understand what you're asking. Please give an example to clarify.
Back to top
View user's profile Send private message
rikshi

New User


Joined: 03 Oct 2005
Posts: 8

PostPosted: Wed Oct 05, 2005 9:22 am    Post subject: Re: Replacing A string in file using JCL
Reply with quote

OVERLAY=(23:C'10')) .

In the i/p file the values are with ?01? in column 23..
I need the o/p file with values in 23 column which keeps changing.
eg.,
1. if I need the system time in that position,then what do i do for that?
2.If i have the output dataset which contains some 2 character value which differs for each run.
Is it possible?

hope you understand me now.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Oct 05, 2005 8:09 pm    Post subject:
Reply with quote

No, I really don't understand you.

If the value you need in positions 23-24 keeps changing, how do you know what value you need for each run?

If you need the system time, you can use one of DFSORT's built-in functions for that, e.g. TIME1. See the following for more details:

http://www.ibm.com/servers/storage/support/software/sort/mvs/professor_sort/srtmatsm.html
Back to top
View user's profile Send private message
sourab
Warnings : 1

New User


Joined: 05 Oct 2005
Posts: 6

PostPosted: Thu Oct 06, 2005 2:28 am    Post subject:
Reply with quote

Hari,

Since the field you want to replace can contain any value and can be at any position, I think better option is to write a cobol program which accepts following value in the linkage section
1. Field Start position
2. Field Lenght
3. Current value
3. replacement value

Use JCL to pass these parameters (Use Symbolic parameters).

In the given scenrio you would like to pass
1. Field Start position = 23
2. Field Lenght = 2
3. Current value = 01
4. replacement value = 10

in the program, check if position 23,2 contains current value.. then replace it by replacement value using move command...

- Saurabh
Back to top
View user's profile Send private message
rikshi

New User


Joined: 03 Oct 2005
Posts: 8

PostPosted: Thu Oct 06, 2005 10:41 am    Post subject:
Reply with quote

Thanks for all your replies.
Quote:
If the value you need in positions 23-24 keeps changing, how do you know what value you need for each run?


I have a dataset which contains 1101(numeric value).Let us create this dataset as www.xxx.yyy1 in one step.
In the next step,consider www.xxx.yyy2 as a dataset which contains
223133
123413
321134
434890
...so on.

the condition is,if the first 4 chracter is '1234' then we have to replace it with the value of the dataset www.xxx.yyy1(1101).

The output should like

223133
110113
321134
434890

Is it possible to acheive?

thanks in advance.
Back to top
View user's profile Send private message
Doubts_ask

New User


Joined: 04 Oct 2005
Posts: 9

PostPosted: Thu Oct 06, 2005 12:57 pm    Post subject: Re: Replacing A string in file using JCL
Reply with quote

Hari,

To replace 01 as 10 in 23rd column can be done in 3 steps.

step 1:

//STEP2000 EXEC PGM=SORT
//SORTIN DD DSN=<dsname>,DISP=SHR
//SORTOUT DD DSN=&&TEMP1,DISP=(NEW,PASS)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(23,2,CH,EQ,C'01')
OUTREC FIELDS=(1,22,C'10',25,80)
/*

This step will extract only records which has 01 in 23rd column and will change it to 10.

Step 2:

//STEP3000 EXEC PGM=SORT
//SORTIN DD DSN=<dsname>,DISP=SHR
//SORTOUT DD DSN=&&TEMP2,DISP=(NEW,PASS)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(23,2,CH,NE,C'01')
OUTREC FIELDS=(1,80)
RECORD TYPE=F
/*

This step will extract rows which doesn't have 01 value in 23rd column.

Step 3:

//STEP4000 EXEC PGM=SORT
//SORTIN DD DSN=&&TEMP1,DISP=(OLD,DELETE,DELETE)
// DD DSN=&&TEMP2,DISP=(OLD,DELETE,DELETE)
//SORTOUT DD DSN=<output dsname>,
// DISP=(NEW,CATLG,DELETE),
// RECFM=FB,LRECL=80,SPACE=(TRK,50)
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,8,CH,A)
RECORD TYPE=F
/*

This step will merge both the files created in step1 and step2. You change the FIELDS parameter as you need.

Hope this helps you.

Pls tell me if I am wrong.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Oct 06, 2005 8:44 pm    Post subject:
Reply with quote

rikshi,

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file1
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
* Create a DFSORT symbol as follows:
* TARG,C'abcd'
* where abcd is the value in positions 1-4
  OUTREC FIELDS=(C'TARG,C''',1,4,C'''',80:X)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file2
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
* Use the TARG symbol created in S1 to do the overlay.
  INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'1234'),OVERLAY=(1:TARG))
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us