Forum Post: Re: How To Define Type Mqod When Calling Websphere Mq Api Function Mqopen

Status
Not open for further replies.
F

Fuelfire

Guest
I wrote the program and set up an environment variable MQSERVER. When I try to connect to queue manager I get an error 2058 (Queue manager name not valid or not known). I tried to put a message to a queue using the WebSphere utility amqsputc. Using the same values of the host server, the port channel, the queue manager and the queue, I was able to put a message in the queue. What could be wrong? MQ administrator also gave me the name of the user to connect. I created the same local user and invoke the console as this user. When I called cmd under my account, I get an error 2035 (Not authorized for access). I do not know how to run p-file under desired user. I tried to do it using "RUN AS", but the error remains the same .. I'm confused. /*Usual sequence is: MQ Connect (queue manager name) MQ Open (queue name) MQ Put / Get (message) MQ Close (q) MQ Disconnect (qm) */ &SCOPED-DEFINE MQCC_OK 0 &SCOPED-DEFINE MQRC_NONE 0 &SCOPED-DEFINE MQOO_INPUT_EXCLUSIVE 4 &SCOPED-DEFINE MQOO_OUTPUT 16 &SCOPED-DEFINE MaxMsgLength 104 857 600 &SCOPED-DEFINE DLL-LIB mqic32.dll &SCOPED-DEFINE MQCO_NONE 0 DEFINE VARIABLE QMgrName AS CHAR FORMAT "X(48)" NO-UNDO. /* Name of queue manager */ DEFINE VARIABLE Hconn AS INT64 NO-UNDO. /* Connection handle */ DEFINE VARIABLE CompCode AS INT64 NO-UNDO. /* Completion code */ DEFINE VARIABLE Reason AS INT64 NO-UNDO. /* Reason code qualifying CompCode */ DEFINE VARIABLE ObjDesc AS MEMPTR NO-UNDO. DEFINE VARIABLE Hobj AS INT NO-UNDO. DEFINE VARIABLE MsgDesc AS MEMPTR NO-UNDO. DEFINE VARIABLE GetMsgOpts AS MEMPTR NO-UNDO. DEFINE VARIABLE PutMsgOpts AS MEMPTR NO-UNDO. DEFINE VARIABLE Buffer_ AS CHAR NO-UNDO. /*Area to contain the message data*/ DEFINE VARIABLE DataLength AS INT NO-UNDO. /*connect*/ PROCEDURE MQCONN EXTERNAL "{&DLL-LIB}" CDECL PERSISTENT: DEFINE INPUT PARAMETER QName AS CHAR NO-UNDO. /*Name of queue manager*/ DEFINE OUTPUT PARAMETER Hconn AS LONG NO-UNDO. /*Connection handle*/ DEFINE OUTPUT PARAMETER CompCode AS LONG NO-UNDO. /*Completion code: MQCC_OK - Successful completion. MQCC_WARNING - Warning (partial completion). MQCC_FAILED - Call failed.*/ DEFINE OUTPUT PARAMETER Reason AS LONG NO-UNDO. /*Reason code qualifying CompCode*/ END PROCEDURE. /*open*/ PROCEDURE MQOPEN EXTERNAL "{&DLL-LIB}" CDECL PERSISTENT: DEFINE INPUT PARAMETER Hconn AS LONG NO-UNDO. /*Connection handle*/ DEFINE INPUT-OUTPUT PARAMETER ObjDesc AS MEMPTR NO-UNDO. /*Object descriptor*/ DEFINE INPUT PARAMETER OPTIONS_ AS LONG NO-UNDO. /*Options that control the action of MQOPEN*/ DEFINE OUTPUT PARAMETER Hobj AS LONG NO-UNDO. /*Object handle*/ DEFINE OUTPUT PARAMETER CompCode AS LONG NO-UNDO. /*Completion code*/ DEFINE OUTPUT PARAMETER Reason AS LONG NO-UNDO. /*Reason code qualifying CompCode*/ END PROCEDURE. /*get message*/ PROCEDURE MQGET EXTERNAL "{&DLL-LIB}" CDECL PERSISTENT: DEFINE INPUT PARAMETER Hconn AS LONG NO-UNDO. /*Connection handle*/ DEFINE INPUT PARAMETER Hobj AS LONG NO-UNDO. /*Object handle*/ DEFINE INPUT-OUTPUT PARAMETER MsgDesc AS MEMPTR NO-UNDO. /*message descriptor*/ DEFINE INPUT-OUTPUT PARAMETER GetMsgOpts AS MEMPTR NO-UNDO. /*Options that control the action of MQGET*/ DEFINE INPUT PARAMETER BufferLength AS LONG NO-UNDO. /*Length in bytes of the Buffer area*/ DEFINE OUTPUT PARAMETER Buffer_ AS CHAR NO-UNDO. /*Area to contain the message data*/ DEFINE OUTPUT PARAMETER DataLength AS LONG NO-UNDO. /*Length of the message*/ DEFINE OUTPUT PARAMETER CompCode AS LONG NO-UNDO. /*Completion code*/ DEFINE OUTPUT PARAMETER Reason AS LONG NO-UNDO. /*Reason code qualifying CompCode*/ END PROCEDURE. /*put the message*/ PROCEDURE MQPUT EXTERNAL "{&DLL-LIB}" CDECL PERSISTENT: DEFINE INPUT PARAMETER Hconn AS LONG NO-UNDO. /*Connection handle*/ DEFINE INPUT PARAMETER Hobj AS LONG NO-UNDO. /*Object handle*/ DEFINE INPUT-OUTPUT PARAMETER MsgDesc AS MEMPTR NO-UNDO. /*message descriptor*/ DEFINE INPUT-OUTPUT PARAMETER PutMsgOpts AS MEMPTR NO-UNDO. /*Options that control the action of MQPUT*/ DEFINE INPUT PARAMETER BufferLength AS LONG NO-UNDO. /*Length in bytes of the Buffer area*/ DEFINE INPUT PARAMETER Buffer_ AS CHAR NO-UNDO. /*Area to contain the message data*/ DEFINE OUTPUT PARAMETER CompCode AS LONG NO-UNDO. /*Completion code*/ DEFINE OUTPUT PARAMETER Reason AS LONG NO-UNDO. /*Reason code qualifying CompCode*/ END PROCEDURE. /*close*/ PROCEDURE MQCLOSE EXTERNAL "{&DLL-LIB}" CDECL PERSISTENT: DEFINE INPUT PARAMETER Hconn AS LONG NO-UNDO. /*Connection handle*/ DEFINE INPUT-OUTPUT PARAMETER Hobj AS LONG NO-UNDO. /*Object handle*/ DEFINE INPUT PARAMETER OPTIONS_ AS LONG NO-UNDO. /*Options that control the action of MQCLOSE*/ DEFINE OUTPUT PARAMETER CompCode AS LONG NO-UNDO. /*Completion code*/ DEFINE OUTPUT PARAMETER Reason AS LONG NO-UNDO. /*Reason code qualifying CompCode*/ END PROCEDURE. /*disconnect*/ PROCEDURE MQDISC EXTERNAL "{&DLL-LIB}" CDECL PERSISTENT: DEFINE INPUT-OUTPUT PARAMETER Hconn AS LONG. /*Connection handle*/ DEFINE OUTPUT PARAMETER CompCode AS LONG. /*êîä âûïîëíåíèÿ*/ DEFINE OUTPUT PARAMETER Reason AS LONG. /*Reason code qualifying CompCode*/ END PROCEDURE. ASSIGN QMgrName = "UNIQM". /*Connect to certain queue manager*/ RUN MQCONN (QMgrName, OUTPUT Hconn, OUTPUT CompCode, OUTPUT Reason). IF ((CompCode = {&MQCC_OK} ) AND (Reason = {&MQRC_NONE})) THEN DO: MESSAGE "+++ MQCONN() ended OK!" VIEW-AS ALERT-BOX. END. ELSE DO: /* report reason and exit */ MESSAGE "--- MQCONN() ended with Completion Code " (IF CompCode = -1 THEN "MQCC_UNKNOWN" ELSE (IF CompCode = 0 THEN "MQCC_OK" ELSE (IF CompCode = 1 THEN "MQCC_WARNING" ELSE "MQCC_FAILED"))) "~nReason code " STRING(Reason) VIEW-AS ALERT-BOX. LEAVE. END. /*Open a query*/ RUN MQOPEN (HConn, INPUT-OUTPUT ObjDesc, /*{&MQOO_INPUT_EXCLUSIVE},*/ {&MQOO_OUTPUT}, OUTPUT Hobj, OUTPUT CompCode, OUTPUT Reason).

Continue reading...
 
Status
Not open for further replies.
Top