Previous Topic: Usage NotesNext Topic: Profile Options


Examples

Examples of the DB-EXIT facility are shown and described below.

Example 1

 PATHAA DEPARTMENT
 PATH-- EMPLOYEE

 017    CALL DB-EXIT ('FIRST' 'EMPLOYEE ' 'DEPT-EMPLOYEE ')
 017    RELS
 017030 CALL DB-EXIT ('NEXT' 'EMPLOYEE ' 'DEPT-EMPLOYEE ')
 017    IF IDMS-STATUS EQ '0307' DROP
 017    RELS
 017    B 030

The first DB-EXIT call in this example retrieves the first EMPLOYEE record that participates in a set relationship with the DEPARTMENT record currently in the input buffer. The second DB-EXIT call retrieves all remaining EMPLOYEE record occurrences in this set relationship until CA Culprit encounters an IDMS-STATUS code that indicates an end-of-set condition.

The first DB-EXIT call generates an OBTAIN FIRST EMPLOYEE WITHIN DEPT-EMPLOYEE command; the second call generates an OBTAIN NEXT EMPLOYEE WITHIN DEPT-EMPLOYEE command. ARG1 specifies the type of call enclosed in single quotation marks. ARG2 specifies the record name EMPLOYEE followed by a single space and enclosed in single quotation marks; ARG3 specifies the set name DEPT-EMPLOYEE followed by a single space and enclosed in single quotation marks.

Example 2

PATH-- EMPLOYEE
017    MOVE 'CALC' TO ARG1
017    MOVE 'EMPLOYEE ' TO ARG2
017    MOVE EMP-ID-0415 TO ARG3
017    MOVE '0301' TO ARG4
017    MOVE 4 TO ARG5
017    B    DB-EXIT
017    RELS
017    IDMS-STATUS EQ '0000'  STOP-RUN

The only PATH parameter specified for this database access run is a dummy path parameter that specifies the EMPLOYEE record. Since the code does not include an automatic retrieval PATH parameter, the code must include a STOP-RUN command in order to terminate processing for the run.

In this example, the DB-EXIT call executes a series of MOVE commands followed by a branch to DB-EXIT. ARG1 generates an OBTAIN CALC EMPLOYEE command. ARG2 specifies the EMPLOYEE record name followed by a space. ARG3 specifies the name of the CALC-key field for the EMPLOYEE record. ARG4 specifies the value of the EMP-ID-0415 field, which is defined as numeric, enclosed in single quotation marks; ARG5 specifies the length, in bytes, of the EMP-ID-0415 field.

Example 3

017100 CALL DB-EXIT ('CALC' 'EMPLOYEE ' EMP-ID-0415 '0301' 4)
017    IDMS-STATUS NE '0000'  DROP
017    RELS
017    MOVE  'DUP' TO ARG1
017200 B DB-EXIT
017    IDMS-STATUS NE '0000'  DROP
017    RELS
017    B 200

This segment of code includes two DB-EXIT requests. The first DB-EXIT request returns an EMPLOYEE record occurrence that has a CALC-key value equal to 0301. The second DB-EXIT request issues an OBTAIN DUPLICATE EMPLOYEE command, which returns any other EMPLOYEE records with a CALC-key value equal to 0301.

The argument values for both DB-EXIT requests are the same except for the value of ARG1. A MOVE statement changes the value of ARG1 from CALC to DUP before process statement 200 is executed.

Example 4

 PATH-- EMPLOYEE
 010    EMP-ID  '0301'
 010    EMP-SS-NUM  '123456789'

 017010 CALL US43 (EMP-ID,EMP-ID-0415,4)
 017    CALL DB-EXIT ('CALC','EMPLOYEE ',EMP-SS-NUM-0415,
*                      EMP-SS-NUM,13)

The CALC key for the EMPLOYEE record consists of two fields: EMP-ID-0415 and EMP-SS-NUM-0415. The call to procedure module US43 moves the value in work field EMP-ID to EMP-ID-0415. The DB-EXIT call generates an OBTAIN CALC EMPLOYEE command. Arguments 3 through 5 move the value in EMP-SS-NUM to the remaining partial key field, EMP-SS-NUM-0415.

Example 5

 PATH-- JOB
 010    WORK-FIELD  'DATA ENTRY CLERK    '

 017    CALL DB-EXIT ('FORMAT-6','JOB ','JOB-TITLE-NDX ',
*                     TITLE-0440,WORK-FIELD,20)
 017    RELS
 017    IDMS-STATUS EQ '0000' STOP-RUN

The DB-EXIT call generates an OBTAIN JOB WITHIN JOB-TITLE-NDX USING TITLE-0440 database retrieval command. In this example, ARG2 specifies the name of the indexed record, ARG3 specifies the name of the indexed set, and ARG4 identifies the name of the index key. ARG5 identifies an alphanumeric work field that contains the value of the indexed field; the 20-byte length of the work field (ARG5) is equal to the length of the index key.

Example 6

 PATHAA EMPLOYEE
 PATH-- DEPARTMENT

 017    CALL DB-EXIT ('OWNER' 'DEPARTMENT ','DEPT-EMPLOYEE ')

Each time CA Culprit executes the DB-EXIT call, it retrieves a DEPARTMENT record occurrence that is the owner record of the EMPLOYEE record occurrence currently in the input buffer.

Example 7

 PATHAA EMPLOYEE
 PATH-- JOB

 017    CALL DB-EXIT ('DBKEY' 'JOB ' X'01256902')

The DB-EXIT call generates an OBTAIN JOB DBKEY command. ARG1 specifies the type of call enclosed in single quotation marks; ARG2 specifies the record name JOB followed by a space and enclosed in single quotation marks. ARG3 specifies the db-key of the record to be retrieved as a hexadecimal literal. The first three bytes of the literal specify the page number, 75113, and the last two bytes specify the line number, 2.

Example 8

 PATH-- EMP-JOB-LR WHERE EMP-ID-0415 EQ EMP-ID-0415(1)
 GW0    INDEX
 GWO    EMP-ID.4 0301 0091 0054 0000

 017010 INDEX + 1 INDEX
 017    EMP-ID.INDEX EQ 0000 STOP-RUN
 017020 CALL DB-EXIT ('SET-VALUE' EMP-ID-0415 EMP-ID.INDEX
*                     4 '2')
 017    CALL DB-EXIT ('LR-NEXT' 'EMP-JOB-LR ')
 017    LR-STATUS EQ 'LR-NOT-FOUND' 010
 017    RELS
 017    B 020

This example includes two DB-EXIT calls. The first call instructs CA Culprit to set a value in the EMP-ID-0415 field in the input buffer. This field is qualified by a 1 in the WHERE clause on the dummy PATH parameter. The value set in the field is one of the values specified for global work field EMP-ID.

The second DB-EXIT call instructs CA Culprit to obtain the logical record occurrence that specifies an employee id value equal to the value in the input buffer. CA Culprit continues to retrieve the next logical record until it encounters LR-NOT-FOUND. The run terminates when the value of EMP-ID is 0000.