#include <hmq.h> MQEINT32 MQeFieldsPutByArrayOfFd( MQEHSESS hSess, MQEHFIELDS hFlds, MQECONST MQEFIELD pFds[], MQEINT32 nFds, MQEINT32 * pCompCode, MQEINT32 * pReason)
#include <hmq.h> static MQECHAR const * FieldsType = "com.ibm.mqe.MQeFields"; static const MQECHAR * textVal = "The Owl and the Pussy Cat went to sea."; static const MQEFIELD PFDS[] = { {MQE_TYPE_BYTE, 0, 0, "fooByte", 0, 0, (MQEBYTE *)0}, {MQE_TYPE_SHORT, 0, 0, "fooShort", 0, 0, (MQEBYTE *)0}, {MQE_TYPE_LONG, 0, 0, "fooLong", 0, 0, (MQEBYTE *)0}, {MQE_TYPE_ASCII, 0, 0, "fooText", 0, 0, (MQEBYTE *)0} }; MQEHSESS hSess; MQEINT32 compcode; MQEINT32 reason; MQEHFIELDS hFlds; MQEBYTE byteVal; MQEINT16 int16Val; MQEINT32 int32Val, pDataLen[2], *pDataLen2; MQEVOID * ppData[4], ** ppData2, **ppData3; MQEINT32 rc, nFlds; MQEINT32 i; MQEBYTE datatype; MQEFIELD * pFds; hSess = MQeInitialize("MyAppsName", &compcode, &reason); hFlds = MQeFieldsAlloc( hSess, FieldsType, &compcode, &reason); /* Put some fields in the fields object using MQeFieldsPutByArrayOfFd() */ byteVal = 0xAE; int16Val = 0x9876; int32Val = 0x12345678; PFDS[0].fd_fd_datalen = sizeof(byteVal); PFDS[1].fd_fd_datalen = sizeof(int16Val); PFDS[2].fd_fd_datalen = sizeof(int32Val); PFDS[3].fd_fd_datalen = strlen(textVal); PFDS [0].fd_data = (MQEVOID *)&byteVal; PFDS [1].fd_data = (MQEVOID *)&int16Val; PFDS [2].fd_data = (MQEVOID *)&int32Val; PFDS [3].fd_data = (MQEVOID *) textVal; MQFieldsPutByArrayOfFd( hSess, hFlds, PFDS, 4, &compcode, &reason); /* Get the field lengths, not data */ for (i=0;i<4;i++) { PFDS[i].fd_fd_datalen = 0; PFDS[i].fd_data = (MQEVOID *)0; } nFlds = MQFieldsGetByArrayOfFd( hSess, hFlds, PFDS, 4, &compcode, &reason); if (nFlds > 0) { /* Get space for field data */ for( i=0; i<nFlds; i++) { PFDS[i].fd_data = (MQEVOID *) malloc(PFDS[i].fd_datalen*mqe_sizeof (PFDS[i].fd_datatype)); } /* Get all the fields defined in field descriptor array in one shot */ nFlds = MQFieldsGetByArrayOfFd( hSess, hFlds, PFDS, nFds, &compcode, &reason); }