Where You Can Specify an Object Field

You can use an object field in the following situations:

Free-Form Evaluation
You can use the EVAL operation to assign one Object item (field or prototyped procedure) to a field of type Object.
Free-Form Comparison
You can compare one object to another object. You can specify any comparison, but only the following comparisons are meaningful:
Free-Form Call Parameter
You can code an object as a parameter in a call operation if the parameter in the prototype is an object.
Notes:
  1. Objects are not valid as input or output fields.
  2. Assignment validity is not checked. For example, RPG would allow you to assign an object of class Number to an object variable defined with class String. If this was not correct, a Java error would occur when you tried to use the String variable.
Figure 96. Object Data Type Example
D Obj             S               O   CLASS(*JAVA
D                                          :'java.lang.Object')
D Str             S               O   CLASS(*JAVA
D                                          :'java.lang.String')
D Num             S               O   CLASS(*JAVA
D                                          :'java.math.BigDecimal')

 * Since all Java classes are subclasses of class 'java.lang.Object',
 * any object can be assigned to a variable of this class.
 * The following two assignments are valid.
C                   EVAL      Obj = Str
C                   EVAL      Obj = Num
 * However, it would probably not be valid to assign Str to Num.


[ Top of Page | Previous Page | Next Page | Contents | Index ]