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
 

 

Checking for High-Values in an array

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

New User


Joined: 05 Nov 2014
Posts: 78
Location: India

PostPosted: Wed Aug 05, 2015 4:09 pm    Post subject: Checking for High-Values in an array
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

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Wed Aug 05, 2015 5:22 pm    Post subject:
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: 78
Location: India

PostPosted: Wed Aug 05, 2015 5:41 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Wed Aug 05, 2015 5:46 pm    Post subject: Reply to: Checking for High-Values in an array
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: 7913
Location: Bellevue, IA

PostPosted: Wed Aug 05, 2015 5:54 pm    Post subject:
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: 78
Location: India

PostPosted: Wed Aug 05, 2015 5:55 pm    Post subject:
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: 78
Location: India

PostPosted: Wed Aug 05, 2015 6:23 pm    Post subject:
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: 78
Location: India

PostPosted: Wed Aug 05, 2015 6:32 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Wed Aug 05, 2015 6:38 pm    Post subject: Reply to: Checking for High-Values in an array
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: 183
Location: Toronto, ON, Canada

PostPosted: Fri Aug 14, 2015 7:43 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Fri Aug 14, 2015 8:21 pm    Post subject: Reply to: Checking for High-Values in an array
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    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 High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Syncsort - NULL in Integer field chec... nartcr SYNCSORT 4 Thu Oct 06, 2016 6:47 am


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