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
 

 

Identifying programs that invoked my program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Identifying programs that invoked my program
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

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

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Oct 06, 2014 10:16 pm    Post subject: Reply to: Identifying programs
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Oct 06, 2014 11:39 pm    Post subject: Reply to: Identifying programs
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Oct 07, 2014 12:27 am    Post subject: Reply to: Identifying programs
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

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

Thanks Enrico.

I found one more link, Check if this makes it useful.
http://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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Oct 07, 2014 10:23 pm    Post subject: Reply to: Identifying programs
Reply with quote

Here's a LINK which may be what you're looking for --- the LE Traceback Facility (watch the wraparound) -

http://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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Oct 09, 2014 5:36 am    Post subject:
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    Post subject: Help needed
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Oct 20, 2014 9:40 pm    Post subject: Reply to: Identifying programs
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm


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