View previous topic :: View next topic
|
Author |
Message |
Revathy Mourouguessane
New User
Joined: 25 Jul 2012 Posts: 5 Location: INDIA
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
Revathy Mourouguessane
New User
Joined: 25 Jul 2012 Posts: 5 Location: INDIA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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... |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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. |
|
Back to top |
|
|
Revathy Mourouguessane
New User
Joined: 25 Jul 2012 Posts: 5 Location: INDIA
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Reenterant? Check your spelling....
Oy Vey |
|
Back to top |
|
|
|