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: 79
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: 7315

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: 8089
Location: East Dubuque, Illinois, USA

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: 79
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: 7315

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: 79
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 SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm
No new posts NDM syntax checking without actually ... GAPX1 All Other Mainframe Topics 0 Wed Jun 07, 2017 2:36 am
No new posts Compiling program in endeavor for tra... RALAKKAL Compuware & Other Tools 4 Mon Jun 05, 2017 8:27 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am


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