View previous topic :: View next topic
|
Author |
Message |
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Hi
I am trying to pass a data to a called prorgam like follows
Code: |
Call 'Adddata' using MsgBuffer,
by Content tag,
by reference return-data,
by Content length of return-data,
End-call.
|
This program Adddata adds the data to MQ which sends it to another application.
I have defined Return-data as x(18200) which is an array of a copybook, which occurs 50 times (50*364).
I am only populating 16 occurrences , but I send whole 18200 bytes, I need to send only (16 * 364 = 5628 bytes).
How can I achieve this to send only few occurrence, whatever contains data and leave the trailing spaces.
Regards
AMit |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Firstly, get rid of the pointless noise, and line things up:
Code: |
Call 'Adddata' using by reference
MsgBuffer
by Content
tag
by reference
return-data
by Content
length of
return-data |
Nothing to trip you up now just by you getting it wrong when you don't even need it. Of course, you could have absurd site-standards :-)
If you are passing data to the subprogram using the name "return-data", don't you think that is confusing?
Enterprise COBOL (nor any other IBM COBOL, and perhaps not any COBOL) doesn't "pass" data. It just passes the address of the start of the data.
So if you want to tell the subprogram how long the data is, you have to do that yourself. Oh, look! Your fourth parameter? Instead of LENGTH OF, you need to calculate a value which is "LENGTH OF table-item multiplied by number of items". |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
I send whole 18200 bytes, I need to send only (16 * 364 = 5628 bytes). |
You totally misunderstand how passing data to subprograms works in COBOL. As Bill pointed out, what actually goes to the subprogram is the address of the first byte of data; whether your subprogram uses 18200 or 5628 or some other number of bytes of data starting at that location is irrelevant. |
|
Back to top |
|
|
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Hi Robert
Thanks for that. I understand that now. But the program where I pass this data is a generic program to process data from many sources.
And return-data is a copybook of length 364 repeated 50 times.I can't change called program. I need to send only some occurrences of return-data. I tried sending calculated length as last parameter (which is received as length) but called program returns s0c1. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Although I'm obviously well down on your list of helpful, you have defined the field you use as the final parameter incorrectly. It was previously a "LENGTH OF" special register, and you have now given it an incorrect definition or size (likely, both) and then wondered why the CALLed program doesn't work.
When you get a problem, you must look into it for longer than it takes to just paste-up a question here. |
|
Back to top |
|
|
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Thanks Bill. I have now had a look at the length defined and it was not defined correctly. Changed it to COMP and the program worked. Yeah I will take a longer look at the code before posting. |
|
Back to top |
|
|
|