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 

Problem with INSPECT

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


Joined: 15 Mar 2005
Posts: 23
Topics: 12

PostPosted: Thu Apr 26, 2007 12:31 pm    Post subject: Problem with INSPECT Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Apr 26, 2007 12:59 pm    Post subject: Reply with quote

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


Joined: 15 Mar 2005
Posts: 23
Topics: 12

PostPosted: Thu Apr 26, 2007 1:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Apr 26, 2007 1:21 pm    Post subject: Reply with quote

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


Joined: 15 Mar 2005
Posts: 23
Topics: 12

PostPosted: Fri Apr 27, 2007 5:40 am    Post subject: Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Apr 27, 2007 6:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Preety
Beginner


Joined: 15 Mar 2005
Posts: 23
Topics: 12

PostPosted: Fri Apr 27, 2007 7:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Fri Apr 27, 2007 7:31 am    Post subject: Reply with quote

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
View user's profile Send private message
jajularamesh
Beginner


Joined: 14 Apr 2006
Posts: 87
Topics: 33

PostPosted: Mon May 14, 2007 2:06 am    Post subject: Reply with quote

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
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Mon May 14, 2007 2:53 am    Post subject: Reply with quote

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
View user's profile Send private message
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