To get the content of a field in a message, call the MQeFieldsGet API, passing a valid pointer to the memory that will receive the data. The data is returned into this memory.
#include <hmq.h> static MQECHAR const * FieldsType = "com.ibm.mqe.MQeFields"; MQEHSESS hSess; MQEINT32 compcode; MQEINT32 reason; MQEHFIELDS hFlds; MQEBYTE datatype; MQEINT32 n; MQEBYTE * pdata; MQEBYTE * buf; MQEINT32 rc; hSess = MQeInitialize("MyAppsName", &compcode , &reason); MQEGMO gmo = MQEGMO_DEFAULT; /*Set default get message options*/ ... /* * Get a message from a queue. */ hFlds = MQeQMgrGetMsg( hSess, "ExampleQM", "SYSTEM.DEFAULT.LOCAL.QUEUE", &gmo, NULL, &compcode, &reason); /* Get the field data length (into n) and type (into datatype) of a field (name: "XYZ")*/ n = MQeFieldsGet( hSess, hFlds, "XYZ", &datatype, NULL, 0, NULL, + &compcode, &reason); /* Verfify that datatype is correct. */ /* Get some space to put the data */ buf = (MQEBYTE *)calloc(n, MQE_SIZEOF(datatype)); /* Get the field data */ rc = MQeFieldsGet( hSess, hFlds, "XYZ", NULL, buf, n, NULL, &compcode, &reason); /* Do something with the data in buf */ /* Free buf */ free( buf ); /* Free the fields object */ MQeFieldsFree( hSess, hFlds, &compcode, &reason); /*Terminate the session */ MQeTerminate( hSess, &compcode, &reason);