SAS 9.1.3 Integration Technologies » Developer's Guide


SAS Stored Processes
Implementing a Repository
Creating a Stored Process
Invoking a Stored Process
Publishing Stored Process Results
Working with Stored Process Results in the Client Application
IOM Direct Interface Stored Processes

Publishing Stored Process Results

At this point, if you have read the section, Invoking a Stored Process, and you have seen how the IOM StoredProcessService is used to invoke the stored process on the server, you may be wondering what happens to the results. This is where packages come into play.

One of the main features of SAS Integration Technologies is the Publishing Framework. Central to the publishing framework is the ability to create or collect data, including SAS output, in the form of packages.

One of the ways in which you can create packages is with the Publish Package Interface. This is a library of SAS CALL routines that you can use within your stored processes to create a package and then publish it to various delivery transports including an e-mail address(es), a message queue, subscribers to a predefined channel, a WebDAV-Compliant server, and to an archive. (See the Publish Package Interface for more details.)

An additional method of delivering a published package is to send it back to the requesting application. This transport is sometimes referred to as the To_Requester transport because that is the value of the parameter in the PACKAGE_PUBLISH CALL routine that controls how the package is delivered.

Follow these basic steps to use the Publish Package Interface:

  1. Initialize the package. For example, the following SAS language code initializes a package:
       packageId=0;
       rc=0;
       PkgDesc = "package contains a printed report 
          and graph for the May Sales Data.";
       nameValue='';
       CALL PACKAGE_BEGIN(packageId, desc, nameValue, rc);
    
  2. Add one or more entries to the package. The following example uses the SAS Output Delivery System (ODS) to generate HTML files that are subsequently inserted into the package. Note that the statements below for PROC SQL, PROC SORT, and PROC PRINT are from the example stored process that is used in Creating a Stored Process.
       ItemDesc='HTML output for May Sales Data';
       nameValue = '';
       filename f '/users/f.html';
       filename c '/users/c.html';
       filename b '/users/b.html';
       filename p '/users/p.html';
       ods html frame=f contents=c(url='c.html') 
          body=b(url='b.html') page=p(url='p.html');
    
       proc sql;
          create table xQuery as
          select &svar
             from datain.&intable
          where &filter;
    
       proc sort data=xQuery;
       by &svar;
    
       proc print data=xQuery;
       by &svar;
    
       ods html close;
    
       /* The statement below inserts the 
          resulting HTML into the package */
    
       CALL INSERT_HTML(packageId, 'fileref:b', "b.html", 
          'fileref:f', "f.html", 'fileref:c', "c.html", 
          'fileref:p', "p.html", ItemDesc, nameValue, rc);
    

    You can add additional items to the package as needed. The example below adds another item; in this case, the GIF file that was produced from SAS/GRAPH from the example stored process that is used in Creating a Stored Process.

       filename = 'filename:c:\Temp\&tempdir\xQuery.gif';
       filetype ='binary';
       desc = 'Graph of the SP01 results in GIF format.';
       nameValue = '';
       mimetype = 'Image/gif';
       CALL INSERT_FILE(packageId, filename, filetype, 
          mimetype, desc, nameValue, rc);
    
  3. Publish the package. The following SAS language code shows an example of publishing the package back to the requesting application:
       call package_publish(packageId, 
          "TO_REQUESTER", rc, "", "");
    
  4. Release the package resources. This is the last step of the publish process using the Publish Package interface. It frees the SAS system resources that were associated with the package that was just published. The following SAS language code shows an example of how to use this CALL routine:
       call package_end(packageId, rc);