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
 

 

Find the MAX value of an element in an array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Find the MAX value of an element in an array
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    Post subject:
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    Post subject: Re: Find the MAX value of an element in an array
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    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 Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts Find out a active PGM jpsager JCL & VSAM 10 Fri Oct 07, 2016 4:32 pm
No new posts How to find a CICS resource used in C... Arunkumar Chandrasekaran CICS 8 Thu Sep 29, 2016 1:45 pm


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