ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » z/OS COBOL programming question

Post new topic  Reply to topic
 z/OS COBOL programming question « View previous topic :: View next topic » 
Author Message
kevinf2349
PostPosted: Mon Nov 08, 2004 12:56 pm    Post subject: z/OS COBOL programming question Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Mon Nov 08, 2004 1:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
kevinf2349
PostPosted: Mon Nov 08, 2004 1:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Mon Nov 08, 2004 1:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
bob_buxton
PostPosted: Tue Nov 09, 2004 4:27 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » z/OS COBOL programming question
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.