Coding a batch program in Pascal

The following code sample is a skeleton batch program in Pascal. It shows you how the parts of an IMS™ program that is written in Pascal fit together. The numbers to the right of the program refer to the notes that follow the program.

Restriction: Pascal is not supported by CICS®.
segment PASCIMS;                                            NOTES
                                                                1
   type                                                         2
     CHAR2 = packed array [1..2] of CHAR; 
     CHAR4 = packed array [1..4] of CHAR;
     CHAR6 = packed array [1..6] of CHAR;
     CHARn = packed array [1..n] of CHAR;
                  DB_PCB_TYPE = record                          3
                  DB_NAME : ALFA;
                  DB_SEG_LEVEL : CHAR2;
                  DB_STAT_CODE : CHAR2;
                  DB_PROC_OPT  : CHAR4;
                  FILLER       : INTEGER;
                  DB_SEG_NAME  : ALFA;
                  DB_LEN_KFB   : INTEGER;
                  DB_NO_SENSEG : INTEGER;
                  DB_KEY_FB    : CHARn;
                end;
   procedure PASCIMS (var SAVE: INTEGER;                        4
                      var DB_PCB_MAST: DB_PCB_TYPE;
                       var DB_PCB_DETAIL : DB_PCB_TYPE);
                  REENTRANT;
   procedure PASCIMS;
   type                                                         5
     QUAL_SSA_TYPE  = record
                                SEG_NAME           : ALFA;
                     SEQ_QUAL     : CHAR;
                     SEG_KEY_NAME : ALFA;
                     SEG_OPR      : CHAR2;
                     SEG_KEY_VALUE: CHAR6;
                     SEG_END_CHAR : CHAR;
                    end;
     MAST_SEG_IO_AREA_TYPE = record
                               (* Field declarations *)
                             end;
      DET_SEG_IO_AREA_TYPE = record
                              (* Field declarations *)
                            end;
   var                                                          6 
     MAST_SEG_IO_AREA : MAST_SEG_IO_AREA_TYPE;             
     DET_SEG_IO_AREA : DET_SEG_IO_AREA_TYPE;
   const                                                        7 
      GU   = 'GU  ';                                        
      GN   = 'GN  ';                                        
     GHU  = 'GHU ';
     GHN  = 'GHN ';
     GHNP = 'GHNP';
     ISRT = 'ISRT';
     REPL = 'REPL';
     DLET = 'DLET';
     QUAL_SSA = QUAL_SSA_TYPE('ROOT','(','KEY',' =',
                              'vvvvv',')');
     UNQUAL_SSA = 'NAME     ';
    procedure PASTDLI; GENERIC;                                  8
   begin
     PASTDLI(const GU,                                           9
             var   DB_PCB_DETAIL;                          
             var   DET_SEG_IO_AREA;                        
             const QUAL_SSA);
     PASTDLI(const GHU,                                         10 
             var   DB_PCB_MAST,                            
             var   MAST_SEG_IO_AREA,                       
             const QUAL_SSA);
     PASTDLI(const GHN,                                         11 
             var   DB_PCB_MAST,                            
             var   MAST_SEG_IO_AREA);
     PASTDLI(const REPL,                                        12
             var   DB_PCB_MAST,                            
             var   MAST_SEG_IO_AREA);
   end;      
                                                                13
Note:
  1. Define the name of the Pascal compile unit.
  2. Define the data types that are needed for the PCBs used in your program.
  3. Define the PCB data type that is used in your program.
  4. Declare the procedure heading for the REENTRANT procedure that is called by IMS. The first word in the parameter list should be an INTEGER, which is reserved for VS Pascal's usage. The rest of the parameters are the addresses of the PCBs that are received from IMS.
  5. Define the data types that are needed for the SSAs and I/O areas.
  6. Declare the variables used for the I/O areas.
  7. Define the constants, such as function codes and SSAs that are used in the PASTDLI DL/I calls.
  8. Declare the IMS interface routine by using the GENERIC directive. GENERIC identifies external routines that allow multiple parameter list formats. A GENERIC routine's parameters are declared only when the routine is called.
  9. This call retrieves data from the database. It contains a qualified SSA. Before you can issue a call that uses a qualified SSA, you must initialize the data field of the SSA. Before you can issue a call that uses an unqualified SSA, you must initialize the segment name field.
  10. This is another call that has a qualified SSA.
  11. This call is an unqualified call that retrieves data from the database. Because it is a Get Hold call, it can be followed by a REPL or DLET call.
  12. The REPL call replaces the data in the segment that was retrieved by the most recent Get Hold call; the data is replaced by the contents of the I/O area that is referenced in the call.
  13. You return control to IMS by exiting from the PASCIMS procedure. You can also code a RETURN statement to exit at another point.
Restriction: You must bind your program to the IMS language interface module (DFSLI000) after compiling your program.