Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
Hi I have two files.... Both are created in same program but in different runs, both have header and trailer records... These file are input to next job... I want merge these two files into one file...i want skip header and trailer in second file and insert those records into first file just before first file trailer recods. Please provide me to do this. Actually first file trailer record got number of records, i want change that also. Is it possible changing that value while merging itself?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You need to give more and clearer information.
Show an example of the records in each input file (relevant fields only) and what you expect for output. Give the RECFM and LRECL of the input files. Give the starting position, length and format of all relevant fields.
Are you "merging" on a key? If so, give the starting position, length and format of the key.
Or are you copying without a key?
Is there anything in the header record that identifies it as a header record (e.g. 'H' in position 1)? If so, what?
Is there anything in the trailer record that identifies it as a trailer record (e.g. 'T' in position 1)? If so, what?
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
Hi Frank,
Thanks for ur reply...
Both the files are created using same program, but in different runs... So both the files record length(1173) and the files record format are same (VB)... Please find below ex for how the files looks....
File1: myfiles.outpu1
kjfhsdkjyfpwfdfnkdfklsdhfsldjhf
kjfsyfduysdfoiysjfsdhfksdhfsdhffsjdhf
uqynwnddskjdhasjdhapduasduapo
dashdjshadljsdhladhdasdaew
triler records ssssssss 4 trailer recrod
triler record end
File 2: myfiles.output2
ehjqwhejkhwkjqnmansasadasdmn
dmsandkjsadkjsdjkdsadasdasdasdsadsd
dsjhadksjhdkjsahdkjsadhkjashdkjs
triler records ssssssss 3 trailer recrod
triler record end
My output should be as below
kjfhsdkjyfpwfdfnkdfklsdhfsldjhf
kjfsyfduysdfoiysjfsdhfksdhfsdhffsjdhf
uqynwnddskjdhasjdhapduasduapo
dashdjshadljsdhladhdasdaew
ehjqwhejkhwkjqnmansasadasdmn
dmsandkjsadkjsdjkdsadasdasdasdsadsd
dsjhadksjhdkjsahdkjsadhkjashdkjs
triler records ssssssss 7 trailer recrod
triler record end
And my output file name should be same as first file nam. i.e myfiles.outpu1
There is no header record. Only trailer record is there.. That can be found using 'ssssssss' in a particular position(say in 37th position and its length is 8).... You can see 4 in first file trailer record and 3 in second file trailer record, my output file record contains 7. I just wanted to add 4 + 3 and write in output file. Becos this number is not total number of records in that file. It comes in different way. So i wanted just to add it.
Please give me some suggestions how to complete this.
Can i use same file name for input and output while merging??
Like below...
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I still have some questions:
You show two 'triler' records in each file. Are there exactly two trailer records in each file and can they be identified by 'triler'? Or are there more than two trailer records in each file? If so, how many (can it vary) and can they all be identified by 'triler'? Is the one with the count the only one with 'ssssssss'?
You show the count in the trailer record you want to replace as one character and don't say where it starts. I assume it's really more than one character, so how long is it, where does it start and what is its format (ZD, PD, something else))?
Quote:
Can i use same file name for input and output while merging??
You are NOT merging, you're copying. And no, you can't use the same file name for input and output while copying or merging.
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
HI Frank,
Thanks for ur reply....
There will be only two trailer records. Both can be identified 'SSSSSSSS' at position 30 to 37. Only the first trailer record is having the count. So i need to replace that only.
The count starts at 40 to 48 and its PD format (PIC S9(9)).
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
Arun,
Ok, i have given ex like that.. forget abt that...
it starts at 40 and ends at 45 and its PD format.
I just want to merge second file data before the trailer records of the first file and change the trailer record count and eliminate second file trailer.
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
Hi Arun,
Second trailer record also same as first trailer record. Not as i mentioned before. See correct Eg below. I should not reduce the trailer records from two to one. Let it be two itself. But i want change count in it during merging.
File1: myfiles.outpu1
kjfhsdkjyfpwfdfnkdfklsdhfsldjhf
kjfsyfduysdfoiysjfsdhfksdhfsdhffsjdhf
uqynwnddskjdhasjdhapduasduapo
dashdjshadljsdhladhdasdaew
triler records ssssssss 4 trailer recrod
triler records ssssssss 4 trailer recrod
File 2: myfiles.output2
ehjqwhejkhwkjqnmansasadasdmn
dmsandkjsadkjsdjkdsadasdasdasdsadsd
dsjhadksjhdkjsahdkjsadhkjashdkjs
triler records ssssssss 3 trailer recrod
triler records ssssssss 3 trailer recrod
My output should be as below
kjfhsdkjyfpwfdfnkdfklsdhfsldjhf
kjfsyfduysdfoiysjfsdhfksdhfsdhffsjdhf
uqynwnddskjdhasjdhapduasduapo
dashdjshadljsdhladhdasdaew
ehjqwhejkhwkjqnmansasadasdmn
dmsandkjsadkjsdjkdsadasdasdasdsadsd
dsjhadksjhdkjsahdkjsadhkjashdkjs
triler records ssssssss 7 trailer recrod
triler records ssssssss 7 trailer recrod
Please provide sample code, let me try with that and with my own tricks too...
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed that the positions you gave did not count the 4-byte RDW, so the 'SSSSSSSS' identifier actually starts in position 34 and the 6 byte PD count actually starts at position 44.
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
HI Frank,
Thanks for your reply...
I dont think our shop allows to use ICEMAN and ICETOOL.... Becos i have never seen these tools in my productions except in IBM Mainframes... I have been asked to do by using SORT utility..... Can you please tell me how to achieve it by using SORT utility....
Quote:
I assumed that the positions you gave did not count the 4-byte RDW, so the 'SSSSSSSS' identifier actually starts in position 34 and the 6 byte PD count actually starts at position 44.
I really dont understand this...
I said 'SSSSSSSS' is present in both the trailer records, and at postion 40 total number of record count will be there and its in PD format... I really dont know difference between ZD and PD...
And also the code which you gave is very complex for me to understand.... please provide me sample code using SORT utility....
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
please provide me sample code using SORT utility
I did.
DFSORT is the SORT utility. PGM=SORT and PGM=ICEMAN invoke DFSORT. PGM=ICETOOL invokes DFSORT's ICETOOL utility. If you have DFSORT, then you have ICETOOL (ICETOOL has been shipped with DFSORT since 1991). The job works fine based on the information you gave me. Try the job and see if it works. If it doesn't work, then you didn't give me correct information. If you get error messages, post them.
As for the positions. You said your file is a VB file. Each VB record has an RDW (record descriptor word) in positions 1-4 that gives the length of the record. So the data bytes actually start at position 5, not position 1. So when you said that your field starts in position 30, I assumed you were not counting the RDW in positions 1-4. Thus, we actually have to add 4 for the RDW and your field really starts in position 34.
BTW, I assumed you have 'ssssssss' (lower case) as the identifier as shown in your input record examples. If you actually have 'SSSSSSSS' (upper case) then change 'ssssssss' to 'SSSSSSSS' in the control statements.
Quote:
I really dont know difference between ZD and PD
A PD value would look like this in hex:
dddd...ds
where d is 0-9 and s is the sign (usually C, F or D)
A ZD value would look like this in hex:
FdFd...sd
where again d is 0-9 and s is the sign (usually C, F or D)
If your count field is actually ZD, change PD to ZD in the SUM statement (that's where I'm adding the counts from the trailer records).
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
Hi Frank,
Thanks a lotttttttttttttt.. really i got shocked when i saw ur reply.... ur explainaton was superb....
For me today is holiday, so i will try it 16th August and let u know my status....
Meanwhile i will just go thru ur code and if i have any doubts, i will post it... i just worked in IMS DB, and COBOL.... but not in SORT utilities... thats the reason i couldnot able to catch what u have posted.... Thanks again Frank.....
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
Hi Frank,
Just gone thru ur code....
I have few doubts, and here are they...
BUILD=(1,4,5:C'1',6:SEQNUM,8,ZD,14:5))
OVERLAY=(5:C'9',6:SEQNUM,8,ZD))
OPTION EQUALS,VLSHRT
I dont understand all the above lines..
One more doubt... With this code my output file contains records of both input files and at end only two trailer records having sum of the records in count field. Why i am asking was i dont understand anything just seeing the code to come up an assumption that i get my required output...
Dont mistake me that i am asking many questions... i am not much good in SORT and other JCL utilities... But now started learning...
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
One more doubt... With this code my output file contains records of both input files and at end only two trailer records having sum of the records in count field. Why i am asking was i dont understand anything just seeing the code to come up an assumption that i get my required output...
Yes, that's what the output will contain ... it's what you asked for. When I tested the job with P'3' for the count in the two input file1 trailer records and P'4' for the count in the two input file2 trailer records, the result had the data records from file1, followed by the data records from file2, followed by two output file trailer records with P'7' for the count.
Here's an explanation of how the job works. Note that I'm showing the count as readable as you did for illustration, but according to what you said, it's really an unreadable PD value.
This reformats the input file2 records to look like this in the T2 data set:
Code:
merge--key
|RDW|2|00000001|ehjqwhejkhwkjqnmansasadasdmn
|RDW|2|00000002|dmsandkjsadkjsdjkdsadasdasdasdsadsd
|RDW|2|00000003|dsjhadksjhdkjsahdkjsadhkjashdkjs
|RDW|9|00000001|triler records ssssssss 3 trailer recrod
|RDW|9|00000002|triler records ssssssss 3 trailer recrod
Now we can use the merge key in the reformatted records to MERGE the T1 and T2 files with these control statements:
Code:
MERGE FIELDS=(5,9,ZD,A)
OPTION EQUALS,VLSHRT
SUM FIELDS=(53,6,PD)
OUTFIL BUILD=(1,4,5:14)
5.9,ZD,A merges on the merge key. EQUALS ensures that the trailer records are merged in their original order. So the merged records look like this:
Code:
merge--key
|RDW|1|00000001|kjfhsdkjyfpwfdfnkdfklsdhfsldjhf
|RDW|1|00000002|kjfsyfduysdfoiysjfsdhfksdhfsdhffsjdhf
|RDW|1|00000003|uqynwnddskjdhasjdhapduasduapo
|RDW|1|00000004|dashdjshadljsdhladhdasdaew
|RDW|2|00000001|ehjqwhejkhwkjqnmansasadasdmn
|RDW|2|00000002|dmsandkjsadkjsdjkdsadasdasdasdsadsd
|RDW|2|00000003|dsjhadksjhdkjsahdkjsadhkjashdkjs
|RDW|9|00000001|triler records ssssssss 4 trailer recrod
|RDW|9|00000001|triler records ssssssss 3 trailer recrod
|RDW|9|00000002|triler records ssssssss 4 trailer recrod
|RDW|9|00000002|triler records ssssssss 3 trailer recrod
Notice the pairs of trailer records have duplicate merge keys of 900000001 for the first pair and 900000002 for the second pair. So these are the only pairs of records that are summed by the SUM statement. The counts for each pair are added and only one record of the pair is kept, resulting in two trailer records with the total count in each:
Code:
|RDW|9|00000001|triler records ssssssss 7 trailer recrod
|RDW|9|00000002|triler records ssssssss 7 trailer recrod
VLSHRT is needed to ensure that we do not terminate due to "short" records for the SUM statement (that is, records shorter than 58 bytes).
Finally, the OUTFIL statement removes the merge key from each record, so SORTOUT has:
Code:
|RDW|kjfhsdkjyfpwfdfnkdfklsdhfsldjhf
|RDW|kjfsyfduysdfoiysjfsdhfksdhfsdhffsjdhf
|RDW|uqynwnddskjdhasjdhapduasduapo
|RDW|dashdjshadljsdhladhdasdaew
|RDW|ehjqwhejkhwkjqnmansasadasdmn
|RDW|dmsandkjsadkjsdjkdsadasdasdasdsadsd
|RDW|dsjhadksjhdkjsahdkjsadhkjashdkjs
|RDW|triler records ssssssss 7 trailer recrod
|RDW|triler records ssssssss 7 trailer recrod
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
Hi Frank,
please check my input file record in the attachment i did in previous message, with the code you have provided i got output like merged both the files just like it...
After the first file records just second file records are merged... So first first file trailer record has come just before second file records and second file trailer record has come at end of the file.. and the sum of the records also not done... please see my input...
attachment removed and needs to be re-posted with copy/paste rather than "screenshot".
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
Your "screenshot" has been deleted.
Please re-post using copy/paste and the "Code" tag (near the top of the Reply editor). You can use Preview to see how your post will appear to the forum , then click Submit whan you are satisfied with the way your post appears.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Sasikumar,
The DFSORT job I posted gets the output you asked for with the input you showed and the "rules" you gave me. If you're not getting the correct output, then either your input is not what you showed, or you changed my job in some way. So you need to post the complete source for your job, all of the DFSORT messages you received in //TOOLMSG. //DFSMSG and //SYSOUT, and the input and output records. If you prefer, you can send these to me offline (yaeger@us.ibm.com) as plain text files. If you send it offline, put "DFSORT" somewhere in your Subject line to catch my attention.