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 

how to search a string in cobol

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


Joined: 03 Mar 2003
Posts: 8
Topics: 6

PostPosted: Wed Apr 02, 2003 6:35 am    Post subject: how to search a string in cobol Reply with quote

hi,

Is there any command or facility to search a string in cobol. i have a flat file from which i have to search a string 'abcd', how can i do it.


pls help
rsk
Back to top
View user's profile Send private message
sudhtech
Beginner


Joined: 27 Mar 2003
Posts: 6
Topics: 2
Location: Chennai

PostPosted: Wed Apr 02, 2003 7:19 am    Post subject: Reply with quote

I have a suggestion regarding search of strings. This solution will work for those programs lying in NED. We can go to Endevor -->Option 8--> Option 3--->Build SCL--List element --> Provide TEXT STRING________________________ you want search.
(or) Try with the following SCL which already generated and working for me.
LIST ELEMENT 'Your cobol program'
VERSION 01 LEVEL 00
FROM ENVIRONMENT 'YOUR PDS'
TYPE 'COBOL' STAGE 2
OPTIONS SHOWING TEXT NOSEARCH
WHERE TEXT EQ
'OPEN_TO_MATCH_Q'
BUILD ACTION &&ACTION

This works for elements endevor and I am really not sure whether this one works for elements in PDS too. Try it out and see.
_________________
Sudheer Nelluri
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Wed Apr 02, 2003 8:06 am    Post subject: Reply with quote

rsk,

I am not aware of any string search command (in VS COBOL II) but following approach may let you find a string within a record
Code:

perform varying rec-i from 1 by 1
   until (rec-i > (length of file-rec - length of ws-str + 1))
         or
         (88-str-found) 
   if file-rec (rec-i: length of ws-str) = ws-str
      set 88-str-found to true
   end-if
end-perform         


diba
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Apr 02, 2003 8:10 am    Post subject: Reply with quote

rsk123in,

If your sole intention is to find out all the lines with 'abcd' then you can use SORT to only select the lines with 'abcd' in them.I assumed that your flat file LRECL is 80 and the following JCL will give only the lines with 'ABCD' in them any where in the line of 80 bytes.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR FLAT FILE,
///           DISP=SHR
//SORTOUT  DD DSN=FILE WITH ABCD,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
  SORT FIELDS=COPY
  INCLUDE COND=(1,80,SS,EQ,C'ABCD')
/*


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
taterhead
Beginner


Joined: 02 Dec 2002
Posts: 7
Topics: 0

PostPosted: Wed Apr 02, 2003 9:25 am    Post subject: Reply with quote

*cough cough* INSPECT *cough cough*
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Thu Apr 03, 2003 1:57 am    Post subject: Reply with quote

taterhead,

Can't hear you clearly. Could you explain how you can find a string using INSPECT?

Thanks,
Diba.
Back to top
View user's profile Send private message Send e-mail
Tophe
Beginner


Joined: 02 Dec 2002
Posts: 8
Topics: 0
Location: Tours, France

PostPosted: Thu Apr 03, 2003 2:21 am    Post subject: Reply with quote

What is the question ?
Does Rsk want to find a string in a flat file with a cobol program ?

If so, i think taterhead is right ... the option TALLYING will return in a counter the answer ...



Christophe
Back to top
View user's profile Send private message
Glenn
Beginner


Joined: 23 Mar 2003
Posts: 56
Topics: 3

PostPosted: Thu Apr 03, 2003 3:41 am    Post subject: Reply with quote

INSPECT with TALLYING is definitely worth a shot here...

Code:

MOVE 0 TO COUNT-1
INSPECT STRING-VALUE
  TALLYING COUNT-1 FOR ALL 'ABCD'


Where 'ABCD' is what we're looking for.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Thu Apr 03, 2003 6:06 am    Post subject: Reply with quote

Glenn,

I had the opinion that INSPECT is for looking single byte characters only.

Thanks for correcting,
Diba.
Back to top
View user's profile Send private message Send e-mail
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sat Apr 05, 2003 2:40 pm    Post subject: Reply with quote

Hi Rsk,

Your problem reminds me of the dog that chases automobiles. What will you do when you find it?

Your answer can possibly determine the approach used to find it.
Back to top
View user's profile Send private message
jaichenchlani
Beginner


Joined: 31 Mar 2003
Posts: 5
Topics: 2

PostPosted: Mon Apr 07, 2003 4:41 am    Post subject: Reply with quote

From the "ISPF Primary Option Menu" Go to Utilities (3) -> "Search data sets for strings of data" (14).
Key in your Search string and your PDS name, and, there you go!!
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming 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