COBOL TIPS #17
by
Shawn M. Gordon
President S.M.Gordon & Associates
In my last column I mentioned a product from Computer Associates called CA-Realia that was a visual COBOL environment rather like Visual Basic. Well, good news, I got a copy to write a review of. I just got it installed, so I have no opinion on it yet, but look for the review around the time this column hits (could be the same issue).
I keep saying that I am out of ideas, and I keep getting information from readers of this column. I really do appreciate the input and feedback, it helps spark my imagination as well. Our tip this month comes from Jim Phillips, and is an excellent example of how and why to use the HPDEVCONTROL instrinsic. The following program will put a DDS tape drive online without having to eject and reload the tape. See listing 1 for the code;
$CONTROL USLINIT IDENTIFICATION DIVISION. PROGRAM-ID. ONLINE. AUTHOR. JIM PHILLIPS. DATE-WRITTEN. 03/21/95. DATE-COMPILED. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. HP-3000. OBJECT-COMPUTER. HP-3000. SPECIAL-NAMES. CONDITION-CODE IS C-C. INPUT-OUTPUT SECTION. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 HPDEVCONTROL-STATUS PIC S9(8) COMP. 01 HPDEVCONTROL-LDEV. 03 HPDEVCONTROL-LDEV-1 PIC X(10) VALUE "a00000007a". 03 PIC X(190) VALUE SPACES. 01 HPDEVCONTROL-ITEMNUM PIC S9(8) COMP. 01 HPDEVCONTROL-ITEM PIC S9(8) COMP. 01 STATUS-BREAK-OUT PIC S9(8) COMP. 01 FILLER REDEFINES STATUS-BREAK-OUT. 03 STATUS-1 PIC S9(4) COMP. 03 STATUS-2 PIC S9(4) COMP. PROCEDURE DIVISION. START-ONLINE. MOVE ZEROES TO HPDEVCONTROL-STATUS HPDEVCONTROL-ITEM. MOVE +100 TO HPDEVCONTROL-ITEMNUM. CALL INTRINSIC "HPDEVCONTROL" USING HPDEVCONTROL-STATUS, HPDEVCONTROL-LDEV, HPDEVCONTROL-ITEMNUM, HPDEVCONTROL-ITEM. MOVE HPDEVCONTROL-STATUS TO STATUS-BREAK-OUT. IF STATUS-1 <> ZEROES DISPLAY SPACES DISPLAY "CALLED HPDEVCONTROL WITH PARM=100, RESULT=" STATUS-1. MOVE +101 TO HPDEVCONTROL-ITEMNUM. CALL INTRINSIC "HPDEVCONTROL" USING HPDEVCONTROL-STATUS, HPDEVCONTROL-LDEV, HPDEVCONTROL-ITEMNUM, HPDEVCONTROL-ITEM. MOVE HPDEVCONTROL-STATUS TO STATUS-BREAK-OUT. IF STATUS-1 <> ZEROES DISPLAY SPACES DISPLAY "CALLED HPDEVCONTROL WITH PARM=101, RESULT=" STATUS-1. STOP RUN.
For the most part you can look this intrinsic up in the manual if you want to check the items and such. However, I think it is worth pointing out that the field HPDEVCONTROL-LDEV-1 has to be a 200 byte field, and the first 10 bytes are the significant ones. The field must be delimited with an alphabetic characters, hence the ‘a’ and the beginning and the end of the string (this is the example from the manual). The value between the ‘a’s is the logical device number of the DDS drive.
Nice, simple, straight forward, handy little utility. After Jim sent this to me it reminded me of my own adventures using the HPVOLINFO intrinsic when it first became available under MPE V Platform 2P. Now this code works on a Classic on 2P, but I can’t make any guarantees about your particular platform. You will need to verify some of the parameters. Next month I will give you a more complex example of this intrinsic.
$CONTROL USLINIT,SOURCE
IDENTIFICATION DIVISION.
PROGRAM-ID. VOLINFO.
AUTHOR. SHAWN M.GORDON.
DATE-WRITTEN. WED, NOV 18, 1992.
DATE-COMPILED.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. HP-3000.
OBJECT-COMPUTER. HP-3000.
SPECIAL-NAMES.
CONDITION-CODE IS CC.
INPUT-OUTPUT SECTION.
DATA DIVISION.
*
********************************************************
WORKING-STORAGE SECTION.
01 EDIT-LNUM PIC Z,ZZZ,ZZZ,ZZ9.
01 EDIT-SNUM PIC ZZ,ZZZ,ZZ9.
01 EDIT-STAT PIC ZZZZ9.
01 MISCELLANEOUS-DATA.
03 STATINFO PIC S9(09) COMP VALUE 0.
03 STATINFO-ARRAY REDEFINES STATINFO.
05 STAT-WORD1 PIC S9(04) COMP.
05 STAT-WORD2 PIC S9(04) COMP.
*
01 ITEMNUMS USAGE COMP.
03 ITEM14 PIC S9(4) VALUE 14.
03 ITEM16 PIC S9(4) VALUE 16.
03 ITEM22 PIC S9(4) VALUE 22.
03 ITEM24 PIC S9(4) VALUE 24.
03 ITEM30 PIC S9(4) VALUE 30.
03 ITEM32 PIC S9(4) VALUE 32.
03 ITEM40 PIC S9(4) VALUE 40.
*
01 ITEMS14.
03 TOTAL-SYSTEM PIC S9(18) COMP VALUE 0.
01 ITEMS16.
03 TOTAL-MPE PIC S9(18) COMP VALUE 0.
01 ITEMS22.
03 TOTAL-VIRTUAL PIC S9(18) COMP VALUE 0.
01 ITEMS24.
03 TOTAL-DIRECTORY PIC S9(18) COMP VALUE 0.
01 ITEMS30.
03 TOTAL-SPOOL-USED PIC S9(18) COMP VALUE 0.
01 ITEMS32.
03 TOTAL-PERM-USED PIC S9(18) COMP VALUE 0.
01 ITEMS40.
03 TOTAL-FREE-SPACE PIC S9(18) COMP VALUE 0.
*
01 VOL PIC X(26) VALUE
“%MPEXL_SYSTEM_VOLUME_SET%”.
*********************************************************
PROCEDURE DIVISION.
*
A1000-INIT.
DISPLAY SPACES.
DISPLAY ‘Begin run of VOLINFO at ‘ TIME-OF-DAY.
DISPLAY ‘Disk volume information system’.
DISPLAY ‘Copyright 1992 S.M.Gordon & Associates’.
DISPLAY ‘This will take a few minutes…’ NO ADVANCING.
DISPLAY SPACES.
DISPLAY SPACES.
CALL INTRINSIC “HPVOLINFO” USING STATINFO, \2\, VOL,
ITEM16, ITEMS16,
ITEM22, ITEMS22,
ITEM24, ITEMS24.
IF STAT-WORD1 <> 0
MOVE STAT-WORD1 TO EDIT-STAT
DISPLAY ‘INTRINSIC HPVOLINFO FAILED’
DISPLAY ‘ERROR CODE = ‘ EDIT-STAT
STOP RUN.
MOVE TOTAL-MPE TO EDIT-LNUM.
DISPLAY ‘MPE Overhead = ‘ EDIT-LNUM.
MOVE TOTAL-VIRTUAL TO EDIT-LNUM.
DISPLAY ‘Virtual Memory = ‘ EDIT-LNUM.
DISPLAY SPACES.
MOVE TOTAL-DIRECTORY TO EDIT-LNUM.
DISPLAY ‘Sectors used for Directories= ‘ EDIT-LNUM.
CALL INTRINSIC “HPVOLINFO” USING STATINFO, \2\, VOL,
ITEM14, ITEMS14,
ITEM30, ITEMS30,
ITEM32, ITEMS32,
ITEM40, ITEMS40.
IF STAT-WORD1 <> 0
MOVE STAT-WORD1 TO EDIT-STAT
DISPLAY ‘INTRINSIC HPVOLINFO FAILED’
DISPLAY ‘ERROR CODE = ‘ EDIT-STAT
STOP RUN.
MOVE TOTAL-SYSTEM TO EDIT-LNUM.
DISPLAY ‘Total System disk space = ‘ EDIT-LNUM.
MOVE TOTAL-PERM-USED TO EDIT-LNUM.
DISPLAY ‘Sectors used by Perm Files = ‘ EDIT-LNUM.
MOVE TOTAL-SPOOL-USED TO EDIT-LNUM.
DISPLAY ‘Sectors used by Spool Files = ‘ EDIT-LNUM.
MOVE TOTAL-FREE-SPACE TO EDIT-LNUM.
DISPLAY ‘Sectors still free on system= ‘ EDIT-LNUM.
DISPLAY SPACES.
DISPLAY ‘End of VOLINFO at ‘ TIME-OF-DAY.
STOP RUN.