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

Find the MAX value of an element in an array


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

New User


Joined: 21 Dec 2005
Posts: 20
Location: US

PostPosted: Wed Jul 12, 2006 2:55 am
Reply with quote

I have an array loaded and in a particular field which is defined as
pic 9(7), I want to find the MAX value in it and on which displacement that is located.

I know it can be find out by putting in a loop but I want to use some in built function or some smart technique.
>>>>
I know ORD-MAX function can be used for this but its giving me kind of weird errors when I am using it as suggested on one of the sites:

01 OrdPos PIC 99.
01 IntArray VALUE "1223037865".
02 Ielement OCCURS 5 TIMES PIC 99.


MOVE FUNCTION ORD-MAX(Ielement(ALL)) TO OrdPos
DISPLAY "Number " Ielement(OrdPos) " is the highest in array".
<<<<

Thanks,
Bharat
Back to top
View user's profile Send private message
ksivalakshmi

New User


Joined: 15 Nov 2005
Posts: 2
Location: Hyderabad

PostPosted: Wed Jul 12, 2006 12:26 pm
Reply with quote

Hi Bharat,

Compute should be used instead of Move.

COMPUTE OrdPos = FUNCTION ORD-MAX(Ielement(ALL))
Back to top
View user's profile Send private message
bharat_juneja

New User


Joined: 21 Dec 2005
Posts: 20
Location: US

PostPosted: Wed Jul 12, 2006 9:05 pm
Reply with quote

Thanks, that works.
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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts Find the occurrence of Key Field (Par... DFSORT/ICETOOL 6
No new posts Find a record count/numeric is multip... COBOL Programming 1
Search our Forums:

Back to Top