Method-name-1 in the END METHOD header must be identical to the
method-name-1 declared in the preceding Method-ID paragraph.
Data declared in the Data Division of a method is accessible only
within that method.
Quotation marks around method-name-1 are optional.
注意: Quotation marks enable you to use reserved words as
method-names and to use non-COBOL characters.
A method definition must be contained in a Class Definition.
The format of the PROCEDURE DIVISION header for a method is the
same as the format 1 PROCEDURE DIVISION header for a program. The GIVING or
RETURNING data-name clause shown in the format 2 header may also be specified.
(See the section
The PROCEDURE DIVISION
Header for details.)
General Rules
Method-name-1 names the method declared by this method
definition.
Data declared in the Local-Storage Section of a method is
allocated separate storage for each invocation of the method and deallocated
upon return from the method. This data is in an undefined state each time the
method is invoked.
注意: If you declare your data in the Local-Storage Section,
separate invocations of the method do not interfere with each other's data.
Data and files declared in a method in sections other than the
Local-Storage Section or the Linkage Section are shared among all invocations
of the method and are in their last used state when the method is invoked.
Method-name-1 may be used in a method invocation with an object
identifier that references an object containing this method.
If a RETURNING or GIVING phrase is specified in the PROCEDURE
DIVISION header of a method, the contents of the data item specified in that
phrase when the method terminates become the result of the method. This result
is placed in the identifier specified in the RETURNING or GIVING phrase of the
INVOKE statement.