IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Confusion while passing data to a called program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Mon Mar 07, 2016 12:36 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Mar 07, 2016 12:50 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Mar 07, 2016 6:35 pm
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: 95
Location: India

PostPosted: Tue Mar 08, 2016 2:17 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Mar 08, 2016 3:10 pm
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: 95
Location: India

PostPosted: Tue Mar 08, 2016 4:17 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top