Negative DBKEYs

book

Article ID: 37971

calendar_today

Updated On:

Products

CA IDMS CA IDMS - Database CA IDMS - ADS

Issue/Introduction

Question:

Is it possible to calculate the page number and line index for negative DBKEYs?

 

Answer:

DBKEYs that exceed x'7FFFFFFF' or 8,388,607 become negative in an S9(8) COMP SYNC field because the high order bit in the left most byte which represent the sign becomes a one.

An assembler program can be called from ADS or a DC or Batch Cobol program to separate the page number from the line index based on the radix.

Other Relevant Information

RECORD FORMAT that should be passed to this program:
01 DBKEY-RECORD.
02 ACCEPTED-DBKEY PIC S9(08) USAGE COMP.
02 DBKEY-PAGE PIC S9(08) USAGE COMP.
02 DBKEY-LINE PIC S9(03) USAGE COMP.
02 RADIX PIC 9(1).
02 DISP-PAGE PIC 9(08).
02 DISP-LINE PIC 9(04).

NOTE: The first three fields MUST be PIC S9(08) USAGE COMP,PIC S9(08) USAGE COMP and PIC S9(03) USAGE COMP.

After control is returned to the COBOL program or dialog :
MOVE W-DBKEY-PAGE TO DISP-PAGE
MOVE W-DBKEY-LINE TO DISP-LINE

Before linking to the program from ADS or Cobol accept the DBKEY into ACCEPTED-DBKEY and update the RADIX with 7 or 8. If the RADIX field is not updated it will default to 8.

Program source for interface with ADS and Cobol using protocols of IDMS-DC and DC-BATCH:
               PRINT ON
               SPACE 2
               COPY #CSADS
               EJECT
               PRINT ON
               PRINT GEN
               #MOPT CSECT=DBKPGM,ENV=USER
               @MODE MODE=IDMSDC
               @INVOKE PROGRAM=DBKPGM
               ENTRY DBKEP1

DBKEP1    CSECT
               USING DBKEP1,R12
               LR R12,R15
               USING CSA,R10            ESTABLISH CSA ADDRESSABILITY
               USING SYSLST,R1
               L R1,0(R1)                   LOAD OF DBKEY TO R1 (PIC S9(08) COMP)
               CLI 10(R1),X'F7'           IS THE RADIX 7?
               BE RADIX7                  YES, OTHERWISE ASSUME RADIX 8
               MVC 5(3,R1),0(R1)      MVC PAGE NUMBER TO W-DBKEY-PAGE
               MVC 9(1,R1),3(R1)       MVC LINE NUMBER TO W-DBKEY-LINE
               B EXIT
RADIX7    MVC 4(4,R1),0(R1)       MOVE DBKEY TO PAGE NUMBER
               NI PAGE+3,X'80'         ZERO OUT THE 7 BITS FOR THE RADIX
               L R3,PAGE                  LOAD PAGE NUMBER TO R3
               SRL R3,7                   SHIFT IT 7 BITS TO THE RIGHT
               ST R3,PAGE                STORE IT BACK TO PAGE
               MVC 9(1,R1),3(R1)        MOVE THE LINE NUMBER
               NI LINE+1,X'7F'          ZERO OUT THE FIRST BIT FOR THE PAGE
               EXIT #RETURN
               # BALI
               LTORG

EXIT        BR 14
SYSLST    DSECT
DBKEY     DS F
PAGE       DS F
LINE        DS H
               END 

 

The program should be preprocessed with IDMSDMLA, then assembled and linked with SYSLIN input:
//SYSLIN DD *
INCLUDE DISTLOAD(IDMS)
INCLUDE OBJECT(DBKPGM)
MODE AMODE(31),RMODE(ANY)
ENTRY DBKPGM
NAME DBKPGM(R)
/*

OBJECT is a DDNAME assigned to the link step that receives the DBKPGM object from the assembler step.

Program source for interface with Cobol using protocol of BATCH:
                ENTRY    DBKPGM
                DBKPGM DS 0H
                USING DBKPGM,12
                USING SYSLST,1
                LR 12,15          UPDATE BASE REGISTER 
                L 1,0(,1)             LOAD ADDR OF RECORD TO R1
                LA 1,0(1)           TURN OFF HIGH ORDER BIT
                CLI 10(1),X'F7'  IS THE RADIX 7? 
                BE RADIX7        YES, OTHERWISE ASSUME RADIX 8
                MVC 5(3,1),0(1)   MVC PAGE NUMBER TO W-DBKEY-PAGE
                MVC 9(1,1),3(1)  MVC LINE NUMBER TO W-DBKEY-LINE
                B    EXIT
RADIX7     MVC 4(4,1),0(1)   MOVE DBKEY TO PAGE NUMBER
                NI PAGE+3,X'80' ZERO OUT THE 7 BITS FOR THE RADIX
                L 3,PAGE LOAD PAGE NUMBER TO R3
                SRL 3,7 SHIFT IT 7 BITS TO THE RIGHT 
                ST 3,PAGE STORE IT BACK TO PAGE
                MVC 9(1,1),3(1) MOVE THE LINE NUMBER
                NI LINE+1,X'7F' ZERO OUT THE FIRST BIT FOR THE PAGE 
 EXIT        BR 14
SYSLST     DSECT
DBKEY      DS F
PAGE        DS F
LINE         DS H
END

This program must be linked in with the Cobol program and does not need to be processed by IDMSDMLA.

 

Additional Information:

CA IDMS Database Administration Guide

 

 

Environment

Release: IDADSO00100-18.5-ADS-for CA-IDMS
Component: