I tried to use Visual COBOL 2.3 to connect to IBM MQ 7.5 which is installed on the same machine (RHEL 7.2)
The sample code is from IBM MQ 7.5 sample folder and I follow IBM document (instructions) , the sample is also posted online as
www.davar.net/.../amq0put0.cbl
I setup and compile the code as these steps:
export COBCPY=/opt/mqm/inc/cobcpy64
cob64 -xtvP amq0put0.cbl -L /opt/mqm/lib64 -lmqicb_r
Everything is good, create the 64-bit executable:
[cobol@rh7 samp]$ cob64 -xtvP amq0put0.cbl -L /opt/mqm/lib64 -lmqicb_r
cob64 -C nolist -xtvP amq0put0.cbl -L /opt/mqm/lib64 -lmqicb_r
* Micro Focus COBOL V2.3 revision 000 Compiler
* Copyright (C) Micro Focus 1984-2015. All rights reserved.
* Accepted - verbose
* Accepted - reentrant
* Accepted - nolist
* Accepted - list("amq0put0.lst")
* Compiling amq0put0.cbl
* Total Messages: 0
* Data: 10608 Code: 1193
* Micro Focus COBOL Code Generator
* Copyright (C) Micro Focus 1984-2015. All rights reserved.
* Accepted - verbose
* Generating amq0put0
* Data: 10376 Code: 1950 Literals: 624
cob64: Entry points defined in module: amq0put0.o
*AMQ0PUT0
amq0put0
But when I run it, I always got this error:
MQCONN ended with reason code 000002058
2058 Queue Manager name error --http://www-01.ibm.com/support/docview.wss?uid=swg21166938
In the sample folder, there is also the C code, and executable from C code: amqsput
I use ./amqsput REQUEST_Q QM1 to test with my local queue and queue manager. no issue at all. I can send message to it.
this is how COBOL calls MQ function:
CALL 'MQCONN'
USING QM-NAME, HCONN,
COMPLETION-CODE, CON-REASON.
this is how C code to call MQ:
MQCONN(QMName, /* queue manager */
&Hcon, /* connection handle */
&CompCode, /* completion code */
&CReason); /* reason code */
I assign the same value for the first parameter in both COBOL and C (I change original COBOL to accept Queue Manager Name from console)
I do not understand why COBOL code failed, C code succeeded. both executed from the same folder.
Really appreciated for the help.
PS -- The IBM instructions for MQ development has the special part for Micro Focus COBOL. I just follow it exactly.
#IBMMQ
#VisualCOBOL