View previous topic :: View next topic |
Author |
Message |
naveen Beginner
Joined: 03 Dec 2002 Posts: 90 Topics: 31
|
Posted: Sat May 17, 2003 4:01 am Post subject: How to replace this ? |
|
|
I've a sequential 80 recl FB file which contains one record as:
Code: | FIELD1:CAN BE ANY VALUE |
Now I want to replace this record with following record:
Code: | FIELD1:FIXED NEW VALUE |
That means anaything can appear after depending on the processing , but I want to replace it with a particular fixed string.
Sometimes the file may contain :
or at other times it may contain :
But everytime I want to replace it with :
How can we do this using batch file aid or sort ? |
|
Back to top |
|
|
savitri Beginner
Joined: 27 Jan 2003 Posts: 1 Topics: 0
|
Posted: Sat May 17, 2003 5:15 am Post subject: |
|
|
Naveen,
This can be achieved by SORT utility.
Use the following sort card
Code: | SORT FIELDS=COPY
OUTREC FIELDS=(1:1,7,8:C'FFFFF') |
Thanks,
Savitri. |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Sat May 17, 2003 10:57 am Post subject: |
|
|
Actually, you should use the following so that the output file will have LRECL=80 like the input file:
Code: |
SORT FIELDS=COPY
OUTREC FIELDS=(1:1,7,8:C'string',80:X)
|
If you use DFSORT, you can make this a little more easy to use with DFSORT symbols:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
* Replace string with constant you want
CON1,'string'
/*
//SORTIN DD ... input
//SORTOUT DD ... output
//SYSIN DD *
OUTREC FIELDS=(1,7,CON1,80:X)
/*
|
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
naveen Beginner
Joined: 03 Dec 2002 Posts: 90 Topics: 31
|
Posted: Mon May 19, 2003 12:44 am Post subject: |
|
|
Frank,
Your solution will work fine ,when :
always start at column 1. But for me it is not the case. Infact,
can start from any column from 1 to 68.
Thats why I was asking for some replace solution ...
Can we do this with sort ???
Or batch file-aid has some power to do this?? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Mon May 19, 2003 4:53 am Post subject: |
|
|
naveen,
The following JCL will give you the desired results.
Code: |
//STEP010 EXEC PGM=FILEAID
//SYSPRINT DD SYSOUT=*
//DD01 DD DSN=INPUT.DATASET,
// DISP=SHR
//DD01O DD DSN=OUTPUT.DATASET,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE),
// DCB=(RECFM=FB,LRECL=ZZZ,BLKSIZE=0)
//SYSIN DD *
$$DD01 COPY EDITALL=(1,0,C'FIELD1',C'NEW CONSTANT VALUE')
/*
|
Hope this helps...
cheers
kolusu |
|
Back to top |
|
|
naveen Beginner
Joined: 03 Dec 2002 Posts: 90 Topics: 31
|
Posted: Mon May 19, 2003 5:59 am Post subject: |
|
|
Kolusu,
It looks as if you haven't read(understood) my problem correctly. Please have a proper look at the problem.
The solution which you have suggested will just replace a particular string.
My problem is different. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Mon May 19, 2003 6:20 am Post subject: |
|
|
Naveen,
I am not sure as to what you are trying to do. But the JCL posted above does a scan of every record for 'FIELD1' irrespective of the position where it occurs and replaces it a 'NEW CONSTANT VALUE'. The new constant value can be your fixed string.This is what I assumed from your follow up post to frank who suggested the DFSORT solution. Now what am I missing in here?
Thanks
Kolusu |
|
Back to top |
|
|
naveen Beginner
Joined: 03 Dec 2002 Posts: 90 Topics: 31
|
Posted: Mon May 19, 2003 6:50 am Post subject: |
|
|
Kolusu,
Better you check my first post on this thread.
I don't want to replace 'FIELD1' with 'any other value'
I want to replace string next to 'FIELD1' with constant string.
FIELD1:xxxxx should be replaced by FIELD1:fffff
but xxxxx is not always xxxxx it could be yyyyy or anything. But I want this complete record FIELD1:xxxxx to be replaced with FIELD1:fffff
I hope I've made myself more clearer this time. |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Mon May 19, 2003 10:07 am Post subject: |
|
|
Naveen,
I've reread your original statement of your requirement and it is NOT clear. In the future, you might want to try to state your requirements more clearly, rather than fault people who are trying to help you.
Sort products do not have any built-in functions to do what you want, although it could be done using an E15 exit with the appropriate logic. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Last edited by Frank Yaeger on Mon May 19, 2003 10:55 am; edited 1 time in total |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Mon May 19, 2003 10:23 am Post subject: |
|
|
Naveen,
I understood your problem and suggested the solution, but it seems you did not even try to execute it and see what it produces. I am using the scan area to be 'FIELD1' so that I can replace the string following it.Run the following jcl which would replace 'XXXXX' (irrespective of the position) to 'FFFFF' .Note that the value 'FIELD1' is not changed at all.
Code: |
//STEP0100 EXEC PGM=FILEAID,REGION=0M
//*
//SYSLIST DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//DD01 DD *
FIELD1:XXXXXKOLUSU
FIELD1:XXXXXDALALY
FIELD1:XXXXXNAVEEN
//DD01O DD SYSOUT=*
//SYSIN DD *
$$DD01 COPY REPLALL=(01,00,C'FIELD1:',C'FIELD1:FFFFF'),OUT=0
/*
|
The out put of this job is :
Code: |
FIELD1:FFFFFKOLUSU
FIELD1:FFFFFDALALY
FIELD1:FFFFFNAVEEN
|
In my example I used EDITALL so that you can even have a larger string replace the shorter string.
Hope this helps...
cheers
kolusu |
|
Back to top |
|
|
naveen Beginner
Joined: 03 Dec 2002 Posts: 90 Topics: 31
|
Posted: Tue May 20, 2003 12:13 am Post subject: |
|
|
Kolusu ,
Your current solution
Code: | $$DD01 COPY REPLALL=(01,00,C'FIELD1:',C'FIELD1:FFFFF'),OUT=0 |
is really working great. But the solution which you posted earlier
Code: | $$DD01 COPY EDITALL=(1,0,C'FIELD1',C'NEW CONSTANT VALUE') |
was just replacing 'FIELD1:' with 'NEW CONSTANT VALUE'.
Thanks for help . |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Tue May 20, 2003 5:53 am Post subject: |
|
|
naveeen,
I used EDITALL so that you can even have a larger string replace the shorter string.Remember REPLALL will overlap the next field if the string to be replaced is larger.
Kolusu |
|
Back to top |
|
|
js01 Beginner
Joined: 13 Oct 2005 Posts: 84 Topics: 32 Location: INDIA
|
Posted: Mon Nov 14, 2005 5:01 am Post subject: |
|
|
Hi Kolusu,
you have mentioned FileAId in your post, but my shop dose not have a fileaid ,we have file master , is it possible to do this with FM or SORT utility?
thank you |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
taltyman JCL Forum Moderator
Joined: 02 Dec 2002 Posts: 310 Topics: 8 Location: Texas
|
Posted: Mon Nov 14, 2005 11:15 am Post subject: |
|
|
JS01
You could use this ISPF edit command
CHANGE P'FIELD1:=====' 'FIELD1:fffff' ALL |
|
Back to top |
|
|
|
|