[USflag] The American Programmer [USflag]


Home
Books on Mainframe Programming
Mainframe Manuals and Tutorials
System Abend codes, Sqlcodes, VSAM/QSAM codes
Everything about the IBM AS/400 Midrange Computer - iSeries
Everything about CICS
Everything about COBOL
Everything about DB2 and SQL
Everything about IMS
  Books on IMS
  Manuals on IMS - Hierarchical Database Management System
  IMS/DLI and other type Abend Codes
  IMS/DLI skeleton COBOL Example program
  IMS/DLI DBD PSB Example
  IMS/DLI COBOL Example program to delete segments
  IMS/DLI COBOL program delete all root segments
  IMS/DLI COBOL Example program to insert segments
  IMS/DLI COBOL Example program to update segments
Everything about Java and JavaScript
Everything about JCL and JES
Everything about REXX
Everything about zOS, VSAM, Tivoli, Assembler
Everything about TSO, ISPF, Spufi
Site Map and Site Search

           Home   > IMS   > IMS Skeleton Program

What you need in a COBOL/IMS/DLI Program

Where do things go? What is needed in your program?
Significant areas of a Cobol program

This shows where important things go in your programs.
Everything shown is just an example. This is not a complete program. 
However, you may copy the function codes as shown.

       WORKING-STORAGE SECTION.
      *	IO AREAS DEFINED

       01  EMPLOYEE-IO-AREA.
           05 EMPLNO   PIC X(06).
           05 LASTNAME PIC X(14).
           05 FRSTNAME PIC X(10).
           05 ADDRESS  PIC X(40).
           05 SALARY   PIC 9(08).
           05 GRADE    PIC X(02).

       01  FUNCTION-CODES:
           05 GN-FUNC   PIC X(4) VALUE 'GN'.
           05 GU-FUNC   PIC X(4) VALUE 'GU'.
           05 GHU-FUNC  PIC X(4) VALUE 'GHU'.
           05 GNP-FUNC  PIC X(4) VALUE 'GNP'.
           05 GNHP-FUNC PIC X(4) VALUE 'GNHP'.       
           05 DLET-FUNC PIC X(4) VALUE 'DLET'.
           05 ROLB-FUNC PIC X(4) VALUE 'ROLB'.
           05 ISRT-FUNC PIC X(4) VALUE 'ISRT'.

      * PUT THE SSA-S HERE
       01 EMPLOYEE-SSA-UNQUAL.
           05 FILLER    PIC X(08) VALUE 'EMPLOYEE'.
           05 FILLER    PIC X VALUE SPACES.

       01 EMPLOYEE-SSA-QUAL.
           05 FILLER                  PIC X(08) VALUE 'EMPLOYEE'.
           05 FILLER                  PIC X     VALUE '('.
           05 EMPLOYEE-SSA-FIELD-NAME PIC X(08) VALUE 'EMPLNO'.
           05 EMPLOYEE-SSA-OPERATOR   PIC X(02) VALUE '= '.
      *       NOTE THE LENGTH OF THE NEXT IS OK FOR THE EMPLOYEE DATA BASE
      *       NOT NECESSARILY FOR OTHER DATA BASES
      *       YOU MUST MOVE A DATA VALUE TO IT!
           05 EMPLOYEE-SSA-DATA-VALUE PIC X(06) VALUE SPACES.
           05 FILLER                  PIC X     VALUE ')'.

 
      LINKAGE SECTION.
     * THE PCB MASKS, IN THE SAME ORDER AS THE PCB'S IN THE PSB
     * the io pcb mask is normally not needed in a batch program       
     * it is needed in OURS, because the PSB has CMPAT=YES

      01 DUMMY-IO-PCB-MASK.
           05 FILLER PIC X(10).
           05 DUMMY-IO-STATUS PIC XX.
     *     NOTE THAT IT IS TOO SHORT, BUT THAT'S OK

      01 DATABASE-PCB-MASK.
           05 DBD-NAME              PIC X(8).
           05 SEG-LEVEL             PIC X(2).
           05 DATABASE-STATUS       PIC X(2).
           05 PROC-OPTIONS          PIC X(4).
           05 RESERVED              PIC S9(5) COMP.
           05 SEGMENT-NAME-FEEDBACK PIC X(8).
           05 LENGTH-KEY-FEEDBACK   PIC S9(5) COMP.
           05 NUM-SENS-SEGS         PIC S9(5) COMP.
      *       NOTE THAT PIC X(6) IN THE FOLLOWING 
      *       WILL WORK FOR THE HOBBIES DATABASE, NOT NECESSARILY ANY OTHER
           05 KEY-FEEDBACK          PIC X(6).

      *     normally you don't do a USING on procedure division.
      *     we have to do it this way, however, 
      *     because of the JCL that we used in the workshop.

        PROCEDURE DIVISION 
           USING DUMMY-IO-PCB-MASK,
           DATABASE-PCB-MASK.

      * COBOL CODE TO PREPARE FOR THE CALL
      *	CLEAR IO AREAS FOR GET
      *	FILL IO AREAS FOR ISRT,REPL
      *	PUT DATA VALUES AND OPERATOR IN SSA'S
      *        DO THE DLI CALL, FOR EXAMPLE:
                CALL 'CBLTDLI' USING
                    GU-FUNC
                    DATABASE-PCB-MASK
                    EMPLOYEE-IO-AREA
                    EMPLOYEE-SSA-UNQUAL
 
      * CHECK STATUS CODE
      	EVALUATE DATABASE-STATUS
      *	all ok
      	WHEN '  '
      		DISPLAY 'SUCCESS'
      	WHEN 'GA'       
      		DISPLAY 'SUCCESS (WENT TO HIGHER LEVEL SEG TYPE)'
      	WHEN 'GK'
      		DISPLAY 'SUCCESS (SAME LEVEL, DIFF SEG TYPE)'       
      *	I can handle it       
      	WHEN 'GE'
      		DISPLAY 'NOT FOUND'
      		MOVE 'Y' TO TIME-TO-STOP-SWITCH
      	WHEN 'GB'
      		DISPLAY 'END OF DATABASE'
      		MOVE 'Y' TO TIME-TO-STOP-SWITCH
      	WHEN 'II'
      		DISPLAY 'DUPLICATE KEY ON INSERT'
      *	disaster       
      	WHEN OTHER
      		DISPLAY 'UNEXPECTED STATUS CODE IS' DATABASE-STATUS       
      		GO TO ERROR-EXIT
      	END-EVALUATE.
 
       ERROR-EXIT.
       	DISPLAY 'PROGRAM ABANDONED'
       	EVALUATE DATABASE-STATUS
       	WHEN 'GP'
       		DISPLAY 'PARENTAGE HAS NOT BEEN ESTABLISHED'
       	WHEN 'DJ'
       		DISPLAY 'NO GET HOLD WAS DONE'
       	WHEN 'LB'
       		DISPLAY 'DUPLICATE KEY ON INSERT WITH LOAD PSB'
       	WHEN 'LC'
       		DISPLAY 'KEY OUT OF SEQUENCE ON INSERT WITH LOAD PSB'
       	WHEN 'LD'
       		DISPLAY 'THE QUALIFIED PARENT WAS NOT FOUND '
        DISPLAY 'ON INSERT WITH LOAD PSB'
       	WHEN 'LE'       
       		DISPLAY 'KEY OUT OF SEQUENCE ON INSERT SIBLING '
        DISPLAY 'WITH LOAD PSB'
       	WHEN 'AB'
       		DISPLAY 'IO AREA REQUIRED IN CALL '
       	WHEN 'AC'
       		DISPLAY 'HIERARCHIC ERROR IN SSAS '
       	WHEN 'AD'
       		DISPLAY 'FUNCTION PARAMETER REQUIRED '
       	WHEN 'AH'       
       		DISPLAY 'REQUIRED SSA IS MISSING'
       	WHEN 'AJ'
       		DISPLAY 'SSA QUALIFICATION ERROR'
       	WHEN 'AK'
       		DISPLAY 'FIELD NAME IN SSA IS WRONG '
       	WHEN 'AT'
       		DISPLAY 'IO AREA TOO LONG '
       		DISPLAY 'A GET HOLD CALL WAS NOT DONE'
       	WHEN OTHER
       		DISPLAY 'LOOK UP STATUS CODE USING QUICK REFERENCE'	
       END-EVALUATE
       
       	CALL 'CBLTDLI' USING
       		ROLB-FUNC
       		DUMMY-IO-PCB-MASK.
       
       		GOBACK.
       
Learn how to use all the features of IMS: IMS/DLI Programming Books

[Books Computer]

Home Books for Computer Professionals Privacy Terms |
Site Map and Site Search Programming Manuals and Tutorials The REXX Files Top of Page |