GLOBAL


GLOBAL uses the global area provided by Data Solutions for calculations on multiple fields and/or multiple records. You can use this exit to save (STORE) the data from one or more fields into the global area. You can then associate the GLOBAL exit with a different data field to retrieve (FETCH) the saved data into that field.

The first time this exit receives control from Data Solutions, it initializes all the global areas. The numeric fields are set to zero and the character field to spaces. The following table describes the parameter positions for the GLOBAL field exit. When entering the GLOBAL parameters, the following applies: Function codes must be left-justified, blank-filled, and uppercase. Alpha values must be uppercase. Multi-column values must be left-justified.

GLOBAL Parameters

Function Code

Position

Value Description

STORE

1-5

STORE function code: Save data from the record in a global area.


6

Specify a valid area designator for the destination field:

C Global character area (see description for 7-9). The total maximum length is 166 bytes.

1 - 9 Global numeric area. Choose from nine separate global areas.


7-9

Specify the global character area starting position. This field is only valid when position 6=’C’.

blank The default starting position is one.

1-166 Specific starting position. The maximum length is 166 bytes. The field is not allowed to extend beyond position 166.

FETCH

1-5

FETCH function code: Move data from a global area into the record.


6

Specify a valid area designator for the source field:

C Global character area (see description for 7-9). The total maximum length is 166 bytes.

1 - 9 Global numeric area. Choose from nine separate global areas.


7

U Store value in record as unsigned. The default is signed.


7-9

Specify the global character area starting position. This field is only valid when position 6=’C’.

blank The default starting position is one.

1-166 Specific starting position. The maximum length is 166 bytes. If the record field length is longer than the implied global length (167 - starting position), the remaining record positions are unchanged and padding does not take place.

RESET

1-5

RESET function code: Clear/reset the specified global area(s).


6-15

You may specify up to 10 areas:

C Set global character area to spaces (166 bytes).

1 - 9 Set specified global numeric area to zeros. Choose from nine separate global areas.

ACCUM

1-5

ACCUM function code: Accumulate a field into a global area.


6

Specify a valid area designator for the destination field:

1 - 9 Global numeric area. Choose from nine separate global areas.

INIT

1-5

INIT function code: Set the designated area to the specified number.


6

Specify a valid area designator for the area to initialize:

R Initialize the field in the data record.

1 - 9 Initialize the specified global numeric area. Choose from nine separate global areas.


7-25

Specify a number value to move to the specified area. The number must be an integer, from 1-18 digits, and without commas or a decimal point. Signed numbers are allowed. The sign may be a separate trailing or leading position or the last digit may contain an embedded sign.

ADD

1-5

ADD function code: Add the specified number to the designated area.

SUB

1-5

SUB function code: Subtract specified number from designated area.


6

Specify the results field:

R Update the field in the record. The results in the record are based on the original sign in the record (unsigned remains unsigned).

1 - 9 Update a global numeric area. Choose from 9 separate global areas.


7-25

Specified number. Value added to or subtracted from the specified area. Number must be an integer, from 1-18 digits, and without commas or a decimal point.

Signed numbers are allowed. The sign may be a separate trailing or leading position or the last digit may contain an embedded sign.

All designated areas are treated as integers. Decimal places implied by any associated PICTURE are ignored.

MULT

1-5

MULT function code: Multiply designated area by specified number.

DIV

1-5

DIV function code: Divide designated area by specified number.


6

Specify the results field:

R Update the field in the record. The results in the record are based on the original sign in the record (unsigned remains unsigned).

1 - 9 Update a global numeric area. Choose from 9 separate global areas.


7-26

Specified number. Multiply or divide the specified area by this value. Number may contain a decimal point but no commas are allowed. The integer portion may be from 0 -12 digits. The decimal fraction may be from 0 - 6 digits.

Signed numbers are allowed. The sign may be a separate trailing or leading position or the last digit may contain an embedded sign.

The results are rounded to the nearest integer. All designated areas are treated as integers. Decimal places implied by any associated PICTURE are ignored.

CALC

1-5

CALC function code: Perform the specified calculation using specified areas.


6

Specify the results field:

Update the field in the record. The results in the record are always signed.

1 - 9 Update a global numeric area. Choose from 9 separate global areas.


7-25

Specify the calculation formula. Specify the designated area(s) and operator(s) in the pattern AOAOAOAO...A.

