RxD2/LINK special functions for REXX EXECs


Several special functions are provided with RxD2/LINK that are required or useful when accessing DB2.

In REXX, you invoke a function by issuing

V1 = FUNC(ARG1,ARG2)

where V1 is the variable into which the function FUNC places the result.

Special functions

Special function

Description

CONVSTCK(tod)

converts the 8-byte TOD clock into display format of YYYYDDD HHMMSSTH

Valid from 1/1/1988 onward. The 8-byte TOD format is such that bit 51 equals 1 microsecond (see the IBM publication, 370 Principles of Operations).

TSTMP = 'A42AE3F94CE5BB31'X
SAY 'TIMESTAMP=' CONVSTCK(TSTMP)

DEFAULT:none

RETURN:‘value’ if function is completed successfully

NOGO:‘reason’ if function fails for the reason given

CTOD(tod)

converts the 8-byte TOD clock time into display format of HHMMSSTH

The 8-byte TOD format is such that bit 51 equals 1 microsecond (see the IBM publication, 370 Principles of Operations ).

 

CPUT = '0000000160B79C00'X
SAY 'CPUT=' CTOD(CPUT)

DEFAULT: none

RETURN: ‘value’ if function is completed successfully

NOGO: ‘reason; if function fails for the reason given

F2C(f)

performs a floating point conversion on variable f and returns the floating point number in display format

/* TEST F2C */
A = '4498765432100000'X
SAY 'F2C=' F2C(A)

 

DEFAULT: none

RETURN: ‘value’ if function is completed successfully

NOGO: if function fails

GBLVAR (GETV,varname)(SETV,varname)(DROP,varname)(UPDV,varname)

creates and manages the global variable environment

The global variable environment is created at first use. Subsequent environment shares the same environment. The environment is destroyed at the EOT of the task that created the environment.

GETV: Gets the global variable varname and places its content in the local variable varname.

SAY 'TESTVAR=' TESTVAR
SAY 'GBLVAR('GETV','TESTVAR')=' GBLVAR('GETV','TESTAVR')
SAY 'TESTVAR=' TESTVAR

SETV: Gets the local variable varname and creates a global variable varname. If the global variable varname already exists, it is not replaced.

TESTVAR= 'TEST VARIABLE FOR TEST GBLVAR'
SAY 'GBLVAR('SETV','TESTVAR')=' GBLVAR('SETV','TESTVAR')

DROP: Drops the global variable varname.

UPDV: Gets the local variable varname and updates the global variable varname. If the global variable varname does not exist, the function is treated like 'SETV'.

DEFAULT: None

RETURN: OK if function is completed successfully

OK: ‘warn if function is completed with a warning

NOGO: ‘reason’ if function fails for the reason given

P2C(p)

performs an unpack on variable p and returns the packed decimal number in display format

/* TEST P2C */
A = '123456789C'X
SAY 'P2C=' P2C(A)

 

DEFAULT: none

RETURN: ‘value’ if function is completed successfully

NOGO: if function fails

UENV(hcename, pgm)

identifies to REXX Host Command Environment (HCE) called hcename, such that pgm receives control for ADDRESS hcename

The hcename currently is required to be DB2.

SK = UENV(DB2)
IF SK ^= 'OK' THEN DO
     SAY 'UNABLE TO ENABLE RXDB2'
     EXIT 16
     END

DEFAULT: hcename = DB2 or pgm = RXDB2

RETURN: ‘value’ if function is completed successfully

NOGO: if function fails

VARSPF(varname)

compresses out the period or periods in the compound variable name and ensures that the resulting variable name is no more than 8 characters long

A compound variable (AA.1) cannot be used in an ISPF dialog. Function VARSPF(AA.1) creates a new simple variable AA1 containing the same data as AA.1 so it can be used in an ISPF dialog.

IF DATATYPE(SQLEMSG.0) = NUM THEN
            DO I = 1 TO
               SQLEMSG.0 SQLEM.I = SPACE(SQLEMSG.I)
               A = VARSPF('SQLEM.'I)
               END /* I LOOP */

 

DEFAULT: none

RETURN: OK if function is completed successfully

NOGO: if function fails

TRUNCATED: if function has to truncate the variable name

WAITSEC(n)

waits n seconds before continuing to process

DO I = 1 TO 5
   A = WAITSEC(2) /* WAIT 2 SECONDS */
   SAY 'LOOP COUNT=' I 'TIME=' TIME()
   END

DEFAULT: n = 5 (seconds)

RETURN: OK if function is completed successfully

NOGO: if function fails

 

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