Author |
Message
|
kevinf2349 |
Posted: Mon Nov 08, 2004 12:56 pm Post subject: z/OS COBOL programming question |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
Please bear with me a littlle on this. I am not a COBOL programmer but an Assembler programming trying to assist someone with a COBOL program.
In assembler on an MQGET I would normally issue a GET with a zero length and then take the returned message length and issue a GETMAIN for that much storage. Then move the reutrned message length to the buffer length and re-issue the GET. Everytime the message returned was bigger than the buffer provided I would FREEMAIN the old and issue a GETMAIN for the new value.
Now.........
How would I do that in COBOL? Is it even possible? As I understand COBOL (and this isn't very much) but you declare map your working storage out at the start of the program, so how can you accomplish the same logic as my assembler program in cobol?
Any help will be greatly appreciated.
Kevin |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Nov 08, 2004 1:04 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I am not a COBOL programmer.
But...
I remember a COBOL programmer I used to know who would allocate one big buffer, 16MBs long, and then remap that to the appropriate structured dataset after retrieving the message.
This is sort of the opposite of your approach in assembler.
Remember that COBOL on the mainframe can't access more than 16 MBs in a single field. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kevinf2349 |
Posted: Mon Nov 08, 2004 1:34 pm Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
That is pretty much the way they are doing it but I don't think it ivery elegant and it is laying in wait for something dumb to happen (like someone sticking a message onto the queue that is bigger than the buffer specified in the program. Yuck!).
I guess we will have to live with it. Thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Nov 08, 2004 1:47 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I think if the message is too big for the buffer, then you will get an return code indicating a truncated message was retrieved.
And if someone sticks a message on the queue that is larger than 16MBs, there's no way to handle it in COBOL, so you're stuck there anyway. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
bob_buxton |
Posted: Tue Nov 09, 2004 4:27 am Post subject: |
|
|
 Master
Joined: 23 Aug 2001 Posts: 266 Location: England
|
If you are running under CICS you can use the EXEC CICS GETMAIN and FREEMAIN services to get and free buffers and the COBOL SET ADDRESS OF buffer TO ptr-variable.
You can do the same in a batch program using LE services (can't remember the names) to do the storage allocation.
It is inefficient to do a get with zero length and then do a Getmain, it is better to allocate a buffer first that is large enough for your expected message size and only deallocate and reallocate the buffer in the unlikely event that you get a truncated message reason code. _________________ Bob Buxton
Ex-Websphere MQ Development |
|
Back to top |
|
 |
|