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
 

 

How to get the program name of calling module in called prog

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 236

PostPosted: Mon Aug 01, 2016 3:36 am    Post subject: How to get the program name of calling module in called prog
Reply with quote

Hi All,

I have a subroutine program(called module) program B static called by many programs. Since it is a maintenance project i dont have access to pass the calling module program through calling variables, is there anyway to get the calling program name without modifying the calling program?

Thanks
Murali
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon Aug 01, 2016 4:59 am    Post subject:
Reply with quote

There has been a SHARE requirement to access this information in Enterprise COBOL for a number of years, so yours is not the first request to do this. However, since the requirement exists, obviously it cannot currently be retrieved easily.
Back to top
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 462
Location: The Universe

PostPosted: Mon Aug 01, 2016 5:30 am    Post subject:
Reply with quote

I can't think of a way to do this. You can try this.
  1. Get a load module map of the module using JCL like this -
    Code:
    //A       EXEC PGM=IMBLIST
    //SYSPRINT DD  SYSOUT=*
    //SYSLIB   DD  DISP=SHR,DSN=--your load module library--
    //SYSIN    DD  *
     LISTLOAD OUTPUT=XREF,MEMBER=--your program's load module--

  2. Part of this listing will look like this -
    Code:
    -------------------------------------------------------------------------------
          LMOD LOC  CSECT LOC    IN CSECT              REFERS TO SYMBOL  AT LMOD LO
              580       580      LOGTIME                   SMFETIME            690
              584       584      LOGTIME                   LOGTMSGS            5C0
    Look for your program in the REFERS TO SYMBOL AT LMOD column. The symbol in the IN CSECT column is usually (though not always) the calling program. Many compilers will put data (like the address of modules it is calling) in a CSECT separate from the program text. For example -
    Code:
    LMOD LOC  CSECT LOC    IN CSECT              REFERS TO SYMBOL  AT LMOD LOC
         24        24      ICH408                    ICH408D            2178
       2675       4FD      ICH408D                   ICH408               00
       271C       5A4      ICH408D                   ICH408               00 
       2728       5B0      ICH408D                   ICH408               00 
       2734       5BC      ICH408D                   ICH408               00 
       2740       5C8      ICH408D                   ICH408               00 
       274C       5D4      ICH408D                   ICH408               00 
       2758       5E0      ICH408D                   ICH408               00 
       2764       5EC      ICH408D                   ICH408               00 
       27A8       630      ICH408D                   ICH408               00 
       27B4       63C      ICH408D                   ICH408               00 
       28F0       778      ICH408D                   MINIFMT            16E8 
       2954       7DC      ICH408D                   ICH408               00 
       2994       81C      ICH408D                   QSORTL             15D0
    Figuring out relations in this kind of structure is doable, though painful.
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 01, 2016 6:53 am    Post subject:
Reply with quote

You'll have to chase control blocks for it. I wrote a callable module that did this for my last client, but

  1. I'm not at that client any more and therefore don't have access to that code, and
  2. it was in PL/I

I'll try to remember the sequence of control blocks tomorrow.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Aug 01, 2016 5:22 pm    Post subject: Reply to: How to get the program name of calling module in called prog
Reply with quote

It's been discussed before. Here, and the links within.

It is not a good idea to use this to control program logic. What do you want the program name for?
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 Aug 01, 2016 8:59 pm    Post subject:
Reply with quote

What you want is this, CEEBINT High-Level Language User Exit Interface but I guess you need modifications?
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 Aug 01, 2016 9:39 pm    Post subject:
Reply with quote

This is what I found on internet, Retrieve Call Stack (QWVRCSTK) API.
Code:
PROCESS NOMONOPRC.

* To compile:
* CRTCBLMOD CALLSTACK
* CRTPGM CALLSTACK BNDDIR(QC2LE)

IDENTIFICATION DIVISION.
PROGRAM-ID. CALLSTACK.

