Using a REDEFINES Clause

You can use REDEFINES to create client operations that generate Java-based beans. Information for processing REDEFINE fields at runtime is provided to the client developer through the Javadocs of the bean.

When the host program behind a client operation implements variable and type-exclusive data (both input and output), use the REDEFINES feature to properly supply data of a particular format into the REDEFINED data area of the client operation.

You can also use REDEFINES when you are processing the outputs of a host transaction to correctly process completely different sets of instance information. This provides a mechanism to reliably process the results of a transaction where the data is dynamic.

Example:

In the following example, which illustrates the typical mutually exclusive REDEFINES option, the data types are not compatible; the response bytes differ in type between text and numeric interpretations. To access this data, you need an indicator field to tell you which of these is appropriate for each particular execution of the operation.

        *  these statements define an area of memory that can contain any one of
        *      three distinct sets of account data at any given point in time
		
	 15 Account-Type-Indicator          	PIC X(1).       
                  88   Type-Savings        VALUE 'S'.               
                  88   Type-Checking       VALUE 'C'.              
                  88   Type-Investment     VALUE 'I'. 
				   
         15  Savings.
                20  Current-Balance               PIC 9(12)V99.    
                20  Minimum-Balance               PIC 9(5)V99.
                20  Interest-Rate                 PIC 9(3)V9(5).
                    . etc .
         15  Checking   REDEFINES Savings.
                20 Date-Established               PIC 9(6) Date Format yyxxxx.
                20 Available-Balance              PIC 9(12)V99. 
                    . etc .
         15  Investment  REDEFINES Savings.
                20  Fund-Name                     PIC X(10) .
                20  Current-Value                 PIC 9(12)V9(4).
                    . etc .

There are additional properties to set after you create the host transaction. In this example they are:

A REDEFINES Variation

REDEFINES can also provide alternative ways to access or set the content of a data area that contains data of the same type and format. You might want to return a large portion of contiguous data, perhaps for further processing, or grab a single piece of information from the middle of the data. REDEFINES lets you parse the data, in different ways, depending on what is meaningful to the application that is processing the results from a transaction.

Example:

In this example the REDEFINES is providing a more detailed or granular view of the same data.

        *
        *  the first field provides a macro view of a 16 byte account code.
        *  the group and fields under it show a parsed view of the encoded fields 
        *         within those same 16 bytes,

         15  Account-Code                              PIC X(16). 
         15  Account-Parsed  REDEFINES Account-Code.
              20  Account-Branch                       PIC X(7). 
              20 Customer-Identifier                   PIC X(9).

Set the Exclusive OR property to "False" for this REDEFINES so the client developer can access any of the alternate formats of the REDEFINES area for a given client operation.

 

Related Topics
Bullet Java Sample Application
Bullet About COBOL Copybooks
Bullet About Properties
Bullet Using Elementary Item Input and Output Properties