| View previous topic :: View next topic |
| Author |
Message |
Preety Beginner

Joined: 15 Mar 2005 Posts: 23 Topics: 12
|
Posted: Thu Apr 26, 2007 12:31 pm Post subject: Problem with INSPECT |
|
|
Hi,
I am trying to check for some particular values in the Input file like
'Ltd.'
'Limited'
'Partner'
'Partners'
'& Co.'
and want to write the record in the output file when any of these is found.
I tried the following INSPECT statement:
INSPECT WS-FIRST-NAME TALLYING WS-TALLY FOR ALL 'Ltd.'.
INSPECT WS-FIRST-NAME TALLYING WS-TALLY FOR ALL 'Limited'.
INSPECT WS-FIRST-NAME TALLYING WS-TALLY FOR ALL 'Partner'.
INSPECT WS-FIRST-NAME TALLYING WS-TALLY FOR ALL 'Partners'.
INSPECT WS-FIRST-NAME TALLYING WS-TALLY FOR ALL '& Co.'.
The output file is giving results even if none of the values are matched.
I am confused if WS-TALLY get replaced every time it goes to next INSPECT or not.
It is not possible to check for WS-TALLY and write the file after every INSPECT as the number of conditions are more.
Kindly suggest.
Thanks,
PM |
|
| Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12401 Topics: 75 Location: San Jose
|
Posted: Thu Apr 26, 2007 12:59 pm Post subject: |
|
|
Preety,
You might be carrying the WS-Tally from the prior records. So add this stmt befroe the first INSPECT statement
| Code: |
MOVE ZERO TO WS-TALLY
|
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
| Back to top |
|
 |
Preety Beginner

Joined: 15 Mar 2005 Posts: 23 Topics: 12
|
Posted: Thu Apr 26, 2007 1:07 pm Post subject: |
|
|
Hi Kolusu,
I have already initialised WS-TALLY by zero in my code.
Is there any other way besides INSPECT to perform this.
Thanks.
PM |
|
| Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12401 Topics: 75 Location: San Jose
|
Posted: Thu Apr 26, 2007 1:21 pm Post subject: |
|
|
| Quote: |
Is there any other way besides INSPECT to perform this.
|
Preety,
INSPECT should work. Show us an example data of your ws-first-name and then show me the record which you think should not be in the output.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
| Back to top |
|
 |
Preety Beginner

Joined: 15 Mar 2005 Posts: 23 Topics: 12
|
Posted: Fri Apr 27, 2007 5:40 am Post subject: |
|
|
Hi,
Here are the INSPECT statements:
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL '& SON'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL '& Sons'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Trading as'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Ltd.'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Limited'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Partner'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Partners'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL '& Co.'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Company'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Club'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Society'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Association'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Charity'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Service'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Services'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Unit'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Inc'.
INSPECT WS-SURNAME
TALLYING WS-TAL FOR ALL 'Incorporated'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Plc'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'PO Box'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Bros'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Brothers'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Newsagent'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Florist'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Garage'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Store'.
INSPECT WS-SURNAME TALLYING WS-TAL FOR ALL 'Stores'.
IF WS-TAL > 0
GO TO BREADIT20-WRITE
ELSE
GO TO BREADIT2-EXIT.
BREADIT20-WRITE.
DISPLAY 'WS-TAL IS ' WS-TAL UPON PRINTER.
DISPLAY 'SURNAME IS ' WS-SURNAME UPON PRINTER.
and I am getting the output as:
WS-TAL IS 01
SURNAME IS LANGSTON
WS-TAL IS 01
SURNAME IS WALKER
Kindly suggest.
Thanks.
PM |
|
| Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Fri Apr 27, 2007 6:35 am Post subject: |
|
|
as kolusu asked, when do you initialize WS-TAL? You have to initialize it to zero before you interrogate each record.
Is 'langston' the contents of SURNAME for the first record? Are there only two input records?
also, why are you using GOTO's?
to be honest, I don't trust your code, simply because of your usage of GOTO's. _________________ Dick Brenholtz
American living in Varel, Germany |
|
| Back to top |
|
 |
Preety Beginner

Joined: 15 Mar 2005 Posts: 23 Topics: 12
|
Posted: Fri Apr 27, 2007 7:09 am Post subject: |
|
|
I have initialised WS-TAL to zero before teh first INSPECT only.
There are lot of Input records around 5000 and I have picked 'langston' randonly from one fo the, None of the output matches correctly.
Is it required to initialize WS-TAL and write to output file after every INSPECT?
I am concentrating on logic and will probably replace GOTO after that.
Thanks,
PM |
|
| Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Fri Apr 27, 2007 7:31 am Post subject: |
|
|
| Preety wrote: | | Is it required to initialize WS-TAL and write to output file after every INSPECT? |
No - just on every change of WS-SURNAME _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
| Back to top |
|
 |
jajularamesh Beginner
Joined: 14 Apr 2006 Posts: 87 Topics: 33
|
Posted: Mon May 14, 2007 2:06 am Post subject: |
|
|
Hi,
WS-TAL needs to be intialialized after every inspect statement.
Other wise use a different variable in each inspect to get the count.
Regards,
Venkata Apparao Jajula |
|
| Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Mon May 14, 2007 2:53 am Post subject: |
|
|
no - WS-TAL does not need to be init after every INSPECT only before each new value in WS-SURNAME. He only needs to know if any one of the conditions is met and write the record once. And, probably, only one of those values could be met on any one record. In fact it could be done using one big IF or EVALUATE. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
| Back to top |
|
 |
|
|
|