|
|
| Author |
Message |
Hari Kumar
New User
Joined: 28 Jul 2005 Posts: 20
|
|
|
|
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 |
|
 |
References
|
|
 |
angelalpe Warnings : 1 New User
Joined: 22 Sep 2005 Posts: 31
|
|
|
|
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 |
|
 |
Hari Kumar
New User
Joined: 28 Jul 2005 Posts: 20
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4684 Location: San Jose, CA
|
|
|
|
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 |
|
 |
rikshi
New User
Joined: 03 Oct 2005 Posts: 9
|
|
|
|
| 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 |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4684 Location: San Jose, CA
|
|
|
|
| I don't understand what you're asking. Please give an example to clarify. |
|
| Back to top |
|
 |
rikshi
New User
Joined: 03 Oct 2005 Posts: 9
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4684 Location: San Jose, CA
|
|
| Back to top |
|
 |
sourab Warnings : 1 New User
Joined: 05 Oct 2005 Posts: 8
|
|
|
|
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 |
|
 |
rikshi
New User
Joined: 03 Oct 2005 Posts: 9
|
|
|
|
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 |
|
 |
Doubts_ask
New User
Joined: 04 Oct 2005 Posts: 10
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4684 Location: San Jose, CA
|
|
|
|
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 |
|
 |
|
|
|