Progress
AppBuilder
Developer’s Guide


Example of receiveHandler Code

This code might be used in an INMESSAGE-TARGET object other than a SmartB2BObject, for example a SmartReceiver. Note the similarities to the receiveReplyHandler code:

DEFINE INPUT PARAMETER hMessage AS HANDLE NO-UNDO. 
/* 
** Declare storage 
*/ 
DEFINE VARIABLE cMessageType AS CHARACTER NO-UNDO. 
DEFINE VARIABLE cMessageID AS CHARACTER NO-UNDO. 
DEFINE VARIABLE mMessageBody AS MEMPTR NO-UNDO. 
DEFINE VARIABLE cProperty AS CHARACTER NO-UNDO. 
DEFINE VARIABLE cPropertyNames AS CHARACTER NO-UNDO. 
DEFINE VARIABLE cPropType AS CHARACTER NO-UNDO. 
DEFINE VARIABLE iThisProp AS INTEGER NO-UNDO. 
DEFINE VARAIBLE cCharProp AS CHARACTER NO-UNDO. 
DEFINE VARIABLE dDecProp AS DECIMAL NO-UNDO. 
DEFINE VARIABLE iIntProp AS INTEGER NO-UNDO. 
DEFINE VARIABLE lLogicProp AS LOGICAL NO-UNDO. 
/*  
** Loop through all properties, identifying types and extracting values 
** appropriately  
*/ 
cPropertyNames = DYNAMIC-FUNCTION(‘getPropertyNames’:U IN hMessage). 
DO iThisProp = 1 TO NUM-ENTRIES( cPropertyNames ): 
 cProperty = ENTRY(iThisProp, cPropertyNames). 
 cPropType = DYNAMIC-FUNCTION(‘getPropertyType’:U IN hMessage, 
                INPUT cProperty). 
 CASE cPropType: 
   
  WHEN ‘String’:U THEN DO: 
   cCharProp = DYNAMIC-FUNCTION(‘getCharProperty’:U IN hMessage,  
                  INPUT cProperty). 
    /*  
    ** Insert code for processing a string property  
    */ 
  END. 
   
  WHEN ‘Boolean’:U THEN DO: 
   lLogicProp = DYNAMIC-FUNCTION(‘getLogicalProperty’:U IN hMessage,  
                INPUT cProperty). 
    /*  
    ** Insert code for processing a logical property  
    */ 
  END. 
   
  WHEN ‘Byte’:U OR WHEN ‘Short’:U OR WHEN ‘Int’:U THEN DO: 
   iIntProp = DYNAMIC-FUNCTION(‘getIntProperty’:U IN hMessage, 
                 INPUT cProperty). 
    /*  
    ** Insert code for processing an integer property  
    */ 
  END. 
   
  WHEN ‘Long’:U OR WHEN ‘Float’:U OR WHEN ‘Double’:U THEN DO: 
   dValue = DYNAMIC-FUNCTION(‘getDecProperty’:U IN hMessage, 
                INPUT cProperty). 
    /*  
    ** Insert code for processing a decimal property  
    */ 
  END. /* when decimal */ 
 END. /* case cPropType */ 
END. /* DO iThisProp */ 
/* 
** Determine message type; extract body appropriately 
*/ 
cMessageType = DYNAMIC-FUNCTION(‘getMessageType’:U IN hMessage). 
CASE cMessageType: 
  
 WHEN ‘BytesMessage’:U THEN DO: 
  mMessageBody = DYNAMIC-FUNCTION(‘getMemptr’:U IN hMessage). 
 END. 
  
 WHEN ‘TextMessage’:U OR WHEN ‘XMLMessage’:U THEN DO: 
  DO WHILE (DYNAMIC-FUNCTION(‘endOfStream’:U IN hMessage) = FALSE: 
   cMessageBody = DYNAMIC-FUNCTION(‘getTextSegment’:U IN hMessage). 
   /*  
   ** Insert code here to put extracted text segments into a form,  
   ** such as temp-table records, that can be read by the routine 
   ** that will process the body of this message 
   */ 
  END. /* do while */ 
 END. /* when text message */ 
END. /* case cMessageType */ 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095