Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Jul 29, 2005 4:36 pm Post subject:
You didn't give enough details to tell us clearly what you want.
Where do you want the counts? In the same output file as the copied records? In a separate output file? In three separate output files? Please show exactly what you want for the output.
Are you looking specifically for the count of records containing 'IND', the count of records containing 'GMT' and the count of records containing 'SMS', or are you looking for the count of records for the fourth field in each record which can have values others than those three.
What is the LRECL of the input file? _________________ 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
Sorry for not giving enough information.
The i/p LRECL is 126. I need all the counts in seperate file.
So I will get two o/p files. One is with the copied records form i/p file and other one is with counts.
I am looking for the count of records for the fourth field in each record. I may get in this fourth field other than 'IND','GMT' and 'SMS'.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Jul 29, 2005 5:39 pm Post subject:
Quote:
I am looking for the count of records for the fourth field in each record. I may get in this fourth field other than 'IND','GMT' and 'SMS'.
Ok, that's a problem because your fields are not in fixed locations. So you'll need a way to find the fourth field in each record before you can do the counting of those fields. That will probably require writing a program or exit with the appropriate logic, so as long as you need code for that, you might as well do code for the rest. _________________ 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
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
Posted: Sat Jul 30, 2005 12:31 am Post subject:
If the file is reasonably small, this small Rexx will do it. If it is not small, you'd just need to make the I/O a little smarter.
Code:
/* REXX */
'ALLOC F(FILE) DA(TEST) SHR REU'
'EXECIO * DISKR FILE (STEM LINES. FINIS'
counts. = 0
vals = ''
Do n=1 to lines.0
Parse Var lines.n . ',' . ',' . ',' val ',' .
If counts.val = 0 Then vals = vals val
counts.val = counts.val+1
End
Do n = 1 to words(vals)
val = word(vals,n)
Say val '=' counts.val
End
'FREE F(FILE)'
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sat Jul 30, 2005 10:45 am Post subject:
Quote:
Can we do, if I am looking for particulary about the 'IND','GMT' and 'SMS'.
Yes. The DFSORT job below will do that. You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's new 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:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/126)
//COPY DD DSN=... copy of input file (VB/126)
//COUNTS DD LRECL=22,DSN=... report (VB/22)
//SYSIN DD *
OPTION COPY,VLSCMP
* Add three counts, initialized to +0, +0 and +0, in each record:
* |RDW|00000|00000|00000|data|
* The first count is for 'IND'.
* The second count is for 'GMT'.
* The third count is for 'SMS'.
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,
5:+0,M11,LENGTH=5,
10:+0,M11,LENGTH=5,
15:+0,M11,LENGTH=5,
20:5)),
* If 'IND' found anywhere in the data, set 'IND' count to +1
* in that record.
IFTHEN=(WHEN=(20,122,SS,EQ,C'IND'),OVERLAY=(5:+1,M11,LENGTH=5),
HIT=NEXT),
* If 'GMT' found anywhere in the data, set 'GMT' count to +1
* in that record.
IFTHEN=(WHEN=(20,122,SS,EQ,C'GMT'),OVERLAY=(10:+1,M11,LENGTH=5),
HIT=NEXT),
* If 'SMS' found anywhere in the data, set 'SMS' count to +1
* in that record.
IFTHEN=(WHEN=(20,122,SS,EQ,C'SMS'),OVERLAY=(15:+1,M11,LENGTH=5))
* Put a copy of the original records in COPY by removing the counts.
OUTFIL FNAMES=COPY,BUILD=(1,4,5:20)
* Put a count for 'IND', 'GMT' and 'SMS' in COUNTS by
* totalling the 'IND' count, 'GMT' count and 'SMS' count.
OUTFIL FNAMES=COUNTS,REMOVECC,NODETAIL,
TRAILER1=('TYPE - IND - ',TOT=(5,5,ZD,M10,LENGTH=5),/,
'TYPE - GMT - ',TOT=(10,5,ZD,M10,LENGTH=5),/,
'TYPE - SMS - ',TOT=(15,5,ZD,M10,LENGTH=5))
/*
_________________ 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
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
Posted: Sat Jul 30, 2005 1:50 pm Post subject:
This solution seems like it would have several possibilities for error. For example, if IND, GMT or SMS are in other parts of the record, you would get invalid counts. A check for ",GMT," etc might help, but that doesn't insure that the string is the 4th delimited element.
OK, I'll show my biases here... The prohibition against Rexx here seems to be a case of choosing an implementation for a solution without consideration of what problem is being solved. In short, are you (Robo) sure you are using the right tool for the job? Although my example used an advanced technique of using stem variables as associative arrays, Rexx is very easy to learn and I'd say it is an essential part of the MVS environment. Not knowing the basics of Rexx will cause you lots of extra work for simple problems like this. It could be argued that "SORT" is now just another programming language, and a much more efficient one at that, but is the set of sort instructions as flexible and as easy to create, read, and maintain as a simple program written in Rexx? If performance and I/O capabilities are essential, definitely go with DFSORT, but if simplicity and flexibility are important, a user program (Rexx or otherwise) might be in order.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sun Jul 31, 2005 10:38 am Post subject:
sg,
I think REXX is a great language and useful in many situations. I offer DFSORT/ICETOOL solutions knowing that it's up to the user to decide which "tool" is appropriate for the job. I would also offer that a DFSORT exit (E15 or E35) in Assembler or COBOL, with the appropriate logic, might sometimes be a good choice but I tend not to show such solutions since people who ask for these kind of solutions often don't want to write any code for whatever reason.
Quote:
This solution seems like it would have several possibilities for error. For example, if IND, GMT or SMS are in other parts of the record, you would get invalid counts. A check for ",GMT," etc might help, but that doesn't insure that the string is the 4th delimited element.
As I said, DFSORT does not process delimited fields. My solution is based on looking for each target string anywhere in the record since the data shown only has one instance of a target string per record. If the data shown had multiple instances of a target string, I would not have offered this solution. _________________ 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
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
Posted: Sun Jul 31, 2005 5:06 pm Post subject:
Hi Frank, Not meant to put down DFSORT at all (though I don't think it was taken that way -- just being sure). I'm just a little miffed that so many computer professionals here and in my everyday encounters, don't want to program even the smallest programs to solve even the smallest problems. What is wonderful about the sort products is that the allow you to avoid the programming and the related environmental stuff (finding a place for an exec, locating procs for a compile, etc), but I tend to think in programming terms. In fact, I was working in mainframes for 2 decades before I even knew what the sort programs were for. I learned that from you, in fact.. Thanks!
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sun Jul 31, 2005 6:32 pm Post subject:
Quote:
Not meant to put down DFSORT at all (though I don't think it was taken that way -- just being sure).
No, I certainly didn't take it that way.
Personally, my language of choice is Assembler, but I've been using it for over 30 years so I'm very comfortable with it. I guess my view is a little at odds with yours, since as a developer I use Assembler to teach DFSORT/ICETOOL new tricks so other people can use it instead of programming themselves. But I certainly understand the usefulness of other languages and tools and sympathize with your reasons for being miffed. _________________ 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
Thank you very much for the solution provided. I will get the target string in only one place in each record. So your solution helped me a lot. Thanks again.
sg,
Could you please send the RExx material link. I want to learn basics.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon May 01, 2006 3:06 pm Post subject:
Here's an easier way to do this with the new PARSE function of z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006). For complete details on all of the new functions available with these PTFs, see:
_________________ 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
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