Application Facilities |
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 result set 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 a result set packages (usually referred to as 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:
packageId=0; rc=0; PkgDesc = "This package contains a printed report and graph for the May Sales Data."; nameValue=''; CALL PACKAGE_BEGIN(packageId, desc, nameValue, rc);
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);
call package_publish(packageId, "TO_REQUESTER", rc, "", "");
call package_end(packageId, rc);
Application Facilities |