IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Replacing A string in file using JCL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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 Developer


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

PostPosted: Tue Oct 04, 2005 8:42 pm
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:

Use [URL] BBCode for External Links
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
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 Developer


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

PostPosted: Tue Oct 04, 2005 10:36 pm
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
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 Developer


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

PostPosted: Wed Oct 05, 2005 8:09 pm
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:

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
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
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 Use [URL] BBCode for External Links in one step.
In the next step,consider Use [URL] BBCode for External Links 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 Use [URL] BBCode for External Links(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
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 Developer


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

PostPosted: Thu Oct 06, 2005 8:44 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts ICETOOL to SUM String DFSORT/ICETOOL 1
No new posts Mark Previous & next lines when a... DFSORT/ICETOOL 9
Search our Forums:

Back to Top