1 
  2 /*
  3 
  4           The procedure cobol_rewrite_gen.pl1 generates the code which realizes the
  5 COBOL rewrite statement.
  6 
  7           REWRITE rn [id] eos
  8 
  9                     eos       a=0       no INVALID
 10                                 1       INVALID
 11 
 12                               c=0       no FROM
 13                                 1       FROM
 14 
 15                               f=00      no NOT
 16                                 01      NOT
 17 
 18                     verb=27
 19 
 20           mp.n                3-4
 21           mp.ptr(1)           type-1("REWRITE")
 22           mp.ptr(2)           type-9(record-name)
 23           mp.ptr(3)           type-9(FROM id)
 24           mp.ptr(n)           eos
 25 
 26 Flow Chart
 27 
 28 TAG(ioerror.retry_tag):
 29 
 30           alt_sw =  file_table.organization = 3   ind
 31                     &
 32                     file_table.alternate_keys ^= 0
 33 
 34           if file_table.access < 2      seq
 35           then      do;       INCR_NTAG
 36 
 37                               OP54(delete_error,ntag);GEN_IOERROR
 38 
 39 TAG(ntag):
 40 
 41                               if file_table.organization = 3          ind
 42                               then      do;       INCR_NTAG
 43 
 44                                                   OP54(delete_error,ntag);GEN_IOERROR
 45 
 46 NTAG(ntag):
 47 
 48                                         end;
 49 
 50                               call REW_REC;
 51 
 52                     end;
 53           else      do;       if        file_table.organization = 2   rel
 54                               then;
 55                               else      do;       if        file_table.access = 3         dyn
 56                                                             &
 57                                                             (         file_table.external
 58                                                                       |
 59                                                                       file_table.open_out
 60                                                             )
 61                                                   then      do;       INCR_NTAG
 62                                                                       OP54(delete_error,ntag);GEN_IOERROR
 63 TAG(ntag):
 64                                                             end;
 65                                         end;
 66 
 67                               if        ^alt_sw
 68                                         &
 69                                         file_table.access = 3         dyn
 70                                         &
 71                                         file_table.read_next
 72 
 73                               then      do;       INCR_NTAG
 74                                                   OP55(read_key,ntag);GEN_IOERROR
 75 TAG(ntag):
 76                                                   INCR_NTAG
 77                                                   OP58(special_rewrite,ntag);GEN_IOERROR
 78 TAG(ntag):
 79                                         end;
 80                               else      do;       INCR_NTAG
 81                                                   if alt_sw then IO_UTIL$FILE_DESC;OP85(alt_special_delete,0);GEN_IOERROR;SET_FSBPTR
 82                                                   OP41(seek_key,ntag);GEN_IOERROR
 83 TAG(ntag):
 84 
 85                                                   call REW_REC
 86                                         end;
 87                     end;
 88           return;
 89 
 90 REW_REC:  proc;
 91 
 92           if alt_sw then      do;       INCR_NTAG
 93                                         OP87(alt_rewrite_delete,ntag);GEN_IOERROR
 94 TAG(ntag):
 95                                         SET_FSBPTR
 96                               end;
 97           INCR_NTAG
 98           OP59(rewrite,ntag);GEN_IOERROR
 99 TAG(ntag):
100 
101           if alt_sw then      do;       INCR_NTAG
102                                         OP88(alt_rewrite_add,ntag);GEN_IOERROR
103 TAG(ntag):
104                               end;
105 
106 end;
107 
108 */
109 
110 %include cobol_opr_rewrite;
111