The %STPBEGIN and %STPEND
macros implement several options for delivering results.
For an introduction to the standard options for stored process results,
see Setting Result Capabilities. In most cases, a stored process that uses
these macros can support all the standard result types with no special
coding. The _RESULT variable defines the result type. The following
values are supported:
returns only a completion
status. An ODS destination is not opened, but the ODS LISTING destination
is closed.
returns the body or
file output from ODS as a stream. This is the default result type
if _RESULT is not set.
There are several values
for _RESULT that generate packages. Packages can be delivered directly
to the client and published to a more permanent location on the server
file system, a WebDAV server, or other destinations. Package creation
and delivery are controlled by many reserved macro variables. Here
are the variables that are valid for all package destinations:
Here are additional
variables that are recognized for specific _RESULT settings:
creates an archive
package on the server file system that contains the generated output.
The _ARCHIVE_PATH and _ARCHIVE_NAME variables specify where the package
is created. In addition, _ARCHIVE_FULLPATH is set by %STPEND to hold
the full pathname of the created archive package.
returns a package to
the stored process client. It can also simultaneously create an archive
package on the server file system if _ARCHIVE_PATH and _ARCHIVE_NAME
are set. This option is valid only on the workspace server, and only
for stored processes that are compatible with 9.2.
creates a package as
a collection on a WebDAV-compliant server. The location of the package
is defined by _COLLECTION_URL or _PARENT_URL. Other relevant variables
include _HTTP_PASSWORD, _HTTP_PROXY_URL, _HTTP_USER, and _IF_EXISTS.
The %STPBEGIN macro
configures ODS to create output files in a temporary working directory.
The %STPEND macro then creates the package from all of the files in
this temporary directory. The temporary directory is defined by the
_STPWORK variable. This variable should not be changed by the stored
process, but new entries can be added to the output package by creating
files in this directory. For example, the XML LIBNAME engine might
be used to create one or more XML files that would be included in
the package along with any output that was created by ODS. The temporary
directory and any files that are contained in it are automatically
deleted when the stored process completes. No cleanup is required
in the stored process program.
Note: If the environment variable
STPWORK is not set when the server is started, then STPBEGIN determines
a temporary directory based on the operating system, and places that
value in the _STPWORK reserved macro variable. If the environment
variable STPWORK is set when the server is started, then STPBEGIN
uses the directory specified as a starting point to create the temporary
directory. For example, the STPWORK environment variable is set to
/usrs/. STPBEGIN creates a temporary subdirectory under /usrs/ and
places the full path to the temporary directory in the _STPWORK reserved
macro variable.