View previous topic :: View next topic
|
Author |
Message |
janusman
New User
Joined: 09 Sep 2008 Posts: 31 Location: India
|
|
|
|
Hi,
I have a requirement where i need to replace a value in file2 with a value from i/p file(file 1).
for e.g.
i have a date file (say file1) from which i need to get date. (it has date and nothing else). I don't have to reformat the date since they are in same format.
I have another file (say file2) in which i want the date present in file2 in some position (say 100) to be replaced with the date that was got from file1.
Files are FB.
Can someone give me some idea on how to go about it? |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Run two DFSORT steps. The first step to generates SYMNAMEs with the value from File1 (e.g. ThisDate,mm/dd/yy). The second step uses the SYMNAME to replace the value in FILE2 records.
SORTIN for first step, assuming date starts at position 1 and is 8 long:
Code: |
OUTREC BUILD=(C'ThisDate,C'''1,8,C'''',80:X) |
For a date value of 01/16/09 this will generate SORTOUT with
ThisDate,C'01/16/09'
This, used as SYMNAMES dd in second step allows you to use ThisDate as the value to be inserted at the appropriate point of the output.
Garry. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
janusman,
If you need more help with this, tell me the starting position and length of the date in input file1. |
|
Back to top |
|
|
janusman
New User
Joined: 09 Sep 2008 Posts: 31 Location: India
|
|
|
|
Frank,
Sorry for the late reply. Here are the details.
input file:
position length data
1 2 month (say 12)
4 2 date (say 23)
20 18 date in words (need to replace the complete string)
Output file
position length data
1223 2 month
1225 2 date
2464 18 date in words
Input file is a VSAM. Output file is a PS file (FB, LRECL 5000).
I need to replace the month, date, and date in words (a string of 18) from the value in i/p to values in o/p.
No conditions for replacing. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for. I assumed your VSAM input file has 5000 byte records.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... date file
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(C'Replace1,''',1,2,4,2,C'''',80:X,/,
C'Replace2,''',20,18,C'''')
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... VSAM input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
RECORD TYPE=F
INREC OVERLAY=(1223:Replace1,2464:Replace2)
/*
|
|
|
Back to top |
|
|
janusman
New User
Joined: 09 Sep 2008 Posts: 31 Location: India
|
|
|
|
Frank,
Thanks for the reply. When I ran the job, the output put file i got was jus a copy of the input VSAM file.
My requirement was to replace the value in the output file which already has some data in it. All the other data should not be touched upon. only the position in which the dates were specified earlier are to be replaced with the dates from the input VSAM file.
So I changed the SORTIN file to the data file (in which i need the date to be replaced with) instead of the VSAM date file and got the desired result.
Thanx for the help. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Huh? In my job, the SORTIN file for step S1 is the date file - the one you called the "date file" with the date and nothing else. The SORTIN file for step S2 is the file in which the dates are to be replaced - the one you called "another file". Step S2 produces a SORTOUT output file with the dates replaced. I have no idea what files you plugged in where, but if you had plugged in the files as documented in my job, you would have gotten an output file with the dates replaced for step S2's SORTOUT. |
|
Back to top |
|
|
janusman
New User
Joined: 09 Sep 2008 Posts: 31 Location: India
|
|
|
|
Ok.
I got confused. The another file in in which the dates are to be replaced is not VSAM. It is a PS file.
So in second step, when you said the sortin as VSAM input file, i got confused with date file which is the only VSAM here. I think my statement in previous post was a little ambiguous "input file is VSAM - i meant the date file". Sorry for that.
Thanx. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Oh, I see. When you said "Input file is a VSAM" I naturally interpreted that as meaning the input file, not the date file. Anyway, I hope the job did what you wanted. |
|
Back to top |
|
|
ArulvelKumar
New User
Joined: 24 Jan 2009 Posts: 4 Location: Preston
|
|
|
|
Hello,
I was searching the web for a similar requirement and found this article.
My requirement is to replace a value from input file to a particular position in output file, in corresponding record. Say, input file has 10 records and output file has 10 records. The value from first record should go to 1st record in output file to x position, 2nd to 2nd and so on.
When I tried this job for my requirement I get ICE275A error for second value. How can I extend this job to my requirement?
Thanks in advance for your help. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
When I tried this job for my requirement I get ICE275A error for second value. How can I extend this job to my requirement? |
I can't read your mind to figure out the job you used that got the ICE275A. Please show your job and the messages you received.
The symbol approach would work for 10 records, but it wouldn't necessarily be the best approach depending on the maximum number of records you can have. So what's the maximum?
Please show an example of the records in your input file (relevant fields only) and what you expect for output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of each relevant field. |
|
Back to top |
|
|
ArulvelKumar
New User
Joined: 24 Jan 2009 Posts: 4 Location: Preston
|
|
|
|
Hello Frank,
I am using the job you have given earlier in this topic. S1 step to create the SYMNAME file and S2 step to use the symname to replace a position in output file.
- Input file (for first step) has 20 alphanumeric characters and it is fixed length. For some records value could be NULL - hex zeroes.
- Output file LRECL is 6500 and it is fixed too.
- Number of records in input as well as output will be same (will range between 4 Lakhs to 4 Million).
I want the 20 characters in input to replace positions 4901 through 4920 in the output file. Rest of the data in output file should remain as it was.
Messages I am getting are
1ICE270I 0 PROCESSING SYMNAMES STATEMENTS
1 Invalue,C'TEST TWO '
£
ICE275A 0 DUPLICATE SYMBOL
Invalue,C'TEST 3 '
£
etc..
I am not getting this message for first record value in input. Error message starts from second value.
Sorry, I hadn't explained clearly in my previous post. |
|
Back to top |
|
|
ArulvelKumar
New User
Joined: 24 Jan 2009 Posts: 4 Location: Preston
|
|
|
|
Sure.
Example data for one record:
Input file1: ABC123455XYZ (from positions 1 to 20)
Input file2: ......................JFN987654MNO........................... (the portion of data I have show is from 4901 to 4920. Dots are for rest of the data)
Here I want ABC123455XYZ from Input file 1 to replace JFN987654MNO in Input file 2 and carry over rest of the data from Input file 2 as it is... to the Output file.
So the first record in output file for me should read
Output file: ......................ABC123455XYZ...........................
LRECL and RECFM information
Input file1: 20 FB
Input file2: 6500 FB
Output file: 6500 FB |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You could use the Symbols technique for 10 records by setting up the symbol name using a sequence number, e.g. Invalue01 for the first symbol, Invalue02 for the second symbol, etc. Since you just used the same symbol repeatedly, of course you got an error message. How did you expect DFSORT to distinguish between the different symbols when you used the same symbol names for all of them?
Quote: |
Number of records in input as well as output will be same (will range between 4 Lakhs to 4 Million). |
The symbol technique will work for a small number of records, but it won't work for the number of records you're talking about. You would have to use a different technique.
Based on what you've said in your posts, I believe the following DFSORT/ICETOOL job will do what you asked for.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/20)
//IN2 DD DSN=... input file2 (FB/6500)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/6500)
//TOOLIN DD *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(6501,8,PD) WITH(4901,20) USING(CTL3)
/*
//CTL1CNTL DD *
INREC OVERLAY=(6501:SEQNUM,8,PD)
/*
//CTL2CNTL DD *
INREC BUILD=(4901:1,20,6501:SEQNUM,8,PD)
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,BUILD=(1,6500)
/*
|
|
|
Back to top |
|
|
ArulvelKumar
New User
Joined: 24 Jan 2009 Posts: 4 Location: Preston
|
|
|
|
Hi Frank,
Thank you so much for the JCL !!! I got the expected output.
Arul |
|
Back to top |
|
|
|