Posted: Wed Sep 29, 2004 7:24 am Post subject: mulitplication in DFSORT
Hi,
Can anybody please help me out as to how to go about multiplying the records in a file with a fixed number say -1 ?
Secondly,is it possible to add alternate records in a file with a fixed number say -1 ?
Thanks
Cobcurious
Like Kolusu, I don't understand your requirement about "alternate records". Please explain in detail what you're trying to do, and show an example of the input records and what you want the output records to look like. _________________ 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
Hi Kolusu & Frank,
Thanks for the reply.I am sorry for not being clear on my second question. .Regarding my second question..let me explain...suppose i have 5 records in my file say 1,2,3,4,5..then I need to add/subtract records 1,2 and 3,4 and so on...Can you please suggest me any work around this problem ?
Thanks
Cobcurious
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Thu Sep 30, 2004 4:08 am Post subject:
Cobcurious,
Is this what u r trying to do ?
Code:
Input:
123
100
246
140
500
Output: U said u need to add 1,2 and 3,4....
223
386
500
If this is the case, the following job will give u desired results. If you have DFSORT in your shop change the program name to ICETOOL instead of SYNCTOOL.
A Brief Explanation of the job. The job takes 1 Step & 4 Passes over the input file to accomplish the result.
Pass 1: The input file is split into two using OUTFIL SPLIT operand.
Pass 2: An 8 digit Sequence number is added at position 41-48 to Temp file 1
Pass 3: Same as Step 2. Seq. number is added at Pos 41-48 to Temp File 2
Pass 4: The outputs of Step 2 & 3 are merged together and sorted on the sequence number added at Position 41, so that the alternate records (of the input file) are grouped one below the other and SUM FIELDS is issued on the first three columns where we have the data.
To subtract records, all you have to do is to Multiply the contents of File 1 or File 2 by a constant -1. Now when u issue a SUM, the records will actually be subtracted.
Hope this helps,
Kolusu / Frank, my solution uses 4 passes. Is there any other way to accomplish the result without so many passes ?
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Thu Sep 30, 2004 4:58 am Post subject:
Quote:
Kolusu / Frank, my solution uses 4 passes. Is there any other way to accomplish the result without so many passes ?
Phantom,
Sure can , The following DFSORT/ICETOOL Jcl just uses 2 passes to get the desired results.
A brief description of the solution. We first 2 seqnum's at the end using INREC. The first seqnum we use a START number as 500 and increment it by 500. So every even numbered record will have '000' . The other seqnum is a 8 byte seqnum.
Using a CHANGE command on the OUTREC FIELDS we change the '000' to a zero , and all other records we change it to 1.
Now using OUTREC On OUTFIL we add this number with the regular seqnum. By doing so every 2 records have the same seqnum.
Now sort on that seqnum and sum on the desired fields.While writting remove the seqnum.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Thu Sep 30, 2004 9:19 am Post subject:
Phantom,
Cool trick !
Quote:
Did I pass the Exam ?????
of course you did , But you should also have taken care of the output and format of the field. With your Job you will create a 16 byte ZD fields with leading zeroes supressed, where as the Input field is only 3 bytes.
Btw avoid using synctool/icetool when it involves just 1 pass of data.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Thu Sep 30, 2004 9:32 am Post subject:
Thanks Kolusu,
How about this code. (I saw your question very late, so I had to rush before someone posts a reply and I'm not an expert in sort to get the solution in the first run itself).
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Thu Sep 30, 2004 9:36 am Post subject:
Code:
Job you will create a 16 byte ZD fields with leading zeroes supressed
I never knew this. I was looking at my previous output and it was right justified. This is the first time I'm trying the ADD/SUB operators in sort. I learned something new today.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum