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
 

 

Calling a PL/I module thru pointer

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: Calling a PL/I module thru pointer
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: 1738
Location: Bloomington, IL

PostPosted: Fri Aug 03, 2012 6:31 pm    Post subject:
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    Post subject: Reply to: Calling a PL/I module thru pointer
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    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Fri Aug 03, 2012 7:55 pm    Post subject: Re: Reply to: Calling a PL/I module thru pointer
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

Site Director


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

PostPosted: Fri Aug 03, 2012 7:59 pm    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Fri Aug 03, 2012 8:54 pm    Post subject:
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: 1712
Location: UK

PostPosted: Sat Aug 04, 2012 3:58 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Aug 04, 2012 6:38 am    Post subject: Reply to: Calling a PL/I module thru pointer
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    Post subject: Reply to: Calling a PL/I module thru pointer
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: 1738
Location: Bloomington, IL

PostPosted: Mon Aug 06, 2012 12:19 pm    Post subject: Re: Reply to: Calling a PL/I module thru pointer
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Aug 06, 2012 12:42 pm    Post subject: Reply to: Calling a PL/I module thru pointer
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Copybook structure in Load module Vai123 COBOL Programming 7 Fri Sep 16, 2016 8:29 pm
No new posts "DFSRRC00 vs IKJEFT01" for ... arunsoods All Other Mainframe Topics 5 Fri Aug 12, 2016 9:54 pm
No new posts How to get the program name of callin... pkmurali COBOL Programming 8 Mon Aug 01, 2016 3:36 am
No new posts Calling Cobol DB2 program from a cobo... nkjain87 DB2 2 Thu Jul 21, 2016 5:12 pm
No new posts Search a Load Module sreekanth1984 TSO/ISPF 8 Tue Jun 07, 2016 8:45 pm


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