Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Question on Inspect

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Sowmya Ramachandra

New User


Joined: 11 May 2007
Posts: 20
Location: Canada

PostPosted: Thu May 28, 2009 1:26 am    Post subject: Question on Inspect
Reply with quote

Hi,

I hav reqiurement wherein I need to check none of the feilds should have low values in it. Do we have any alternative other than using the below Inspect command. Because Inspect is taking long time.

INSPECT IN-REC TALLYING
CNTR FOR ALL LOW-VALUES.

IN-REC is 300 Charaters.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8054
Location: East Dubuque, Illinois, USA

PostPosted: Thu May 28, 2009 1:32 am    Post subject:
Reply with quote

1. How do you know the INSPECT is "taking long time"? Is this based on STROBE or similar product, or are you just guessing?
2. Reference modification is a possibility -- check the manuals link at the top of the page and look in the COBOL Language Reference.
3. Depending on how many records you have, doing a byte-by-byte check of 300 bytes of data may just take a long time. You may not have any choice but to accept how long it takes.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu May 28, 2009 2:23 am    Post subject: Reply to: Question on Inspect
Reply with quote

This flavor of an INSPECT may (probably does) cause a CALL to a COBOL run-time routine. IMHO, an in-line perform would be better, using (as Robert has suggested), reference modification comparison against each byte.

Be sure to define CNTR as a PIC S9(04) or PIC S9(08) COMP field.

When using reference-modification and an in-line perform, use CNTR to count the number of LOW-VALUE bytes found. Make sure you initialize it to ZERO first outside of the perform.

Compare TALLY to the LENGTH OF IN-REC (in the in-line perform varying), then you don't need to know the length at all.

TALLY is implicitly defined as PIC S9(05) COMP.

Regards,
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu May 28, 2009 4:29 am    Post subject: Reply to: Question on Inspect
Reply with quote

Example -

Code:

03  CNTR PIC S9(04) COMP.
03  IN-REC PIC  X(300).
03  IN-REC-MAP PIC  X(300).

MOVE ZERO TO CNTR.
MOVE 1 TO TALLY.
MOVE ZERO TO IN-REC-MAP (1:256).
MOVE IN-REC-MAP (1:) TO IN-REC-MAP (257:).

PERFORM UNTIL TALLY > LENGTH OF INREC
   IF  IN-REC (TALLY:1) = LOW-VALUE
       ADD 1 TO CNTR
       MOVE '1' TO IN-REC-MAP (TALLY:1)
   END-IF
   ADD 1 TO TALLY
END-PERFORM.

When you're done, CNTR will contain the number of LOW-VALUE bytes in IN-REC (zero or non-zero) and if a '1' is found in a given position in IN-REC-MAP, then this is the byte-location where LOW-VALUE was found.

Give it a try and see if it's more efficient than the INSPECT.

Regards,
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu May 28, 2009 5:56 am    Post subject:
Reply with quote

Hello,

Quote:
I hav reqiurement wherein I need to check none of the feilds should have low values in it.
What are you to do if a record has any low-values? Treat the record as an error record? Bypass that record? Etc?

Do the records contain any packed-decimal or binary fields? Packed-decimal and binary fields very often have one or more bytes of x'00'. . .

If the records do not contain comp-3/comp fields and the existence of one byte of x'00' triggers different action (i.e. error processing), no need to tally the entire record. When the first low-value is encountered, stop looking and save some cycles.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu May 28, 2009 6:28 am    Post subject: Reply to: Question on Inspect
Reply with quote

Dick,

Good point about COMP and COMP-3 data (yikes!) possibly being present in IN-REC. Missed that little tidbit by a mile as I was assuming that this data was all EBCDIC display. icon_redface.gif

Regards,
Back to top
View user's profile Send private message
Sowmya Ramachandra

New User


Joined: 11 May 2007
Posts: 20
Location: Canada

PostPosted: Thu May 28, 2009 9:04 pm    Post subject:
Reply with quote

Actually I need to display difference error messages based on the count of low-values. After that Low-values has to be cleaned up and replaced by spaces. In the existing pgm there is one more INSPOECT to replace.
I am planning to use the below command instead of 2 inspects. will that make difference ?
INSPECT IN-REC TALLYING TALLY FOR ALL LOW-VALUES REPLACING ALL LOW-VALUES BY SPACES

Meanwhile i ll try the PERFORM mentioned above also.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu May 28, 2009 11:24 pm    Post subject: Reply to: Question on Inspect
Reply with quote

Could there also be any other type of value found in IN-REC that you need to convert to SPACE?

In the PERFORM, you could change your IF check from "= LOW-VALUE" to "< SPACE" and set the target byte to SPACE. This means that any byte-value found in the range of X'00' through X'3F' will be changed to SPACE.

Click on the below link which may be helpful -

http://ibmmainframes.com/viewtopic.php?p=143786&highlight=#143786

Regards,
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri May 29, 2009 2:01 am    Post subject:
Reply with quote

Hello,

Quote:
Actually I need to display difference error messages based on the count of low-values.
What is the difference in error(s) between a record with 1, 5, or 7 low-values tallied?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
No new posts Fault Analyzer - listings question. egrove IBM Tools 4 Thu Aug 11, 2016 5:31 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us