Friday, May 17, 2019

REXX: External Functions

In addition to in built functions, REXX provides external functions to do specific tasks

SYSDSN:

This function returns OK if the specified data set exists; otherwise, it returns an appropriate error message.

The input for this function is a dataset name.

Example:

if SYSDSN(" ' Your Dataset ' ") /= 'OK' then do       
    say "Dataset doesn't exist. ' 
end

SYSVAR:

This function uses specific argument values to return information about the user, terminal, language, exec, system, and console session.

Example:

userid = SYSVAR(SYSUID)
say userid

This would return the userid who is logged in.

SETLANG:

This function is used to determine the currently language being used and also it allows us to change the language.

Example:

 curlang=SETLANG()
 say curlang 

OUTTRAP:

This function puts lines of command output into a series of numbered variables, each with the same prefix. These variables save the command output and allow an exec to process the output. Specify the variable name in parentheses following the function call.

Example:
x = OUTTRAP('att')
"LISTC"

att0 - will contain the no. of lines stored.
att1 - will contain the first line
att2 - will contain the second line and so on

you can also use STEM variables as parameter.

Example:

x = OUTTRAP('out.')
"LISTC"

out.0 - will contain the no. of lines stored.
out.1 - will contain the first line
out.2 - will contain the second line and so on

LISTDSI:

This function lists the dataset information.

Example:

x = LISTDSI(" ' Your Dataset ' ")

This statement will populate many system variables.

for ex:
SYSDSNAME
SYSRECFM 
SYSLRECL 
SYSBLKSIZE
SYSKEYLEN
SYSALLOC
SYSUSED
SYSUSEDPAGES
SYSPRIMARY
SYSSECONDS
SYSUNITS
SYSEXTENTS
SYSCREATE

No comments:

Post a Comment

Featured Post

REXX Skeleton: Submitting jobs through Rexx

Submitting jobs through REXX and reading the spool through REXX gives us immense potential to automate many manual activities in mainframes....