SAS 9.1.3 Integration Technologies » Developer's Guide


Publish Package Interface
Publish/Retrieve Encoding Behavior
Publishing Packages
INSERT_CATALOG
INSERT_DATASET
INSERT_FDB
INSERT_FILE
INSERT_HTML
INSERT_MDDB
INSERT_PACKAGE
INSERT_REF
INSERT_SQLVIEW
INSERT_VIEWER
PACKAGE_BEGIN
PACKAGE_END
PACKAGE_PUBLISH
LDAP Channel Store Syntax
SAS Metadata Repository Channel Store Syntax
Retrieving Packages
COMPANION_NEXT
ENTRY_FIRST
ENTRY_NEXT
PACKAGE_DESTROY
PACKAGE_FIRST
PACKAGE_NEXT
PACKAGE_TERM
RETRIEVE_CATALOG
RETRIEVE_DATASET
RETRIEVE_FDB
RETRIEVE_FILE
RETRIEVE_HTML
RETRIEVE_MDDB
RETRIEVE_NESTED
RETRIEVE_PACKAGE
RETRIEVE_REF
RETRIEVE_SQLVIEW
RETRIEVE_VIEWER
Filtering Packages
Publishing Examples
Publishing in the Data Step
Publishing in a Macro
Publishing with FTP
Publishing Framework

Example: Publishing in the Data Step

The following example builds a package, and then explicitly publishes to two queues, and then publishes to a channel defined within the LDAP directory. This example uses the data step, but easily can be changed to use the macro interface.

   filename f 'c:\frame.html';
   filename c 'c:\contents.html';
   filename p 'c:\page.html';
   filename b 'c:\body.html';
   ods html frame = f contents =c(url="contents.html") 
      body = b(url="body.html") page=p(url="page.html");

   /* run some data steps/procs to generate ODS output */
   data b;
      do i= 1 to 1000;
      output;
   end;
   run;

   data emp;
   input fname $ lname $ ages state $ siblings;
   cards;
   Steph Lyons 32 NC 4
   Richard Jones  40  NC 2
   Mary White  74 NC 1
   Kai Burns 3   NC 1
   Dakota Nelson 1 NC 1
   Paul Black 79 NC 8
   Digger Harris 5  NC 0
   Coby Thomas 1   NC 0
   Julie Mack 6 NC 1
   Amy Gill 3   NC 1
   Brian Meadows 16 HA 1
   Richard Wills 17 HA 1
   Diane Brown 48 CO 4
   Pamela Smith 42 HA 4
   Joe Thompson  44 WA 10
   Michael Grant 23 IL 1
   Michael Ford 31 NM 4
   Ken Bush 28 NC 1
   Brian Carter 27 NC 1
   Laurie Clinton 32 NC 1
   Kevin Anderson 33 NC 1
   Steve Kennedy 33 NC 1
   run;
   quit;

   proc print;run;
   proc contents;run;
   ods html close;

   data _null_;
      rc=0;a='a';b='b';c='c';d='d';
      length filename $64 mimeType $24 fileType 
	     $10 nameValue $100 description $100;

      pid = 0;
      nameValue="type=(test) coverage=(filtering, 
	     transports)";
      call package_begin(pid,"Main results package.", 
	     nameValue, rc);
      if (rc eq 0) then put 'Package begin successful.';
      else do;
         msg = sysmsg();
         put msg;
      end;

      gifpid=0;
      call package_begin(gifpid,"Gif nested package.",'', rc);
      if (rc eq 0) then put 'Gif package begin successful.';
      else do;
         msg = sysmsg();
         put msg;
      end;

      nameValue="type=report, topic=census";
      description="North Carolina residents.";
      libname = "WORK";
      memname="EMP";
      call insert_dataset(pid, libname, memname, 
	     description, nameValue, rc);
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
      end;
      else
         put 'Insert data set successful.';


      call insert_html(pid,"fileref:b", "", 
         "fileref:f", "",
         "fileref:c", "",
         "fileref:p", "", "ODS HTML Output",'', rc);
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
      end;
      else
         put 'Insert html successful.';


      call insert_dataset(pid,"WORK","b",
	     "B dataset...",'', rc);
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
      end;
      else
         put 'Insert data set successful';

      /* insert package (nested package */
      call insert_package(pid, gifpid,rc);
      if rc eq 0 then put 'Insert package successful';
      else do;
         msg = sysmsg();
         put msg;
      end;


      description = "Gif for marketing campaign.";
      filename = "filename:campaign01.01.gif";
      fileType = "Binary";
      mimeType = "Image/Gif";
      call insert_file(gifpid, filename, fileType, 
         mimeType, description,'', rc);
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
      end;
      else
         put 'Insert file (gif) successful.';


      description = "Test VRML file.";
      filename = "filename:test.wrl";
      fileType = "text";
      mimeType = "model/vrml";
      call insert_file(pid,filename, fileType, 
         mimeType, description,'', rc);
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
      end;
      else
         put 'Insert file (vrml) successful.';


      /* send package to the two queues that are specified */
      properties='';
      call package_publish(pid, "TO_QUEUE", rc, properties,  
	     "MQSERIES://JSMITH.LOCAL", "MSMQ://JSMITH\transq");
      if rc ne 0 then  do;
         msg = sysmsg();
         put msg;
      end;
      else
         put 'Publish successful';


      /* publish to the filter test channel 
	     defined in LDAP directory */
      ldapinfo = 
         "LDAP://alpair01.unx.sas.com:8010/o=Alphalite Airways,
         c=US";
      channel1= 'FilterTest1';
      properties='channel_store, subject';
      subject="Filter Testing Results";
      call package_publish(pid, "TO_SUBSCRIBERS", rc, 
         properties, ldapinfo, subject, channel1);
      if rc ne 0 then  do;
         msg = sysmsg();
         put msg;
      end;
      else
         put 'Publish successful';

      call package_end(pid,rc);
      if rc ne 0 then  do;
         msg = sysmsg();
         put msg;
      end;
      else
         put 'Package end successful';
   run;
   quit;