View previous topic :: View next topic
|
Author |
Message |
Bruno Oliveira
New User
Joined: 28 Jan 2010 Posts: 16 Location: Portugal
|
|
|
|
In batch, and in CICS, i need to identify the program that invoked my program.
Example:
Code: |
PROGRAM1
[...]
call PROGRAMZ
[...] |
Code: |
PROGRAM2
[...]
call PROGRAMZ
[...] |
Code: |
PROGRAMZ
[...]
what program invoke my program?
[...] |
Is there a way of getting the program that invoked PROGRAMZ without passing it by LINKAGE SECTION?
Is there some stack that I could access to get this information?
Thank you in advance.
Bruno Oliveira |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
unfortunately the link posted applies to AS/400 cobol
not to zOS cobol |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
I can only answer programmatically for a CICS environment -
If the program had been CALLED (which is NOT a CICS API), issue an ASSIGN PROGRAM API.
If the program had been accessed via a LINK or an XCTL, issue an ASSIGN INVOKINGPROG API.
In the Called Batch program, write a small Assembler program, which returns the address of the current register-savearea (R13+4). This should get you started and trace backwards from there. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Thanks Enrico.
I found one more link, Check if this makes it useful.
ibmmainframes.com/about57228.html
Btw why would like to know this information in the application program? |
|
Back to top |
|
|
Bruno Oliveira
New User
Joined: 28 Jan 2010 Posts: 16 Location: Portugal
|
|
|
|
The first objective is to automatically determine the name of the calling program instead of relying on developers.
Developers often copy & paste code from one program to another and I prefer to get the caller program from "the platform" instead of relying on developers.
The second objective is to have a secure way of authenticate programs between applications. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Here's a LINK which may be what you're looking for --- the LE Traceback Facility (watch the wraparound) -
publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/ceev11c0/1.12.1.4?ACTION=MATCHES&REQUEST=caller&TYPE=FUZZY&SHELF=cee2bkc0&DT=20110613170855&CASE=&searchTopic=TOPIC&searchText=TEXT&searchIndex=INDEX&rank=RANK&ScrollTOP=FIRSTHIT#FIRSTHIT
Plus, because it's LE, it can probably be used in both CICS and Batch.
Here's an Assembler sub-program which returns the address of the "CEECAA" (a related subject) -
Code: |
*PROCESS RENT PROGRAM IS RE-ENTRANT
***********************************************************************
* THIS PROGRAM IS 'CALLED' FROM AN 'LE-ENABLED' COBOL-PROGRAM *
* (CICS OR BATCH) AND IT RETURNS THE 'CAA' ADDRESS WHICH IS *
* ALWAYS THE CONTENTS OF R12. UPON RETURN, THE 'COBOL RETURN *
* CODE SPECIAL-REGISTER' WILL EQUAL ZERO (SUCCESSFUL) OR 16 *
* (UNSUCCESSFUL). A R13-SAVEAREA IS UNNECESSARY AS WE DON'T *
* LEAVE THIS SUB-PROGRAM EXCEPT UPON RETURNING TO THE CALLER. *
***********************************************************************
GBLC &PGMNAME SET VARIABLE
&PGMNAME SETC 'GET2CAA' SET PROGRAM-NAME
&PGMNAME CSECT BEGIN CSECT (R3)
USING *,R3 INFORM ASSEMBLER
SAVE (14,12) SAVE REGISTERS
LA R3,0(,R15) CSECT ADDRESSABILITY
L R7,0(,R1) PARM ADDRESSABIITY
LA R7,0(,R7) CLEAR TOP-BIT
ST R12,0(,R7) STORE CAA-POINTER
NI 0(R7),X'7F' CLEAR TOP-BIT
XR R15,R15 CLEAR RETURN-CODE
LTR R12,R12 VALID R12 (HOPE SO)?
JNZ RTN2CLLR YES, RETURN TO CALLER
LA R15,16 MAJOR PROBLEM
RTN2CLLR EQU *
*
RETURN (14,12),RC=(15) RESTORE REGISTERS AND RETURN
*
LTORG ,
*
YREGS , MVS REGISTER-MACRO
*
&PGMNAME AMODE 31 ,
&PGMNAME RMODE ANY ,
*
END , END 'GET2CAA'
|
Regards, |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Great!! This is helpful Bill. |
|
Back to top |
|
|
Bruno Oliveira
New User
Joined: 28 Jan 2010 Posts: 16 Location: Portugal
|
|
|
|
Hi, Bill.
First of all, thank you for your example.
We are trying to use your example in a COBOL program, but we are with some dificulties. What data area must we bind to?
Can you please give us an example of a COBOL program accessing the Assembler GET2CAA routine?
Thank you in advance.
Bruno Oliveira |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Here's a COBOL program which CALLS "GET2CAA" -
Code: |
CBL LIST,NOOFFSET,OPT(FULL),NOTEST,TRUNC(OPT),FLAG(I,I),ARITH(EXTEND)
CBL NUMPROC(NOPFD)
IDENTIFICATION DIVISION.
PROGRAM-ID. TEST2CAA.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DATA.
03 WS-GET2CAA PIC X(08).
03 WS-GET2CAA-POINTER-X.
05 WS-GET2CAA-POINTER POINTER.
03 WS-PACKED PIC 9(17) PACKED-DECIMAL.
03 WS-PACKED-V9 REDEFINES WS-PACKED
PIC 9(16)V9 PACKED-DECIMAL.
03 WS-PACKED-X REDEFINES WS-PACKED
PIC X(09).
03 WS-DISPLAY PIC 9(17).
03 WS-DISPLAY-V9 REDEFINES WS-DISPLAY
PIC 9(16)V9.
03 WS-DISPLAY-X REDEFINES WS-DISPLAY
PIC X(17).
03 WS-DISPLAY-MSG PIC X(80).
PROCEDURE DIVISION.
*
INITIALIZE WS-DATA
*
MOVE 'GET2CAA' TO WS-GET2CAA
*
CALL WS-GET2CAA USING WS-GET2CAA-POINTER
*
MOVE WS-GET2CAA-POINTER-X TO WS-PACKED-X (1:4)
MOVE WS-PACKED-V9 TO WS-DISPLAY-V9
*
INSPECT WS-DISPLAY-X CONVERTING X'FAFBFCFDFEFF'
TO 'ABCDEF'
*
MOVE 'CAA-POINTER = X''00000000'''
TO WS-DISPLAY-MSG
MOVE WS-DISPLAY-X TO WS-DISPLAY-MSG (17:8)
*
DISPLAY WS-DISPLAY-MSG
*
GOBACK.
|
Unfortunately, IBM does not offer a COBOL version of CEECAA. It's only available in Assembler.
HTH.... |
|
Back to top |
|
|
|