Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Example: defining a client

The following example shows a small client program of the Account class.

The program does this:

(The Account class was shown in Example: defining a method.)

 cbl dll,thread,pgmname(longmixed)
 Identification division.
 Program-id. "TestAccounts" recursive.
 Environment division.
 Configuration section.
 Repository.
     Class Account is "Account".
 Data Division.
*  Working data is declared in LOCAL-STORAGE instead of 
*  WORKING-STORAGE so that each thread has its own copy: 
 Local-storage section.
 01  anAccount usage object reference Account.
*
 Procedure division.
 Test-Account-section.
     Display "Test Account class"
*  Create account 123456 with 0 balance:
     Invoke Account "createAccount"
       using by value 123456
       returning anAccount
*  Deposit 500 to the account: 
     Invoke anAccount "credit" using by value 500
     Invoke anAccount "print"
     Display space
*
     Stop Run.
 End program "TestAccounts".

Example: defining a factory (with methods)


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)