Presentation is loading. Please wait.

Presentation is loading. Please wait.

OO-Cobol. Moving between MVS and UNIX From MVS, use a TSO command to start a UNIX shell: TSO OMVS Or TSO ISHELL From UNIX, use the exit command to return.

Similar presentations


Presentation on theme: "OO-Cobol. Moving between MVS and UNIX From MVS, use a TSO command to start a UNIX shell: TSO OMVS Or TSO ISHELL From UNIX, use the exit command to return."— Presentation transcript:

1 OO-Cobol

2 Moving between MVS and UNIX From MVS, use a TSO command to start a UNIX shell: TSO OMVS Or TSO ISHELL From UNIX, use the exit command to return to MVS: exit

3 Logging Directly into z/OS UNIX You can telnet directly to z/OS UNIX from a command prompt: c:\> telnet 192.86.33.118 You cannot switch to TSO. You can use the TSO SHELL command to run a TSO command from your shell session You can use the UNIX vi editor or UNIX-style command- line editing You cannot use OEDIT to edit a file

4 Basic z/OS UNIX Commands Use the change directory (cd) command to move to a specific directory: CSUP004:/u: cd /u/csu/csup004 Use the list command (ls) to list subdirectories and files in the current directory: CSUP004:/u: ls

5 Basic z/OS UNIX Commands Use the remove (rm) command to remove a file or subdirectory: CSUP004:/u: rm myprog.java Use a shell command (oedit) to edit or create a file: CSUP004:/u: oedit myprog.java

6 Defining a Cobol Class IDENTIFICATION DIVISION. … ENVIRONMENT DIVISION. … FACTORY. (optional) … OBJECT. (optional) … END CLASS

7 IDENTIFICATION DIVISION Identification Division. Class-id. Account inherits Base. Names the class you are defining Names the immediate superclass (Java or Cobol) Base is defined in the Repository All classes must be derived directly or indirectly from java.lang.Object

8 Repository Environment Division. Configuration Section. Repository. Class Base is “java.lang.Object” Class Account is “Account”. Connects the internal names to external class names Base is required, Account is optional Specify the external class name if the name contains non-Cobol characters, or any referenced class that is part of a Java package

9 Class Instance Data Define a Data Division and a Working-Storage section in the Object section to define instance data The Object section is immediately preceded by an Identification Division. Identification Division. Object. Data Division Working-Storage section. 01 AccountNumber pic 9(6). 01 AccountBalance pic s9(9) value zero. … End Object.

10 Initializing Instance Data Initialize instance data by using value clauses Complex instance data can be initialized by calling customized methods Cobol instance data is equivalent to Java private nonstatic member data.

11 cbl dll,thread,pgmname(longmixed) Identification Division. Class-id. Account inherits Base. Environment Division. Configuration section. Repository. Class Base is "java.lang.Object" Class Account is "Account". * Identification division. Object. Data division. Working-storage section. 01 AccountNumber pic 9(6). 01 AccountBalance pic S9(9) value zero. * Procedure Division. ** (Instance method definitions here) * End Object. * End class Account.

12 Defining Instance Methods Define instance methods in the Procedure Division of the Object paragraph Each instance method has four divisions: 1) Identification – names the method 2) Environment – names the files the method uses 3) Data – defines files and creates local variables 4) Procedure – defines the executable statements that provide the service

13 Method – Identification Division Identification Division. Method-id. “credit”.

14 Local Storage Section A separate copy of Local-Storage is allocated for each invocation of the method, and is freed on return If a value clause is coded, the item is initialized to that value on each invocation of the method

15 Working Storage Section A single copy of Working-Storage is allocated. Data persists in its last-used state until the run unit ends The same copy of data is used whenever the method is invoked, regardless of the invoking object or thread A value clause is used to intialize a data item on the first invocation of the method

16 Linkage Section This works like any linkage section to provide addressability to data outside the method

17 Procedure Division for Methods Code the executable statements for a method in the Procedure Division Compile with the THREAD option You can code EXIT METHOD or GOBACK If you specify RETURNING upon invocation of the method, the EXIT METHOD or GOBACK returns the value of the data item to the invoking client There is an implicit EXIT METHOD at the end of each Procedure Division for each method Coding STOP RUN kills the entire run unit Code End Method for each Method body

18 Defining a Method Procedure Division. * Identification Division. Method-id. "getBalance". Data division. Linkage section. 01 outBalance pic S9(9) binary. * Procedure Division returning outBalance. Move AccountBalance to outBalance. End method "getBalance". ** (Other instance methods not shown) End Object. * End class Account.

19 Client Programs In a Cobol or Java client, you can: 1)Create object instances of Java and Cobol classes. 2)Invoke instance methods on Java and Cobol objects 3)Invoke Cobol factory methods and Java static methods

20 Client Programs Each client has four divisions: 1)Identification - a) Declare program RECURSIVE in the Program-Id paragraph. b) Compile with the THREAD option 2)Environment – define a repository 3)Data – define local client data 4)Procedure – create classes, manipulate objects

21 Client Data Division Data Division. Local-storage section. 01 anAccount usage object reference Account. 01 aCheckingAccount usage object referenceCheckingAccount. 01 aCheck usage object reference Check. 01 payee usage object reference Account. Object reference variables are like reference variables in Java If the class name is omitted after “object reference”, the reference can point to any object and have limited interoperability with Java You must define class-names that are used in the object reference phrase. The definitions belong in the Repository.

22 Comparing Object References One way to compare object references is by coding conditional statements: If anAccount = Null … If anAccount = Nulls … You can also invoke the JNI IsSameObject service: Set address of JNIEnv to JNIEnvPtr Set address of JNINativeInterface to JNIEnv Call IsSameObject Using by value JNIEnvPtr object1 object2 returning

23 Comparing Object References You can also invoke the JNI IsSameObject service: 01 is-same Pic X. 88 is-same-false value x’00’. 88 is-same-true value x’01’ through x’FF’. Linkage Section. Copy JNI. Procedure Division. Set address of JNIEnv to JNIEnvPtr Set address of JNINativeInterface to JNIEnv Call IsSameObject Using by value JNIEnvPtr object1 object2 returning is-same If is-same-true …

24 Comparing Object References Within a method, calling IsSameObject with SELF compares an object reference to see if it refers to the same object as the one on which the method was invoked

25 Setting References An object reference can be set to null: Set anAccount to Null. An object reference can be set to another reference: Set anAccount to otherAccount. An object reference can point to the containing object: Set anAccount to SELF.

26 Invoking Methods Use Invoke to execute a method: Invoke Account "createAccount" using by value 123456 returning anAccount Invoke anAccount "credit" using by value 500. The createAccount method must be a Cobol factory method if Account is a Cobol program Variable anAccount must be defined: 01anAccount usage object Reference Account.

27 Defining a Factory Factory methods and data are associated with the class (similar to Java static members) Identification Division. Factory. Data Division. Working-storage section. … Procedure Division. … End Factory

28 Compiling, Linking Cobol Classes To compile a Cobol class: cob2 -c -qdll,thread Accounta.cbl To compile the Java version: javac Accounta.java To link in the sidefiles and build a DLL: cob2 -bdll -o libAccounta.so Accounta.o /u/Java5_31/J5.0/bin/j9vm/libjvm.x /usr/lpp/cobol/lib/igzcjava.x

29 Java Client To Compile: javac Actrunr.java To execute: java Actrunr


Download ppt "OO-Cobol. Moving between MVS and UNIX From MVS, use a TSO command to start a UNIX shell: TSO OMVS Or TSO ISHELL From UNIX, use the exit command to return."

Similar presentations


Ads by Google