MF 

Method (OO Native COBOL)

General Format:


Syntax for the method definition

Syntax Rules

  1. Method-name-1 in the END METHOD header must be identical to the method-name-1 declared in the preceding Method-ID paragraph.
  2. Data declared in the Data Division of a method is accessible only within that method.
  3. Quotation marks around method-name-1 are optional.
    Note: Quotation marks enable you to use reserved words as method-names and to use non-COBOL characters.
  4. A method definition must be contained in a Class Definition.
  5. 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

  1. Method-name-1 names the method declared by this method definition.
  2. 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.
    Note: If you declare your data in the Local-Storage Section, separate invocations of the method do not interfere with each other's data.
  3. 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.
  4. Method-name-1 may be used in a method invocation with an object identifier that references an object containing this method.
  5. 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.