View previous topic :: View next topic |
Author |
Message |
rsk123in Beginner
Joined: 03 Mar 2003 Posts: 8 Topics: 6
|
Posted: Wed Apr 02, 2003 6:35 am Post subject: how to search a string in cobol |
|
|
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 |
|
|
sudhtech Beginner
Joined: 27 Mar 2003 Posts: 6 Topics: 2 Location: Chennai
|
Posted: Wed Apr 02, 2003 7:19 am Post subject: |
|
|
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 |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Wed Apr 02, 2003 8:06 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Apr 02, 2003 8:10 am Post subject: |
|
|
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 |
|
|
taterhead Beginner
Joined: 02 Dec 2002 Posts: 7 Topics: 0
|
Posted: Wed Apr 02, 2003 9:25 am Post subject: |
|
|
*cough cough* INSPECT *cough cough* |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Thu Apr 03, 2003 1:57 am Post subject: |
|
|
taterhead,
Can't hear you clearly. Could you explain how you can find a string using INSPECT?
Thanks,
Diba. |
|
Back to top |
|
|
Tophe Beginner
Joined: 02 Dec 2002 Posts: 8 Topics: 0 Location: Tours, France
|
Posted: Thu Apr 03, 2003 2:21 am Post subject: |
|
|
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 |
|
|
Glenn Beginner
Joined: 23 Mar 2003 Posts: 56 Topics: 3
|
Posted: Thu Apr 03, 2003 3:41 am Post subject: |
|
|
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 |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Thu Apr 03, 2003 6:06 am Post subject: |
|
|
Glenn,
I had the opinion that INSPECT is for looking single byte characters only.
Thanks for correcting,
Diba. |
|
Back to top |
|
|
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Sat Apr 05, 2003 2:40 pm Post subject: |
|
|
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 |
|
|
jaichenchlani Beginner
Joined: 31 Mar 2003 Posts: 5 Topics: 2
|
Posted: Mon Apr 07, 2003 4:41 am Post subject: |
|
|
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 |
|
|
|
|