IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Checking for High-Values in an array


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Wed Aug 05, 2015 4:09 pm
Reply with quote

Hi
I am having a problem checking for end of elements in an array. The Fixed file record is defined as

01 AB-RECORD-PRC redefines AI-record.
05 filler pic x(12).
05 record-num pic 9(08) comp.
05 AB-centre pic 9(2) comp-3.
05 filler pic x(4).
05 AB-date pic 9(7) comp-3.
05 filler pic x(3).
05 AB-volume pic 9(9) comp-3.
05 filler pic x(22).
05 AB-detail.
10 AB-detail-data occurs 600 times.
15 AB-detail-date pic 9(7) comp-3.
15 AB-detail-vol pic x(4).
15 filler pic x(22).
05 filler pic x(378).


The 600 items array is populated for only about 10 occurrences and then it contains all X'FFFFFFFFFFFFFFFFFFFFFFFFFFFFF'

I am doing a search on this array as follows:

Perform varying wscount from 1 by 1 until
(AB-detail-date(wscount) = ws-mst-date) or
(AB-detail-date(wscount) = High-Values)

end-perform.

This code is giving error:
AB-DETAIL-DATE (PACKED INTEGER)" WAS COMPARED WITH "HIGH-VALUES". Comparison was discarded.

Please suggest how can I resolve ?

Regards
Amit
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Wed Aug 05, 2015 5:22 pm
Reply with quote

OMG...

You cannot compare COMP-3 variables with character values.

Code:
Perform varying wscount from 1 by 1 until
(AB-detail-vol(wscount) = High-Values) or
(AB-detail-date(wscount) = ws-mst-date)
end-perform.


This of course assumes that AB-detail-vol is also initialized with High values.

And if the compiler decides that the order of the compares needs to be reversed for efficiency reasons, you will still end in shit creek without a paddle.
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Wed Aug 05, 2015 5:41 pm
Reply with quote

Hi

So is there any way I can find the end of elements on array ?

Regards
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Aug 05, 2015 5:46 pm
Reply with quote

How can you possibly not know how many entries you stuffed in the table? So you use that to limit your search.

And yes, you "protect" your comparison of the packed-decimal by testing the limit first. No COBOL compiler is ever going to swap the comparisons for optimisation.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Aug 05, 2015 5:54 pm
Reply with quote

A packed decimal variable with HIGH-VALUES will be non-numeric. So you now have at least 3 good ways to resolve your issue:

1. AB-DETAIL-DATE (WSCOUNT) NOT NUMERIC
2. AB-DETAIL-VOL (WSCOUNT) = HIGH-VALUES
3. Track the number of entries in the array and compare WSCOUNT to that value
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Wed Aug 05, 2015 5:55 pm
Reply with quote

Hi Bill

The code section I pasted above is File Definition of the input file. I am reading directly from the file. Each record in itself contains array of 30 characters. The array starts at position 57, first element 57-86 , second element 87-116 , third element 117-146 and so on. Record is 18437 bytes long. This 30 byte array is repeated 600 times.So actually at processing time I do not know how many array elements would be populated.

I hope I am not missing anything and am able to explain. Please let me know if I am not.
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Wed Aug 05, 2015 6:23 pm
Reply with quote

Thanks Robert, Not numeric works. It is giving a 0c7 at later point, but I can take care of that.
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Wed Aug 05, 2015 6:32 pm
Reply with quote

It was a code fall through. I fixed it.

Thanks again Robert, Bill and prino.

Best Regards
Amit
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Aug 05, 2015 6:38 pm
Reply with quote

"Traditionally", something in the record prior to the table would tell how many entries were actually active in the table.

If you don't have that, both Prino and Robert have suggested testing an alpha-numeric field for high-values.

There are other ways of arranging the same thing.

The problem with Robert's NUMERIC test is that there may be non-numeric (and non-HIGH-VALUES) data :-)

You also need to use the OCCURS limit, otherwise if all entries are full you may "fall of the end" of the table.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Fri Aug 14, 2015 7:43 pm
Reply with quote

I suggest to define the table
Code:
10 AB-detail-data occurs 600 times.
15 AB-detail-entry.
20 AB-detail-date pic 9(7) comp-3.
20 AB-detail-vol pic x(4).
20 filler pic x(22).

Then do your check check
Code:
Perform varying wscount from 1 by 1 until
AB-detail-entry (wscount) = high-values or
AB-detail-date(wscount) = ws-mst-date
  do something
end-perform.

Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Aug 14, 2015 8:21 pm
Reply with quote

That'll fall off the end when the table is full and a match is not found :-)

You could make the test an 88. Should.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top