|SAS Companion for the OS/390 Environment|
The following sections provide the information that you need in order to write the functions that are part of the user exit module.
SAS calls the Initialization function before it calls any of the other functions. In the Initialization function, you specify the amount of virtual memory that your routine will need above and below the 16-megabyte address line. You store the length of the work area that you need above the line in the fullword that is pointed to by the INITMALN field of the Initialization FRCB. You store the length of the work area that you need below the line in the fullword that is pointed to by the INITMBLN field of the Initialization FRCB. All pointers in the Initialization FRCB point to valid data areas.
In the amount of storage that you request, you should include space for a Local Register Save Area (LRSA) of 72 bytes, plus any other work areas that your Parse Options function and Open function will need.
SAS allocates the memory that you request when it returns from this function, and it stores pointers to the allocated memory in the UEBCB. The pointer to the memory that was allocated above the line is stored in the MEMABV field of the UEBCB. The pointer to the memory that was allocated below the line is stored in the MEMBEL field.
Initialization FRCB illustrates the Initialization FRCB structure and its relationship with other control blocks:
|Parse Options Function|
In the Parse Options function, you validate both the name of the user exit and any INFILE or FILE statement options that SAS does not recognize. SAS calls this function once to process the user exit module name. SAS then calls the function for each statement option that it does not recognize so that the function can process each option and value string.
You can use two kinds of statement options in your user exit:
Note that quotes are considered part of the value; if you want them to be stripped off, you must provide the code to do so.
The first time the Parse Options function is invoked, it should do the following:
Parse Options FRCB illustrates the Parse Options FRCB structure and its relationship to other control blocks.
Parse Options FRCB
When the Parse Options function receives control, PARSOPTL is set to the length of the option name, and the address of the option name is stored in PARSOPTN. For options that take a value, PARSVALL is set to the length of the value, and the address of the option value is stored in PARSVAL. For options that do not take a value, both PARSVALL and PARSVAL are set to 0.
If an invalid option name or option value is detected, R15 should be set to a return code value of 8.
SAS invokes the Open function after INFILE or FILE statement processing opens the associated data set. Open FRCB illustrates the Open FRCB and its relationship to other control blocks:
The OPENMODE field can be one of the following values:
|1||the data set is opened for input mode.|
|2||the data set is opened for output mode.|
|4||the data set is opened for append mode.|
|8||the data set is opened for update mode (read and write).|
When this function receives control, the Pointer to User Maximum Data Size field (OPENZLEN) points to a fullword that contains the Data Set Record Size. In this function, set the pointer so that it points to a fullword that you initialize. The fullword should contain the size of the largest record that you expect to process with the Read function. If it contains a lesser value, then truncated records may be passed to the Read function.
The Data Set Record Format field (OPENRECF) can be any combination of the following values:
|'C0'x||indicates Undefined format.|
|'80'x||indicates Fixed format.|
|'40'x||indicates Variable format.|
|'10'x||indicates Blocked format.|
|'08'x||indicates Spanned format.|
|'04'x||indicates ASA Control Characters format.|
The Open function should activate any subprocesses or exits and should solicit from them any virtual storage requirements.
In this function, if you turn on the EX_NEXT flag in the UEBCB, SAS calls the Read function for the first record before it reads any records from the file itself.
If you use any SAS service routines (such as the ALLOC and FREE routines) in this function, then you must set the EX_ALC flag in the UEBCB.
SAS invokes the Read function during execution of the INPUT statement to obtain the next input record. Read FRCB illustrates the Read FRCB structure and its relationship to other control blocks:
When the Read function receives control, the READRECA field (or Pointer to User Record Area Address) points to the address of the current record from the file. The READRECL field points to a fullword that contains the length of the record that is in the Record Area.
In this function you can change the Record Address so that it points to a record that was defined by your user exit. If you do this, then SAS passes your record to the INPUT statement, rather than passing the record that was read from the file. However, in this case you must also update the fullword that the Pointer to Record Size points to: it must equal the actual size of the record that the Record Address points to.
As long as the EX_NEXT flag is on, SAS invokes the Read function to obtain the next record. SAS reads no records from the file itself until you turn off the EX_NEXT flag.
If you set the EX_DEL flag, then SAS ignores the current record, and processing continues to the next record.
SAS invokes the Concatenation function whenever a data set in a concatenation of data sets has reached an end-of-file condition and the next data set has been opened. Concatenation FRCB illustrates the Concatenation FRCB structure and its relationship to other control blocks:
In this function you can modify the maximum data size for the next data set by changing the Pointer to User Maximum Data Size so that it points to a fullword that you initialize.
SAS invokes the Write function during the execution of the PUT statement whenever a new record must be written to the file. Write FRCB illustrates the Write FRCB and its relationship to other control blocks.
When the Write function receives control, the WRITRECA field (or Pointer to User Record Area Address) points to a Record Address. The Record buffer is allocated by SAS and contains the record that was created by the PUT statement.
In this function you can change the Record Address so that it points to a record that is defined by your user exit. If you do this, then SAS writes your record to the file, instead of writing the record that was created by the PUT statement. However, in this case you must also update the fullword that the Pointer to Record Size points to: it must equal the actual size of the record that the Pointer to Record Area points to.
In the Write function, you may also change the setting of flags in the UEBCB. As long as the EX_NEXT bit in the UEBCB is on, SAS calls the Write function to write the next output record. The DATA step is not prompted for any new records to output until the EX_NEXT flag has been set. At any time, if the EX_DEL bit in the UEBCB is on, SAS ignores the current record, and processing continues to the next record.
SAS invokes the Close function after it closes the associated data set. In this function, you should close any files that you opened, free any resources that you obtained, and terminate all subprocesses or exits that your user exit initiated.
Close FRCB illustrates the Close FRCB structure and its relationship to other control blocks.
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.