Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of the built in Min Function

Status
Not open for further replies.

MikeMcKeown

Programmer
Apr 1, 2003
69
GB
Hello,

I'm trying to use the built in Min function but the compiler is giving me errors.

The code I am trying is

BB-DO-CALCULATION SECTION.
MOVE FUNCTION MIN (CEA08I-REPAYMENT-VEHICLE,
CEA08I-MAX-OFFER-AMOUNT)
TO CEA08O-ACTUAL-MAX-OFFER.

The error message I'm getting from the compiler (if it helps I'm comiling under Xpeditor)

"FUNCTION" was specified as an informational word in the current reserved word table. The reserved word table used may be different from the IBM-supplied default. Refer to VS COBOL II Application Programming Language Reference for information on reserved words.

"FUNCTION" was not defined as a data-name. The statement was discarded.

"MIN" was invalid. Skipped to the next verb, period or procedure-name
definition.

Thanks in Advance,

Mike McKeown
 
Do you have the built-in functions available in your compiler? I don't think they were available in COBOL II. I believe that they were made available in the next version which was COBOL/370.

Your error message sounds like it does not understand the word FUNCTION, which would be the case if you are using a COBOL II compiler.
 
Thanks,

I think thats the most likely diagnosis. I'm compiling outwith our usual work environment which is Endevor. The compiler I'm using at the moment is a Cobol II compiler so hopefully it will work using Endevor but I'm not sure which version of Cobol is supported on our Endevor.

Maybe a question for our Endevor expert unless you have any clues about Endevor?

Obviously in this case instead of the above code I can check which value is greater using IF statements but I was hoping to use the more powerful functions in later programs.

Thanks for your reply,

Mike McKeown

 
Am I correct that they (built-in functions) are not used with Cobol/400?

 
The min function (along with several others) was made available by IBM for ILE COBOL V5R2 on the iSeries. I don't believe that IBM has enhanced COBOL/400 to include the intrinsic functions, but . . .

Glenn
 
Ok thanks, I'll try and see if the built in functions work in my native work envinronment which is Endevor.

If this doesn't work are there suggested ways to do things like calculating the minimum? A decent way that I came up with was to put the values in an array then go through them in a loop, keeping the smallest value. But if the values start off as seperate variables then this will involve moving the values to an array before potentially quite a few lines of code.

Are there any other suggested methods that people have used in the past?
 
Typically I've had to find minimums in a file. That's very easy. If the elements can be put in an array, that's easy. If they're distinct data elements, then that's easy but very bulky:
Code:
MOVE ITEM1 TO WS-MINIMUM
IF ITEM2 < WS-MINIMUM
    MOVE ITEM2 TO WS-MINIMUM
END-IF
IF ITEM3 < WS-MINIMUM
    MOVE ITEM3 TO WS-MINIMUM
END-IF
[\CODE]
Regards.

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top