Previous Topic: CLIST CommandsNext Topic: Commands


CLIST Examples

This section contains three CLIST examples which use a variety of CA IDMS DMLO CLIST processing features:

Note: For detailed CLIST command syntax information, see the chapter "CA IDMS DMLO Sessions"

CLIST Example #1

This CLIST deletes a specified record.

 EXEC CALCDEL record-name calc-field calc-key del-opt

 (1)  CINIT %1
 (2)  MOVE %3 to %2
 (3)  OBTAIN CALC %1
 (4)  ON ANYERR QUIT REQUESTED RECORD NOT FOUND
 (5)  IFC %NULL4
        ERASE %1
      ELSE
        ERASE %1  %4 MEMBERS
      ENDIF
 (6)  ENDC

 (1)  Conditionally BIND and load the dictionary elements of record
 (2)  Set calc-field to calc-key
 (3)  Obtain the selected record (record-name)
 (4)  If any CA IDMS error, stop execution and display 'REQUESTED RECORD NOT FOUND'.
 (5)  Determine format of CA IDMS DML ERASE command based on content (or NULL status) of del-opt.
 (6)  Required CLIST terminator
CLIST Example #2

This CLIST sweeps an area or set, looking for a field value in a record. It makes use of variable processing/prompting and conditional statements.

 EXEC SCANFOR record set/area search-fld search val max-rec

 (1)  **** SWEEP AREA OR SET LOOKING FOR FIELD VALUE IN A RECORD

 (2)  :%1 = PRIMARY RECORD NAME
      :%2 = SET OR AREA NAME TO BE SWEPT
      :%3 = FIELD NAME TO BE TESTED
      :%4 = VALUE TO LOCATE
      :%5 = MAX RECORDS TO CHECK W/O HIT
      *

 (3)  OBTAIN FIRST %1 IN %2

 (4)  REPEAT %5

 (5)  ON 0307 EXITR

 (6)  IFC %3 = %4
         EXITR
      ENDIF

 (7)  OBTAIN NEXT %1 IN %2

 (8)  ENDR

 (9)  ENDC


 (1)  COMMENT line
 (2)  Define lines (used during variable prompting)
 (3)  Start search process
 (4)  Start of loop
 (5)  On end-of-set, leave loop
 (6)  If item of interest found, leave loop
 (7)  Get next record
 (8)  Required loop terminator
 (9)  Required CLIST terminator

Note: In order for SCANFOR to work, you must establish currency for the owner if a set is selected.

CLIST Example #3

This CLIST is an example of an 'application' CLIST which incorporates nesting of CLISTs. For a specified R-CUSTOMER record, locate the first R-PO (in CUST-PO set) for which PO-DATE is a specified value. If for that record, PO-UNSHIP = 0.00, delete the record.

 EXEC DELZERO 'SMITH' 890501

 (1)  **** DELETE SELECTED R-PO RECORDS

 (2)  :%1 = R-CUSTOMER RECORD KEY (MAX 20 BYTES)
      :%2 = PO-DATE VALUE TO BE LOCATED (YYMMDD)
      *

 (3)  CINIT R-CUSTOMER

 (4)  MOVE %1 TO RCUST-KEY

 (5)  OBTAIN CALC R-CUSTOMER

 (6)  ON DB-REC-NOT-FOUND QUIT RECORD NOT FOUND

 (7)  EXEC SCANFOR R-PO CUST-PO PO-DATE %2 UNTIL

 (8)  ON DB-END-OF-SET   QUIT NO PO FOR %2

 (9)  IFC PO-UNSHIP = 0.00
         ERASE R-PO ALL MEMBERS
      ELSE
         QUIT PO HAS NONZERO UNSHIP
      ENDIF

 (10) ENDC


 (1-2) COMMENT / DEFINEs
 (3)   Ensure R-CUSTOMER field definitions loaded, and bound
 (4)   Set desired record key
 (5)   Read record of interest
 (6)   If not found, exit with message
 (7)   Call CLIST SCANFOR to walk CUST-PO set (see CLIST Example #2)
 (8)   If not found, exit with message
 (9)   Delete record or exit with message depending on PO-UNSHIP
 (10)  Required CLIST terminator