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

Calling a PL/I module thru pointer


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Revathy Mourouguessane

New User


Joined: 25 Jul 2012
Posts: 5
Location: INDIA

PostPosted: Fri Aug 03, 2012 5:10 pm
Reply with quote

Hi,

I wanted to call a PL/I main module(REBB001) from anther PL/I main module(REBB0000). The call is getting thru but the called module has junk values passed.

This is how the piece of code looks like:

REBB0000 - Calling module:
DCL REBB001 EXTERNAL ENTRY(PTR);

#INCLUDE REIXXXX3 /* include for input */
#INCLUDE REIXXXX4 /* include for output */

DCL 1 REBB001_IN unaligned LIKE RE_INPUT;
DCL 1 REBB001_OUT unaligned LIKE RE_OUTPUT;

DCL 1 COMMAREA_REBB001 PTR;
DCL 1 REBB001_PTR BASED(COMMAREA_REBB001),
3 REBB001_IN_PTR PTR INIT(ADDR(REBB001_IN)),
3 REBB001_OUT_PTR PTR INIT(ADDR(REBB001_OUT));

Assigning value to input variables
REBB001_IN.xxxxxx = 'VVVV'

CALL REBB001(COMMAREA_REBB001);

REBB001 - Called Module
REBB001: proc(comm_ptr) options(main, reenterant);

DCL 1 COMM_ptr PTR;
DCL 1 REBB001_PTR BASED(COMM_ptr),
3 REBB001_IN_PTR PTR,
3 REBB001_OUT_PTR PTR;

#INCLUDE REIXXXX3 /* include for input */
#INCLUDE REIXXXX4 /* include for output */

DCL 1 INPUT UNALIGNED BASED(REBB001_IN_PTR) LIKE RE_INPUT;

I get junk value in input. Could you explain me why?

Thanks!
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Aug 03, 2012 6:31 pm
Reply with quote

I do not see where you are assigning any value (let alone a valid one) to COMMAREA_REBB001. Under those circumstances, you'll naturally have invalid data in the called module.
Back to top
View user's profile Send private message
Revathy Mourouguessane

New User


Joined: 25 Jul 2012
Posts: 5
Location: INDIA

PostPosted: Fri Aug 03, 2012 7:09 pm
Reply with quote

Thank you for response.

Could you let me know the changes in called module to get value in calling module, as the structure of calling module cannot be changed.

I tried many option:

DCL 1 REBB001_PTR,
3 REBB001_IN_PTR PTR INIT(ADDR(REBB001_IN)),
3 REBB001_OUT_PTR PTR INIT(ADDR(REBB001_OUT));
DCL 1 COMMAREA_REBB001 PTR INIT(REBB001_PTR);

CALL REBB001(COMMAREA_REBB001);

(OR)

DCL 1 REBB001_PTR,
3 REBB001_IN_PTR PTR INIT(ADDR(REBB001_IN)),
3 REBB001_OUT_PTR PTR INIT(ADDR(REBB001_OUT));
DCL 1 COMMAREA_REBB001 PTR BASED(REBB001_PTR);

CALL REBB001(COMMAREA_REBB001);

(OR)

CALL REBB001(CALL REBB001);

None is working...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Aug 03, 2012 7:15 pm
Reply with quote

Quote:
Could you let me know the changes in called module to get value in calling module, as the structure of calling module cannot be changed.

Akatsukami,

welcome to friday and the world of remedial schooling!
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Aug 03, 2012 7:55 pm
Reply with quote

Revathy Mourouguessane wrote:
Thank you for response.

Could you let me know the changes in called module to get value in calling module, as the structure of calling module cannot be changed.

Strange, as the changes that you indicate as trying are changes to the calling module; perhaps your terminology is confused.

Fortunately, what you want is simple:
Code:
DCL 1 REBB001_PTR,
3 REBB001_IN_PTR PTR INIT(ADDR(REBB001_IN)),
3 REBB001_OUT_PTR PTR INIT(ADDR(REBB001_OUT));
DCL COMMAREA_REBB001 PTR INIT(ADDR(REBB001_PTR));

CALL REBB001(COMMAREA_REBB001);

Note that this means that you'll have two levels of indirection to access REBB001_IN and REBB001_OUT.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Aug 03, 2012 7:59 pm
Reply with quote

Hello

Quote:
Could you let me know the changes in called module to get value in calling module, as the structure of calling module cannot be changed.
If new info will be "passed" to the called module, there WILL be changes to the calling module.

This almost sounds like a requirement for the never implemented COME FROM (kinda the opposite of a GO TO).

If the caller is not changed, how would you propose making the new value available to the called code?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Aug 03, 2012 8:54 pm
Reply with quote

dick scherrer wrote:
This almost sounds like a requirement for the never implemented COME FROM (kinda the opposite of a GO TO).

Actually, I did write a preprocessor for COME FROMs in PL/I on the VAX-11/780 about 30 years ago. Pretty useless, granted, but I had some free time... icon_smile.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Aug 04, 2012 3:58 am
Reply with quote

Why does the called module have a PROC OPTION of MAIN? It is NOT amain module. Your calling module is the main module (or, at least, the originally invoked module is MAIN)
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Aug 04, 2012 6:38 am
Reply with quote

I guess you're under the impression that you can save overhead, by passing an address, because the data itself is passed to the called sub-program?

IBM standard linkage, used by all HLL's (under the covers), the calling module/program always passes the address (or addresses) of the data in a Parmlist off R1 and the called module/sub-program obtains addressability by addressing this Parmlist (off R1 as well) when it receives control.

Why get cute and make things complicated?

This is basic knowledge which should be known by any Software Engineer. icon_rolleyes.gif
Back to top
View user's profile Send private message
Revathy Mourouguessane

New User


Joined: 25 Jul 2012
Posts: 5
Location: INDIA

PostPosted: Mon Aug 06, 2012 11:06 am
Reply with quote

Hi,

Thanks for the response.

Its my mistake that I have confused calling program with called program.

The below change didn't work:
Calling program:
DCL 1 REBB001_PTR,
3 REBB001_IN_PTR PTR INIT(ADDR(REBB001_IN)),
3 REBB001_OUT_PTR PTR INIT(ADDR(REBB001_OUT));
DCL COMMAREA_REBB001 PTR INIT(ADDR(REBB001_PTR));

CALL REBB001(COMMAREA_REBB001);

Called module:
REBB001: proc(comm_ptr) options(fetchable, reenterant);

DCL 1 COMM_ptr PTR;

DCL 1 REBB001_PTR BASED(COMM_ptr),
3 REBB001_IN_PTR PTR,
3 REBB001_OUT_PTR PTR;

#INCLUDE REIXXXX3 /* include for input */
#INCLUDE REIXXXX4 /* include for output */

DCL 1 INPUT UNALIGNED BASED(REBB001_IN_PTR) LIKE RE_INPUT;

And the reason why we need to pass thru pointer is that the internal testing tool expects a pointer as input.

Thanks!
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Mon Aug 06, 2012 12:19 pm
Reply with quote

Revathy Mourouguessane wrote:

The below change didn't work:

That's too bad. If you had shown us the error messages, we'd have something to work with; as it is, we can only express sympathy.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Aug 06, 2012 12:42 pm
Reply with quote

Reenterant? Check your spelling....

Oy Vey icon_rolleyes.gif
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 -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts Calling an Open C library function in... CICS 1
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts calling a JCl inside a JCL JCL & VSAM 3
Search our Forums:

Back to Top