DATA DIVISION.
WORKING-STORAGE SECTION.
COPY QUSEC OF QSYSINC-QCBLLESRC.
COPY QWCATTR OF QSYSINC-QCBLLESRC.

01 Receiver.
05 Bytes-Returned PIC S9(9) BINARY.
05 Bytes-Available PIC S9(9) BINARY.
01 Memory-Pointer POINTER.
01 Stack-Pointer POINTER.
01 My-Name PIC X(10).

LINKAGE SECTION.
COPY QWVRCSTK OF QSYSINC-QCBLLESRC.

PROCEDURE DIVISION.
MAIN-LINE.
MOVE 0 TO Bytes-Provided OF QUS-EC.
PERFORM Get-Caller THRU Exit-Get-Caller.
STOP RUN.

Get-Caller.

* Find out how much information is available

* First initialize the Job Information structure
MOVE LOW-VALUES TO QWC-JIDF0100.
MOVE "*" TO JOB-NAME OF QWC-JIDF0100.
MOVE SPACES TO USER-NAME OF QWC-JIDF0100.
MOVE SPACES TO JOB-NUMBER OF QWC-JIDF0100.
MOVE SPACES TO INT-JOB-ID OF QWC-JIDF0100.
MOVE 1 TO THREAD-INDICATOR OF QWC-JIDF0100.

* Then call the API
CALL "QWVRCSTK" USING
BY REFERENCE Receiver,
BY CONTENT LENGTH OF Receiver,
BY CONTENT "CSTK0100",
BY REFERENCE QWC-JIDF0100,
BY CONTENT "JIDF0100",
BY REFERENCE QUS-EC.

* Allocate enough memory for the information
CALL LINKAGE PRC "malloc" USING
BY VALUE Bytes-Available OF Receiver
RETURNING Memory-Pointer.
SET ADDRESS OF QWV-CSTK0100 TO Memory-Pointer.

* Now get the information
CALL "QWVRCSTK" USING
BY REFERENCE QWV-CSTK0100,
BY CONTENT Bytes-Available OF Receiver,
BY CONTENT "CSTK0100",
BY REFERENCE QWC-JIDF0100,
BY CONTENT "JIDF0100",
BY REFERENCE QUS-EC.
* Not available for some reason?
IF ENTRY-AVAILABLE OF QWV-CSTK0100 = 0
DISPLAY "Major problem accessing call stack"

ELSE
* Display the program name
SET Stack-Pointer TO Memory-Pointer
SET Stack-Pointer UP BY ENTRY-OFFSET
OF QWV-CSTK0100
SET ADDRESS OF QWV-RCSTK-ENTRY TO Stack-Pointer
MOVE PROGRAM-NAME OF QWV-RCSTK-ENTRY TO My-Name
PERFORM TEST AFTER UNTIL PROGRAM-NAME OF QWV-RCSTK-ENTRY
NOT EQUAL My-Name
SET Stack-Pointer UP BY ENTRY-LENGTH
OF QWV-RCSTK-ENTRY
SET ADDRESS OF QWV-RCSTK-ENTRY TO Stack-Pointer
END-PERFORM
DISPLAY "My caller is: " PROGRAM-NAME
OF QWV-RCSTK-ENTRY
END-IF.

* Now free the allocated memory
CALL LINKAGE PRC "free" USING BY VALUE Memory-Pointer.
Exit-Get-Caller.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Aug 01, 2016 10:13 pm    Post subject: Reply to: How to get the program name of calling module in called prog
Reply with quote

Rohit,

That program is for iSeries again.

The CEEBINT is possible, but it is a bit blunt. There's discussion of it in another topic here, which the search should find. If COBOL can be calling CEEBINT, the exit cannot be written in COBOL (but an be PL/I, C/C++, Assembler).
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Wed Aug 03, 2016 2:06 am    Post subject:
Reply with quote

Thanks Bill. I never require to work on that but good to know.
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 How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 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 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