GETATTACHMENT

Gets attachment information that is associated with a particular message.
Supports: MQSeries, MQSeries C, MSMQ, Rendezvous, Rendezvous-CM

Syntax

CALL GETATTACHMENT(qid, lastflag, attachid, type, qual1, qual2, rc , desc, minor , major>>>);

Required Arguments

qid
Numeric, input
Specifies the handle of an opened queue obtained from a previous OPENQUEUE function call.
lastflag
Numeric, output
Indicates whether you have reached the last attachment in a message. Possible values are as follows:
0
Specifies that more attachments are to be presented.
1
Specifies that this is the final attachment.
attachid
Numeric, output
Returns an attachment identifier that is used with the ACCEPTATTACHMENT function call when this attachment is accepted.
type
Character, output
Returns the type of attachment. The following types are valid:
  • EXTERNAL_TEXT
  • EXTERNAL_BIN
  • DATASET
qual1
Character, output
Returns the first attachment qualifier. If this is an external attachment, then this qualifier designates the file specification that is used to send it (either FILENAME or FILEREF). Otherwise, this qualifier designates the sending library name.
qual2
Character, output
Returns the second attachment qualifier. If this is an external attachment, then this qualifier designates the sending filename or fileref. Otherwise, this qualifier designates the sending member name.
rc
Numeric, output
Provides the return code from the CALL routine. If an error occurs, then the return code is nonzero. You can use the SAS function SYSMSG() in order to obtain a textual description of the return code.
desc
Character, output
Returns a description of the attachment if the sender provides one. This parameter is optional.
minor
Numeric, output
Returns a user-specified minor version number. This parameter is optional.
major
Numeric, output
Returns a user-specified major version number. This parameter is optional.

Details

You can repeatedly call this function until the final attachment has been presented.
Note: To receive an attachment from outside of the SAS environment, you must know the layout of an attachment. For more information, see the Attachment Layout for WebSphere MQ and MSMQ and the Attachment Layout for TIBCO Rendezvous .

Example

The following example gets all of the attachment information from a message:
length msg $ 200;
length qid lastflag attachid rc 8;
length type $ 13;
length qual1 qual2 $ 80;
length desc $ 80;
length minor major 8;
next:
   rc=0;
   lastflag=0;
   attachid=0;
   type='';
   qual1='';
   qual2='';
   desc='';
   minor=0;
   major=0;
   call getattachment(qid, lastflag, attachid, type,
      qual1, qual2, rc, desc, minor, major);
   if rc ^= 0 then do;
      put 'GETATTACHMENT: failed';
      msg = sysmsg();
      put msg;
   end;
   else do;
      put 'GETATTACHMENT: succeeded';
      put 'Attachment type is ' type;
      if type eq 'EXTERNAL_TEXT' OR type eq
	     'EXTERNAL_BIN' then do;
         put "Sender's " qual1 " was " qual2;
      /* process external file... */
      end;
   else do;
      put "Sender's library name was ' qual1;
      put "Sender's member name was ' qual2;
      /* process library member... */
      end;
      if lastflag eq 0 then goto
next;