View previous topic :: View next topic
|
Author |
Message |
Sowmya Ramachandra
New User
Joined: 11 May 2007 Posts: 20 Location: Canada
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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.
Regards, |
|
Back to top |
|
|
Sowmya Ramachandra
New User
Joined: 11 May 2007 Posts: 20 Location: Canada
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 -
ibmmainframes.com/viewtopic.php?p=143786&highlight=#143786
Regards, |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|