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

Identifying programs that invoked my program


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

New User


Joined: 28 Jan 2010
Posts: 16
Location: Portugal

PostPosted: Mon Oct 06, 2014 10:02 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Mon Oct 06, 2014 10:12 pm
Reply with quote

see if this tricks what do you need.
www-01.ibm.com/support/knowledgecenter/#!/ssw_i5_54/apis/qwvrcstk.htm
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Mon Oct 06, 2014 10:16 pm
Reply with quote

unfortunately the link posted applies to AS/400 cobol
not to zOS cobol
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 Oct 06, 2014 11:39 pm
Reply with quote

Here's a topic.
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: Tue Oct 07, 2014 12:27 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Tue Oct 07, 2014 3:04 am
Reply with quote

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
View user's profile Send private message
Bruno Oliveira

New User


Joined: 28 Jan 2010
Posts: 16
Location: Portugal

PostPosted: Tue Oct 07, 2014 2:05 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Tue Oct 07, 2014 10:23 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Thu Oct 09, 2014 5:36 am
Reply with quote

Great!! This is helpful Bill.
Back to top
View user's profile Send private message
Bruno Oliveira

New User


Joined: 28 Jan 2010
Posts: 16
Location: Portugal

PostPosted: Mon Oct 20, 2014 8:31 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Mon Oct 20, 2014 9:40 pm
Reply with quote

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. icon_neutral.gif

HTH....
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 Error to invoke MPP program through B... IMS DB/DC 3
No new posts Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top