Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

dynamically set buffer length

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Java & MQSeries
View previous topic :: :: View next topic  
Author Message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Thu Apr 07, 2011 2:27 am    Post subject: dynamically set buffer length
Reply with quote

Is there a way in Enterprise COBOL to dynamically set the buffer length for a PUT?
Here's what i am trying to do. I want to write a callable subroutine that just does a PUT1.
The subroutine will can be called by many other COBOL programs that will all have different lengths for the message they want to PUT.
I don't want to pick some arbitrary size for the buffer-length. Because as soon as I do someone will exceed it.
I could have them pass in the size of the message they are putting but how does that help?
I will have a PIC in the linkage section that is of some size to hold the message they passed. Can I max out an 01 in the linkage at 16MB and then somehow redefine it to be what they passed in?
I know how to dynamically allocate storage using CEEGTST but still I have to have something of a set PIC defined in that linkage.
Any thoughts?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 07, 2011 12:37 pm    Post subject:
Reply with quote

originator of the message knows the length - it should be passed.

you can put from linkage, so your cobol routine does not need to establish working-storage or dynamic storage -
that is a waste, not only do you double the storage requirements of the task,
there is the move involved.
mqs does a move anyway, why add an extra move.

define your linkage to the max allowable definition.
then you will only have to change when you change compilers.
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Fri Apr 08, 2011 11:45 pm    Post subject:
Reply with quote

ok. so if I have this in the LINKAGE

01 WS-LINKAGE-DATA.
05 WS-MESSAGE PIC X(100000000).

because the maxmessage length is 100MB and the calling program only passes in a 1000 bytes message through the linkage and then I do a PUT aren't I putting the 1000 bytes plus the rest as spaces??
This seems wasteful too.
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Sat Apr 09, 2011 12:04 am    Post subject:
Reply with quote

Plus it doesn't work I get a 2030 if the buffer-length is different than the queue length
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Sat Apr 09, 2011 12:05 am    Post subject:
Reply with quote

Sorry that should have read

Plus it doesn't work I get a 2030 if the buffer-length variable is different than the actual length of what you put in the buffer
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Apr 09, 2011 11:19 am    Post subject:
Reply with quote

1. I said that the originater (CALLer of your module) kinows the length of the message that was built.
The length of the message and the message should be part of your linkage and the CALLer's USING parms.

2. The mqs parms include
  • message length
  • buffer length
  • address of message/message
parms
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Mon Apr 11, 2011 7:04 pm    Post subject:
Reply with quote

OK I tried this. The CALLer of the module had this working storage:

01 WS-LINKAGE-DATA.
05 WS-LENGTH PIC 9(08).
05 WS-MESSAGE PIC X(20).

And the module has this linkage

01 WS-LINKAGE-DATA.
05 WS-LENGTH PIC 9(08).
05 WS-MESSAGE PIC X(100000000).

Then my put looks like this
ALL 'MQPUT1' USING PUT-HCONN
OBJECT-DESCRIPTOR
MESSAGE-DESCRIPTOR
PMOPTIONS
PUT-BUFFER-LENGTH
WS-MESSAGE(1:PUT-BUFFER-LENGTH)
PUT-COMPCODE
PUT-REASON.

The problem with this is that if you DISPLAY WS-MESSAGE when you start up the program, what I see in there is a 20 byte message and then a bunch of garbage. It looks like this (Bold text is the actual message):

