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
 

 

Confusion while passing data to a called program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
amitc23

New User


Joined: 05 Nov 2014
Posts: 78
Location: India

PostPosted: Mon Mar 07, 2016 12:36 pm    Post subject: Confusion while passing data to a called program
Reply with quote

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
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Mar 07, 2016 12:50 pm    Post subject: Reply to: Confusion while passing data to a called program
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Mon Mar 07, 2016 6:35 pm    Post subject:
Reply with quote

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
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 78
Location: India

PostPosted: Tue Mar 08, 2016 2:17 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Mar 08, 2016 3:10 pm    Post subject: Reply to: Confusion while passing data to a called program
Reply with quote

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
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 78
Location: India

PostPosted: Tue Mar 08, 2016 4:17 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Unwrap the data based on delimiter X'25' bhavana yalavarthi DFSORT/ICETOOL 22 Fri Dec 09, 2016 10:25 am
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm


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