MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Search String in VB file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Robo2005
Beginner


Joined: 13 Jul 2005
Posts: 11
Topics: 3

PostPosted: Fri Jul 29, 2005 4:29 pm    Post subject: Search String in VB file Reply with quote

Hi,

Please help me in follwing requirement.

I have one VB file.

I need the total counts of particular field in the record.

for ex: The input file is
Code:

12345678901,xxxxxx,111111,IND,BMT,CC,
23456478682,YYY,22222,GMT,BMT,ZZ,
23456478682,XY,2345,IND,BMT,ZZ,
34565678682,XXYYY,22234522,IND,BMT,ZZ,
34565634582,ZZXXYYY,22234522,SMS,BMT,ZZ,
24354478682,XXYYY,2224556662,GMT,BMT,ZZ,


THE O/P shld be the same copy of above records and also i want the counts like
TYPE - IND - 3
TYPE - GMT - 2
TYPE - SMS - 1

The o/p file shlb also be VB.

Thanks
Robo.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Jul 29, 2005 4:36 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Robo2005
Beginner


Joined: 13 Jul 2005
Posts: 11
Topics: 3

PostPosted: Fri Jul 29, 2005 4:45 pm    Post subject: Reply with quote

Hi Frank,

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'.

Thanks
Robo.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Jul 29, 2005 5:39 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Robo2005
Beginner


Joined: 13 Jul 2005
Posts: 11
Topics: 3

PostPosted: Fri Jul 29, 2005 6:00 pm    Post subject: Reply with quote

Thanks for your reply.
Can we do, if I am looking for particulary about the 'IND','GMT' and 'SMS'.


Thanks
Robo
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Sat Jul 30, 2005 12:31 am    Post subject: Reply with quote

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)'
And of course, adding error checking never hurts Wink
Back to top
View user's profile Send private message Visit poster's website
Robo2005
Beginner


Joined: 13 Jul 2005
Posts: 11
Topics: 3

PostPosted: Sat Jul 30, 2005 8:05 am    Post subject: Reply with quote

Thanks for your solution. But I can't use REXX in my project and also I don't know REXX.
It would be helpfull, if I could get a solution thru SORT.

Thanks
Robo.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sat Jul 30, 2005 10:45 am    Post subject: Reply with quote

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:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/

Code:

//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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Sat Jul 30, 2005 1:50 pm    Post subject: Reply with 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.

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.
Back to top
View user's profile Send private message Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun Jul 31, 2005 10:38 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Sun Jul 31, 2005 5:06 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun Jul 31, 2005 6:32 pm    Post subject: Reply with quote

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. Laughing 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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Robo2005
Beginner


Joined: 13 Jul 2005
Posts: 11
Topics: 3

PostPosted: Tue Aug 02, 2005 2:15 pm    Post subject: Reply with quote

Frank,

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.

Thanks
Robo.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon May 01, 2006 3:06 pm    Post subject: Reply with quote

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:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//COPY DD DSN=...   copy of input file (VB)
//COUNTS DD DSN=...  report (VB)
//SYSIN    DD    *
  INREC PARSE=(%=(ABSPOS=17,ENDBEFR=C','),
               %=(ENDBEFR=C','),
               %01=(FIXLEN=3,ENDBEFR=C',')),
        BUILD=(1,4,5:%01,8:5)
  SORT FIELDS=(5,3,CH,A)
  OUTFIL FNAMES=COPY,BUILD=(1,4,8)
  OUTFIL FNAMES=COUNTS,REMOVECC,NODETAIL,
         SECTIONS=(5,3,
           TRAILER3=(C'TYPE - ',5,3,C' - ',COUNT=(EDIT=(TT))))
/*

_________________
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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group