Example: request message to issue CEMT INQUIRE TASK through the CICS-WebSphere MQ bridge

This example shows how an application can use the CICS-WebSphere MQ bridge to start a 3270 transaction, in this case CEMT, that would normally be started by entering its identifier and some command line arguments at a CICS® terminal.

When the CEMT task starts, it issues an EXEC CICS RECEIVE command to receive any command-line arguments that follow its identifier. The non-CICS application that emulates the command line invocation must therefore start CEMT with a RECEIVE vector that contains appropriate values in the vector structure, and also include the command-line values.

Constructing the request message

The following C language code fragment shows how the request message can be constructed. The C language header file dfhbrmqh.h is in the CICS SAMPLIB library.
/* #includes */
#include cmqc.h /* WebSphere MQ header */
#include dfhbrmqh.h /* Vector structures */
⋮
/* #defines */
#define CMDSTRING "CEMT I TASK" /* Command string */
#define RCV_VECTOR "0402" /* Vector descriptor */
#define INBOUND "I " /* Inbound type */
#define VERSION "0000" /* Vector version */
#define YES "Y " /* YES indicator */
#define NO "N " /* NO indicator */
⋮
/* Data declarations */
/* AID indicator value */
const char AID[ 4 ] = { 0x7d, ' ',' ',' ' } ;
MQMD mqmd ; /* Message descriptor */
MQCIH mqcih = {MQCIH_DEFAULT} ; /* CICS information header */
brmq_vector_header brvh ; /* Standard vector header */
brmq_receive brrcv ; /* RECEIVE vector structure */
MQCHAR * MsgBuffer ; /* Message buffer pointer */
⋮

The outbound message that is returned to the reply queue contains a SEND reply vector with data in terminal control format. Your application must interpret this format to analyze the data that it receives.

Allocating storage for the message buffer

/* allocate storage for the message buffer. Note that the RECEIVE */
/* vector structure includes space for the standard vector header.
*/

MsgBuffer = malloc(sizeof(MQCIH) + sizeof(brrcv)
+ strlen(CMDSTRING) ) ;
⋮

Setting up the MQMD

memcpy(mqmd.Format, MQFMT_CICS,sizeof((MQFMT_CICS));
memcpy(mqmd.MsgId, MQMI_NONE, sizeof(MQMI_NONE));
memcpy(mqmd.CorrelId, MQCI_NEW_SESSION, sizeof((MQCI_NEW_SESSION);
mqmd.MsgType = MQMT_REQUEST;
strncpy(mqmd.ReplyToQueue,"MyReplyQueue");

Setting up the MQCIH

mqcih.LinkType = MQCLT_TRANSACTION ;
mqcih.GetWaitInterval= 1000 ; /* one second */
mqcih.FacilityKeepTime = 10000 ; /* |= 0 says return token */
memcpy(mqcih.Facility,MQCFAC_NONE,sizeof(MQCFAC_NONE));
strncpy(mqcih.TransactionId, "CEMT", strlen("CEMT"));
strncpy(mqcih.FacilityLike, " ", strlen(" "));
mqcih.UOWControl = MQCUOWC_FIRST;
memcpy(mqcih.AttentionId,AID,sizeof(mqcih.AttentionId); /* enter
pressed */

Setting up the BRMQ

brvh.brmq_vector_length = sizeof(brrcv) + strlen(CMDSTRING) ;
strncpy(brvh.brmq_vector_descriptor, RCV_VECTOR,
strlen(RCV_VECTOR)) ;
strncpy(brvh.brmq_vector_type, INBOUND, strlen(INBOUND)) ;
strncpy(brvh.brmq_vector_version, VERSION, strlen(VERSION)) ;
/* Initialize fields in the RECEIVE vector structure: */
strncpy(brrcv.brmq_re_transmit_send_areas, YES, strlen(YES)) ;
strncpy(brrcv.brmq_re_buffer_indicator, NO, strlen(NO)) ;
strncpy(brrcv.brmq_re_aid, AID, sizeof(brrcv.brmq_re_aid)) ;
brrcv.brmq_re_data_len =strlen(CMDSTRING) ;

Building the message

/* Copy the MQCIH to the start of the message buffer */
memcpy(MsgBuffer, &mqcih, sizeof(MQCIH)) ;
/* Append the RECEIVE vector to the CIH */
memcpy(MsgBuffer + sizeof(MQCIH), brrcv, sizeof(brrcv) ) ;
/* Overlay the standard vector header on the RECEIVE vector */
memcpy(MsgBuffer + sizeof(MQCIH), brvh, sizeof(brvh) ) ;
/* Append the command string to the vector structure */
strncpy(MsgBuffer + sizeof(MQCIH) + sizeof(brrcv),
CMDSTRING, strlen(CMDSTRING)) ;
/* the message is now ready for the MQPUT with length of
sizeof(MQCIH) + sizeof(brrcv)+ strlen(CMDSTRING);


fg15580_.html | Timestamp icon Last updated: Monday, 5 June 2017