WS-MESSAGE = PO NUMBER 1234567890
LICENSED MATERIALS - PROPERTY OF IBM5655-DB2(C) COPYRIGHT IBM CO
OVERNMENT USERS RESTRICTED RIGHTS - USE, DUPLICATION OR DISCLOSURE RESTRICTED BY
. DSNAA 11/22/9615.57 0 00 DSNELI 96.327 .} 00 .}
- AM {<j {< \{<;\AM -- N Aq- {bN - A {b 0- - - / & &K K 0
{ K A.K A} 0A K AyK cA K A K A K A K A{K A.K `
AkK A K Am& z A*K Ao 0/@j /q A!K A }} m /q A j
CIB / 51006SQLCA hDSNELI E 00 IGZEBST
N } D# { }* 0 { 0{ N } Dc {> 0 { 0{



However this does work. But I don't know how I feel about the garbage being in there. Seems like a bad idea to have that in there. The only way to get rid of it it to initialize WS-MESSAGE but then you've wiped it out.
Surely I am not the first person to attempt this? There has to be a way that is cleaner
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Mon Apr 11, 2011 7:05 pm    Post subject:
Reply with quote

Above, one of your mq params was Address. Do you mean pass a POINTER?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Apr 11, 2011 7:39 pm    Post subject:
Reply with quote

1. yes, this has been done more than once.

2. what are you populating PUT-BUFFER-LENGTH with? it is for a put operation, not really used. it is a get operation data-item that tells
mqs when it may overflow with a message. You should be more interested in providing mqs with the actual message length.....

3. what is this: WS-MESSAGE(1:PUT-BUFFER-LENGTH)??
There is no need to provide reference modification. there is a parm for mqs that tells it what the length of the message is.

4. why are you using an unsigned display numeric to pass 'pure numeric' data.

5. why are you worried about the data in the message area beyond the message length? and what is not clean??? you have defined a meg of memory as a potential USING parm. mqs, and everybody else is only worried about the message-length portion of the message.
you want to display a clean message... display ws-message(1:msg-length)

as far as passing pointers or addresses or whatever,
you will have to refer to the MQS documentation to determine what the different parms are and how and with what are they populated.
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Mon Apr 11, 2011 7:45 pm    Post subject:
Reply with quote

Quote:
what are you populating PUT-BUFFER-LENGTH with?


I am moving WS-LENGTH to PUT-BUFFER-LENGTH

Quote:
what is this: WS-MESSAGE(1:PUT-BUFFER-LENGTH)

When I wasn't doing ref mod I was getting a 2030 error cause the queue channel was only set up for 4MB. But it sounds like you are saying this shouldn't happen. That MQ will truncate the BUFFER based on the PUT-BUFFER-LENGTH. Is that correct?

Quote:
why are you using an unsigned display numeric to pass 'pure numeric' data.

I made the WS-LENGTH the same data type as BUFFER-LENGTH. Is this not necessary?

Quote:
why are you worried about the data in the message area beyond the message length?


Because I am seeing garbage get passed into my module. That does not seem like a good thing?

I appreciate your help. Gotta get this figured out for a demo soon!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Apr 11, 2011 8:45 pm    Post subject:
Reply with quote

1. been a while since i coded mqs, but there is definitely two distinct parms:
buffer-length
message-length.

2. i have never know ibm to use display numeric variable for a numeric field.
usually they are halfword, or word signed binary:

pic s9(9) comp. or pic s9(4) comp.


3. your phrasing 'seeing garbage get passed into my module.' portends a problem of understanding.

what you see, is the calling modules area, and that you can access it,
means your ss-range compiler options are set to off, which means you can walk on the area of other modules. in development, this is not a good idea. but for purposes of your demo, it does not matter.

in case you do not have it: this is a link to the WebSphere MQ Library
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Tue Apr 12, 2011 1:50 am    Post subject:
Reply with quote

Well, I tried using compiler option SSRANGE. It still picked up other areas of the module. I am not sure why.
I appreciate your help. it does work, I don't really think that it picking up other parts of the module is a problem although it bugs me that when you display the message for debugging there is additional stuff in there. That could confusing to someone who didn't know why.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 12, 2011 2:48 am    Post subject:
Reply with quote

you have a linkage pointer (using WS-LINKAGE-DATA)
which addresses 100000000 + 8 bytes of someone else's storage.

you have a length. when you do the display,
DISPLAY WS-LINKAGE-DATA(1:WS-LENGTH + 8)
and you will only display
  • the length field (a length of 8)
  • and the message from WS-LINKAGE-DATA for the length of WS-LENGTH
.

or you could have two displays:
Code:
DISPLAY 'LENGTH  : ' WS_LENGTH
DISPLAY 'MESSAGE : ' WS-MESSAGE(1:WS-LENGTH)


Though I would have a working storage field, binary s9(4) comp,
populate it with WS-LENGTH,
and replace WS-LENGTH in the reference modification in the display of the message with the COMP field.
Back to top
View user's profile Send private message
Susan Talbot

New User


Joined: 17 Dec 2010
Posts: 36
Location: KY

PostPosted: Tue Apr 12, 2011 7:01 pm    Post subject:
Reply with quote

I tried the SSRANGE option and it didn't seem to work although I will ask someone who works on mainframe tech.
The program seems to work fine now and do what I need it to do. Really appreciate the help.
I was worried about other developers wondering what was in the message if they tried to debug but I am sure they will know. I will put a Display in there using ref mod like you show above and it should be ok
Thank you again
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 12, 2011 7:21 pm    Post subject:
Reply with quote

always happy to help bluegrass.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Java & MQSeries All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts how to DYNAMICALLY write sort cond to... mohamedmubee COBOL Programming 13 Fri Aug 26, 2016 11:46 pm
No new posts PL/I: opening file w/ dynamically det... Sam Dodgers PL/I & Assembler 6 Wed Jul 27, 2016 4:05 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us