A Designated area. (See position 6 values 'R' OR '1' - '9') You may specify up to 10 designated areas.

O Operator. Valid operators are:

+ ADD

- SUBTRACT

          • MULTIPLY

DIVIDE

You may specify up to 9 operators and 10 areas.

Calculations are performed left to right in the order specified. All numbers are treated as integers. Decimal places implied by any associated PICTURE are ignored.

Record Output Field Format

  • Character fields may be 1 - 166 bytes.
  • Binary (COMP) fields may be 2, 4, or 8 bytes long.
  • Numeric (EXTERNAL,DISPLAY) fields can be 1 - 18 digits, must be numeric, and may include an embedded trailing sign.
  • Packed (COMP-3) fields can be 1 - 18 digits (1 - 10 bytes) and may have an embedded trailing sign. The value must be numeric.

Computing a Sum in the Same Record

Example 1
LAYOUT NAME   PARAMETER      DESCRIPTION
-----------   ------------   -------------------------------
FIELD-A       STORE1         SAVE IN GLOBAL AREA 1
FIELD-B       STORE2         SAVE IN GLOBAL AREA 2
FIELD-C       STORE3         SAVE IN GLOBAL AREA 3
TOTAL         CALC R1+2+3    PUT SUM OF AREAS 1+2+3 IN RECORD

Summarizing Multiple Records

Example 2
CRITERIA  SELECT  LAYOUT
  SET       KEY    NAME      PARAMETER    DESCRIPTION
  ---       ---   --------   -----------  ------------------
   1         A    DTL-AMT    ACCUM1       ACCUM TOTAL: AREA 1
   2         B    DTL-AMT    ACCUM2       ACCUM TOTAL: AREA 2
   3         C    DTL-AMT    ACCUM3       ACCUM TOTAL: AREA 3

There could be multiple A, B, and C records before record T.

   4         T    TOTAL-A    FETCH1       STORE AREA 1 IN REC
   4         T    TOTAL-B    FETCH2       STORE AREA 2 IN REC
   4         T    TOTAL-C    FETCH3       STORE AREA 3 IN REC
   4         T    GRAND-TOT  CALC R1+2+3  STORE SUM OF AREAS 1+2+3 IN RECORD
   5         T    GRAND-TOT  RESET123     RESET AREAS 1 - 3

Reducing decimal places

All record fields have two implied decimal places.

Example 3
CRIT    LAYOUT
SET      NAME       PARAMETER      DESCRIPTION
----   --------     ------------   -------------------------------
 1     FIELD-A      STORE1         SAVE IN GLOBAL AREA 1
 1     FIELD-B      STORE2         SAVE IN GLOBAL AREA 2
 1     FIELD-C      INIT 3100      SET AREA 3 = 100
 2     FIELD-C      CALC R1*2/3    CALC: 1 * 2 (4 DECIMAL PLACES)
                                           / 3 (DIVIDE BY 100 TO
                                                DROP 2 DEC. PLACES)
                                         R = SAVE IN RECORD

Increasing Decimal Places (Percentage)

Field 1 and 2 are integers. Field 3 is a percentage (2 decimal places).

Example 4
CRIT   LAYOUT
SET     NAME        PARAMETER     DESCRIPTION
----   --------      -----------   -------------------------------
 1     FIELD-A      STORE1        SAVE IN GLOBAL AREA 1
 1     FIELD-B      STORE2        SAVE IN GLOBAL AREA 2
 1     FIELD-C      INIT 3100     SET AREA 3 = 100
 2     FIELD-C      CALC R1*3/2   CALC: 1 * 3 (MULTIPLY BY 100 TO
                                              GET 2 DEC. PLACES)
                                          / 2 (CALC PERCENTAGE)
                                        R = SAVE IN RECORD

Combining Character Fields

Example 5
CRIT  SEL  LAYOUT    FIELD
SET   KEY   NAME     LENGTH  PARAMETER    DESCRIPTION
----  ---  --------  ------  -----------  ------------------
 1     A   FIELD-A    20     STOREC       SAVE IN POS.  1-20
 2     B   FIELD-B    20     STOREC21     SAVE IN POS. 21-40
 3     C   FIELD-C    40     FETCHC       STORE POS. 1-40
                                                INTO RECORD

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*