Finding the z/OS Sysname in CICS

Today I’ve got a simple but neat little tip to share. Have you ever had a need to know which z/OS system your CICS program is running in? I found myself in that situation today, needing a way to programmatically set the hostname in the URL in a CICS web application. The CICS web application could be running in any LPAR. The z/OS system running in each of our LPAR’s has a unique sysname, so if I could access that, I could determine the hostname for that z/OS.

Looking in SYS1.MACLIB(CVT), we see that z/OS has a control block called the CVT (Communications Vector Table) that contains the sysname 340 bytes into it. In the comments at the top of that member, we learn that there is a pointer to the CVT in the PSA (Prefixed Save Area) x’10’ bytes into it. The PSA is easy to find – it is at address 0. So, armed with this info, I wrote the sample code below, which you are welcome to use or incorporate into your own project. If you use this code, just define a PPT for it (if you do not use autoinstall for programs) and point a tranid to the program.

IDENTIFICATION  DIVISION.
PROGRAM-ID.     CVTTEST.

ENVIRONMENT  DIVISION.
DATA  DIVISION.
WORKING-STORAGE  SECTION.

01   WS-PSA-POINTER.
10   PSA-PTR-PIC9        PIC S9(8) COMP-5 VALUE  0.
10   PSA-PTR             REDEFINES PSA-PTR-PIC9 POINTER.

01   SEND-AREA.
10   FILLER              PIC X(1)  VALUE SPACE.
10   FILLER              PIC  X(11) VALUE 'CVTSNAME = '.
10   SA-CVTSNAME         PIC X(8)  VALUE  SPACES.

LINKAGE  SECTION.

01   PSA.
10   FILLER              PIC  X(16).
10   CVT-PTR             POINTER.

01   CVT.
10   FILLER              PIC  X(340).
10   CVTSNAME            PIC  X(8).

EJECT

PROCEDURE  DIVISION.

100-MAINLINE.

SET ADDRESS OF PSA TO  PSA-PTR.
SET ADDRESS OF CVT TO  CVT-PTR.

MOVE CVTSNAME TO  SA-CVTSNAME.

EXEC CICS SEND  FROM(SEND-AREA)
LENGTH(LENGTH OF  SEND-AREA)
END-EXEC.

999-RETURN.

EXEC CICS  RETURN
END-EXEC.

GOBACK.
Advertisements

2 responses to “Finding the z/OS Sysname in CICS

  1. Good tip – I came across another variation which eliminates the need to define the PSA pointer area in Working Storage. This is achieved by changing:
    SET ADDRESS OF PSA TO PSA-PTR.
    to
    SET ADDRESS OF PSA TO NULL.

    • Hi, Tom.

      Thanks for checking out the blog. Sure enough, what you listed will work as well. Null address, zero address, both end up at the same place! Thanks for sharing!

      Steve

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s