home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / message / unitrep.src < prev   
Encoding:
Text File  |  1988-05-03  |  447.4 KB  |  12,945 lines

  1. -------- SIMTEL20 Ada Software Repository Prologue ------------
  2. --                                                           -*
  3. -- Unit name    : UNITREP Software Model
  4. -- Version      : 
  5. -- Contact      : Lt. Colonel Falgiano
  6. --              : ESD/SCW
  7. --              : Hanscom AFB, MA  01731
  8. -- Author       : SAIC COMSYSTEMS Division
  9. --              : 2815 Camino del Rio South
  10. --              : San Diego, CA  92108
  11. -- DDN Address  :
  12. -- Copyright    : (c) 1984 SAIC COMSYSTEMS
  13. -- Date created : 
  14. -- Release date : September 30, 1984
  15. -- Last update  : 
  16. --                                                           -*
  17. ---------------------------------------------------------------
  18. --                                                           -*
  19. -- Keywords     : 
  20. ----------------:
  21. --
  22. -- Abstract     : UNITREP consists of four subsystems: Message
  23. ----------------: Input and Validation (MIV), Database Manage-
  24. ----------------: ment (DBM), Man/Machine Interface (MMI), and
  25. ----------------: Systems Utilities (SYS).  DBM interfaces to 
  26. ----------------: an Intelligent Database Machine (IDM) back  
  27. ----------------: end relational database processor.  The 
  28. ----------------: UNITREP database stores validated UNITREP 
  29. ----------------: messages from all organizations and units in
  30. ----------------: the United States armed forces and some    
  31. ----------------: foreign forces under U.S. control.
  32. ----------------:
  33. ----------------: This tool was developed as a precursor for    
  34. ----------------: the WMCCS Information System (WIS).  An 
  35. ----------------: executable version of the tool has been 
  36. ----------------: demonstrated.  This source code has sub-
  37. ----------------: sequently been recompiled but has not under-
  38. ----------------: gone extensive testing.
  39. ----------------:
  40. --                                                           -*
  41. ------------------ Revision history ---------------------------
  42. --                                                           -*
  43. -- DATE         VERSION AUTHOR                  HISTORY 
  44. -- 10/30/84        1.0  SAIC                    Initial Release
  45. --                                                           -*
  46. ------------------ Distribution and Copyright -----------------
  47. --                                                           -*
  48. -- This prologue must be included in all copies of this software.
  49. -- 
  50. -- This software is copyright by the author.
  51. -- 
  52. -- This software is released to the Ada community.
  53. -- This software is released to the Public Domain (note:
  54. --   software released to the Public Domain is not subject
  55. --   to copyright protection).
  56. -- Restrictions on use or distribution:  NONE
  57. --                                                           -*
  58. ----------------- Disclaimer ----------------------------------
  59. --                                                           -*
  60. -- This software and its documentation are provided "AS IS" and
  61. -- without any expressed or implied warranties whatsoever.
  62. --
  63. -- No warranties as to performance, merchantability, or fitness
  64. -- for a particular purpose exist.
  65. --
  66. -- Because of the diversity of conditions and hardware under
  67. -- which this software may be used, no warranty of fitness for
  68. -- a particular purpose is offered.  The user is advised to 
  69. -- test the software thoroughly before relying on it.  The user
  70. -- must assume the entire risk and liability of using this 
  71. -- software.
  72. --
  73. -- In no event shall any person or organization of people be
  74. -- held responsible for any direct, indirect, consequential
  75. -- or inconsequential damages or lost profits.
  76. --                                                          -*
  77. ----------------- END-PROLOGUE -------------------------------
  78. --::::::::::
  79. --unitrepsr.dis
  80. --::::::::::
  81. -- UNITREP source files in compilation order follow:
  82.  
  83. idmdefs.src
  84. msgtypes.src
  85. sys.src
  86. idmio.src
  87. mmi.src
  88. msginput.src
  89. msgvalid.src
  90. dbb.src
  91. modcoms.src
  92. main.src
  93. --::::::::::
  94. --idmdefs.src
  95. --::::::::::
  96. package idm_defs is
  97.  
  98.   subtype commbuf is string(1..4000);
  99.  
  100.   type buffer_link is access commbuf;
  101.  
  102.   type param_value_block is
  103.     record
  104.       size  : integer range 1..257;
  105.       token : integer;
  106.       value : string(1..256);
  107.     end record;
  108.  
  109.   type param_value_link is access param_value_block;
  110.  
  111.   type param_var_value is
  112.     record
  113.       size  : integer range 1..257;
  114.       token : integer;
  115.       len   : integer;
  116.       value : string(1..255);
  117.     end record;
  118.  
  119.   type param_name_block;
  120.  
  121.   type param_name_link is access param_name_block;
  122.  
  123.   type param_name_block is
  124.     record
  125.       succ  : param_name_link;
  126.       value : param_value_link;
  127.       size  : integer range 1..12;
  128.       name  : string(1..12);
  129.     end record;
  130.  
  131.   type col_desc is
  132.     record
  133.       name   : string(1..12);
  134.       namlen : integer range 0..12;
  135.       format : integer;
  136.       index  : integer range 0..4000;
  137.     end record;
  138.  
  139.   type col_desc_array is array(1..255) of col_desc;
  140.  
  141.   type col_desc_link is access col_desc_array;
  142.  
  143.   type idm_data_type is (idm_int1,
  144.                          idm_int2,
  145.                          idm_int4,
  146.                          idm_flt4,
  147.                          idm_flt8,
  148.                          idm_char,
  149.                          idm_fchar,
  150.                          idm_bcd,
  151.                          idm_fbcd,
  152.                          idm_bcdflt,
  153.                          idm_fbcdflt,
  154.                          idm_binary,
  155.                          idm_fbinary);
  156.  
  157.   type idm_exception is (badparm_err,  bindtype_err,  done_err,
  158.                          donecmds_err, getitm_err,    moredata_err,
  159.                          no_err,       nocmds_err,    nodbopen_err,
  160.                          notexec_err,  query_err,     parse_err,
  161.                          sync_err,     targend_err,   targnum_err,
  162.                          truncate_err, tupend_err,    data_err,
  163.                          device_err,   end_err,       storage_err);
  164.  
  165.   type idm_status_type is (statdata,
  166.                            statdcnt,
  167.                            statdint,
  168.                            staterrno,
  169.                            staterrstr,
  170.                            statnerr,
  171.                            statrc);
  172.  
  173.   type idmrun_type is
  174.     record
  175.       ftchan   : integer := 0;
  176.       dbin     : integer := 0;
  177.       fgeor    : boolean := true;
  178.       lnbuffer : buffer_link := null;
  179.       inbufnxt : integer range 1..4001 := 1;
  180.       inbuflst : integer range 0..4000 := 0;
  181.       fgxact   : boolean := false;
  182.       fgexec   : boolean := false;
  183.       fgfetch  : boolean := false;
  184.       fgfchxpt : boolean := false;
  185.       exresult : idm_exception := no_err;
  186.       stcmdnam : string(1..12);
  187.       ctcmdnam : integer range 0..12 := 0;
  188.       lnparams : param_name_link := null;
  189.       ctparams : integer := 0;
  190.       lncols   : col_desc_link := null;
  191.       ctcols   : integer range 0..255 := 0;
  192.     end record;
  193.  
  194.   badparm_error   : exception;
  195.   bindtype_error  : exception;
  196.   done_error      : exception;
  197.   donecmds_error  : exception;
  198.   getitm_error    : exception;
  199.   moredata_error  : exception;
  200.   nocmds_error    : exception;
  201.   nodbopen_error  : exception;
  202.   notexec_error   : exception;
  203.   query_error     : exception;
  204.   parse_error     : exception;
  205.   sync_error      : exception;
  206.   targend_error   : exception;
  207.   targnum_error   : exception;
  208.   truncate_error  : exception;
  209.   tupend_error    : exception;
  210.  
  211. end idm_defs;
  212. --::::::::::
  213. --msgtypes.src
  214. --::::::::::
  215. package MSG_Types is
  216.  
  217.   type Department_Types is (W,F,M,N,E,D,X,Z);
  218.  
  219.   type Uic2_Department_Types is (C,D,E,G,H,K,L,N,R,S);
  220.  
  221.   type Coaff_Types is (AC, AF, AG, AL, AN, AO, AQ, AR, AS, AU, AV, AY,
  222.                        BA, BB, BC, BD, BE, BF, BG, BH ,BL, BM, BP, BQ,
  223.                        BR, BT, BU, BV, BX, BY, BZ, CA, CB, CD, CE, CF,
  224.                        CG, CH, CI, CJ, CK, CL, CM, CN, CO, CQ, CS, CT,
  225.                        CU, CV, CW, CY, CZ, DA, DJ, DM, DR, EC, EG, EI,
  226.                        EK, EQ, ES, ET, FA, FG, FI, FJ, FO, FP, FR, FS,
  227.                        FT, GA, GB, GC, GE, GH, GI, GJ, GL, GP, GQ, GR,
  228.                        GT, GV, GY, GZ, HA, HK, HM, HO, HU, IC, ID, IO,
  229.                        IQ, IR, IT, IV, IY, IZ, JA, JM, JO, JQ, JS, KE,
  230.                        KN, KR, KS, KT, KU, LA, LE, LI, LS, LT, LU, LY,
  231.                        MA, MB, MC, MG, MH, MI, ML, MN, MO, MP, MQ, MR,
  232.                        MT, MU, MV, MX, MY, MZ, NA, NC, NE, NF, NG, NH,
  233.                        NI, NL, NO, NP, NQ, NR, NS, NU, NZ, PA, PC, PE,
  234.                        PF, PG, PK, PL, PM, PO, PP, PQ, PU, QA, RE, RO,
  235.                        RP, RQ, RW, SA, SB, SC, SE, SF, SG, SH, SL, SM,
  236.                        SN, SO, SP, SQ, ST, SU, SW, SY, SZ, TC, TD, TH,
  237.                        TK, TL, TN, TO, TP, TQ, TS, TU, TV, TW, TZ, UG,
  238.                        UK, UN, UR, US, UV, UY, VC, VE, VI, VM, VQ, VT,
  239.                        WA, WF, WI, WQ, WS, WZ, YE, YO, YS, ZA, ZI);
  240. -- COUNTRY/INTERNATIONAL AFFILIATION
  241. --     SPECIAL CHECK FOR Coaff_Types "DO", "IN", "IS"
  242.  
  243.   type Udc_Types is (A,B,C,D,E,F,T,U,V,W,X,Y,Z,
  244.                      G,H,L,N,J,K,P,Q,R,S);  -- UNIT DESCRIPTOR CODE
  245. --     SPECIAL CHECK FOR Udc_Types "1" "3" "5" "7" "9" "2" "4" 
  246. --                                 "6" "8" "0"
  247.  
  248.   type Ulc_Types is (A  ,ACD,ACT,ADM,AF ,AFY,AGP,AGY,ANX,
  249.                      AP ,AR ,ARS,AST,AUG,B  ,BAS,BD ,BDE,
  250.                      BKS,BLT,BN ,BND,BR ,BSN,BT ,BTY,CAY,
  251.                      CEC,CEP,CGC,CGE,CLN,CMD,CMN,CMP,CO ,
  252.                      CPS,CRW,CTP,CTR,DAY,DEP,DET,DIR,DIV,
  253.                      DMB,DMF,DML,DMM,DMP,DMR,DMT,DMU,DSP,
  254.                      DST,DTL,ELE,FAC,FAR,FLO,FLT,FMF,FTR,
  255.                      FT ,GAR,GRP,HBD,HHB,HHC,HHD,HHS,HHT,
  256.                      HM ,HMC,HQ ,HQC,HQD,HQS,HSB,HSC,HSP,
  257.                      INS,ISP,IST,LAB,LIB,MAA,MAB,MAF,MAG,
  258.                      MAU,MAW,MER,MGR,MGZ,MIS,MSC,MSF,MTF,
  259.                      MUS,NSC,NSL,OBS,OFC,OFF,OIC,OL ,
  260.                      PKG,PKT,PLN,PLT,PO ,PRT,PTY,PVG,RCT,
  261.                      REP,RES,RGN,RGT,RLT,RNG,SCH,SCM,SCO,
  262.                      SCT,SEC,SHP,SIP,SQ ,SQD,SS ,SST,STA,
  263.                      STF,STP,STR,SU ,SUP,SVC,SYD,SYS,TE ,
  264.                      TF ,TG ,TM ,TML,TRN,TRP,TU ,U  ,USS,
  265.                      WG ,WKS);  -- UNIT LEVEL CODE
  266. --     SPECIAL CHECK FOR Ulc_Types "FOR"
  267.  
  268.   type Major_Types is (X);  -- MAJOR UNIT INDICATOR
  269.  
  270.   type Reval_Types is (G,R,X);  -- REGISTRATION VALIDATION
  271.  
  272.   type Cserv_Types is (C,D,A,N,F,M,E,J);  -- CINC/SERVICE COMMAND CODE
  273. --     SPECIAL Cserv_Types "1" "2" "3" "4" "5" "6" "7" "8" "9"
  274.  
  275.   type Activ_Types is (AC,CW,DE,ED,ER,NP,PD,PH,PK,PL,PS,
  276.                        RD,UM,UN,XX,AN,AS,CA,CD,CJ,CM,CS,
  277.                        DA,DR,FP,FR,GF,IP,LD,LE,ON,OP,
  278.                        PC,PM,PO,PA,PV,PW,RC,RE,RF,RO,RR,
  279.                        SM,SR,CR,CV,MA,OH,RA,RX,DS,FO,OE,
  280.                        OT,SD,TE,TO,BT,NA,RT,TA,TB,TR,TS,
  281.                        TU,TW,AD,AU,EX,GW,MR);
  282. -- CURRENT STATUS AND ACTIVITY CODE
  283. --     SPECIAL CHECK FOR Activ_Types "IN"
  284.  
  285.   type Flag_Types is (X);  -- ORGANIC ORGANIZATION ESTABLISHED
  286.  
  287.   type Cbcom_Types is (A,B,E,K,N,P,T);  -- COMBINED COMMAND CODE
  288.  
  289.   type Dfcon_Types is (N,T,V,S,R,G);  -- DEFCON STATUS
  290. --     SPECIAL CHECK FOR Dfcon_Types "5" "4" "3" "2" "1"
  291.  
  292.   type Nucin_Types is (X);  -- NUCLEAR CAPABILITY INDICATOR CODE
  293.  
  294.   type Media_Types is (C,L,M,T);  -- SYSTEM NOTIFICATION MEDIA
  295.  
  296.   type Tadc_Types is (X);  -- TELECOMMUNICATIONS ADDRESS DIRECTORY CODE
  297.  
  298.   type Tpers_Types is (CS,CQ,CP,AC,NC,MC,FC,EC,AW,NW,MW,
  299.                        FW,EW,AE,NE,ME,FE,EE,ZA,ZE,ZC,RC,
  300.                        RE,RW,AK,NK,MK,FK,EK,AX,NX,MX,FX,
  301.                        EX,NT,MT,FT,ET,AM,NM,MM,FM,EM,AI,
  302.                        NI,MI,FI,EI,AD,ND,MD,FD,ED,AH,NH,
  303.                        MH,FH,EH,AL,NL,ML,FL,EL,ZZ);
  304. -- TYPE OF PERSONNEL
  305. --       SPECIAL CHECK FOR Tpers_Types "AT"
  306.  
  307.   type Cceby_Types is (X);  -- CUMULATIVE CASUALTIES/ENEMY PW EDIT
  308.  
  309.   type Tread_Types is (JCRR1,POMCS);  -- TYPE OF READINESS
  310.  
  311.   type Reasn_Types is (P,S,R,T,M,N,X); 
  312. -- OVERALL REASON ORGANIZATION NOT FULLY COMBAT READY
  313.  
  314.   type Prres_Types is (P01,P02,P03,P04,P05,P06,P07,P08,P09,
  315.                        P10,P11,P12,P13,P14,P15,P16,P17,P18,
  316.                        P19,P20,P21,P22,P23,P24,P25,P26,P27,
  317.                        P28,P29,P30,P31,P32,P33,P34,P35,P36,
  318.                        P37,P38,P39,P40,P41,P42,P43,P44,P45,
  319.                        P46,P47,P48,P49,P50,P51,P52,P53,P54,
  320.                        P55,P56,P57,P58,P59,P60,P61,P62,P63,
  321.                        P64,P65,P66,P67,P68,P69,P70,P71,P72,
  322.                        P73,P74,P75,P76,P77,P78,P79,P80,PUP,
  323.                        S01,S02,S03,S04,S05,S06,S07,S08,S09,
  324.                        S10,S11,S12,S13,S14,S15,S16,S17,S18,
  325.                        S19,S20,S21,S22,S23,S24,S25,S26,S27,
  326.                        S28,S29,S30,S31,S32,S33,S34,S35,S36,
  327.                        S37,S38,S39,S40,S41,S42,S43,S44,S45,
  328.                        S46,S47,S48,S49,S50,S51,S52,S53,S54,
  329.                        S55,S56,S57,S58,S59,S60,S61,S62,S63,
  330.                        S64,S65,S66,S67,S68,S69,S70,S71,S72,
  331.                        S73,S74,S75,S76,S77,S78,S79,S80,S81,
  332.                        S82,S83,S84,S85,S86,S87,S88,S89,S90,
  333.                        S91,S92,S93,S94,S95,S96,S97,S98,SUP,
  334.                        R00,R01,R02,R03,R04,R05,R06,R07,R08,
  335.                        R09,R10,R11,R12,R13,R14,R15,R16,R17,
  336.                        R18,R19,R20,R21,R22,R23,R24,R25,R26,
  337.                        R27,R28,R29,R30,R31,R32,R33,R34,R35,
  338.                        R36,R37,R38,R39,R40,R41,R42,R43,R44,
  339.                        R45,R46,R47,R48,R49,R50,R51,R52,R53,
  340.                        R54,R55,R56,R57,R58,R59,R60,R61,R62,
  341.                        R63,R64,R65,R66,R67,R68,R69,R70,R71,
  342.                        R72,R73,R74,R75,R76,R77,R78,R79,R80,
  343.                        R81,R82,R83,R84,R85,R86,R87,R88,R89,
  344.                        R90,R91,R92,R93,R94,R95,R96,R97,R98,
  345.                        R99,RAA,RAB,RAC,RAD,RAE,RAF,RAG,RAH,
  346.                        RAL,RAN,RAP,RAQ,RAR,RAS,RAT,RAU,RAV,
  347.                        RAW,RAX,RAY,RBA,RBB,RBC,RBD,RBE,RBF,
  348.                        RBG,RBH,RBI,RBJ,RBK,RBL,RBM,RBN,RUP,
  349.                        T01,T02,T03,T04,T05,T06,T07,T08,T09,
  350.                        T10,T11,T12,T13,T14,T15,T16,T17,T18,
  351.                        T19,T20,T21,T22,T23,T24,T25,T26,T27,
  352.                        T28,T29,T30,T31,T32,T33,T34,T35,T36,
  353.                        T37,T38,T39,T40,T41,T42,T43,T44,T45,
  354.                        T46,T47,T48,T49,T50,T51,T52,T53,T54,
  355.                        T55,T56,T57,T58,T59,T60,T61,T62,T63,
  356.                        T64,T65,T66,T67,T68,T69,T70,T71,T72,
  357.                        T73,T74,T75,T76,T77,T78,T79,T80,T81,
  358.                        T82,T83,TUP);
  359. -- PRIMARY REASON MEASURED RESOURCE AREA RATING 
  360. -- FOR PERSONNEL NOT FULLY COMBAT READY
  361.     subtype Prres_Prres_Types is Prres_Types range P01..P80;
  362.     subtype Esres_Prres_Types is Prres_Types range S01..S98;
  363.     subtype Erres_Prres_Types is Prres_Types range R00..RBN;
  364.     subtype Trres_Prres_Types is Prres_Types range T01..T83;
  365.  
  366.   type Rlim_Types is (P,S,R,T);  -- REASON FOR READINESS RATING LIMITATION
  367.  
  368.   type Fordv_Types is (C,B,F,H,D,I,J,K,T,U,G,
  369.                        X,Y);  -- FOREIGN DELIVERY EQUIPMENT CAPABLILITY
  370.  
  371.   type Merec_Types is (AL,AS,CM,CO,DF,DL,EC,EM,EL,FL,HH,
  372.                        HY,IR,LL,LA,MO,OP,PH,RA,RM,SG,SL,
  373.                        SP,TL,TM,TV,UV,VI,WX,MP,XX);
  374. -- Major Equipment - Reconnaissance Capabilities
  375. --        SPECIAL CHECK FOR Merec_Types "#"
  376.       
  377.   type Pin_Types is (A,B,D,E,F,G,H,K,L,M,N,P,R,S);
  378.  
  379.   type Pleac_Types is (A,C);  -- ORGANIZATION PLAN RELATIONSHIP
  380.  
  381.   type Ddp_Types is (ND,ID,AD,MD,LD);  -- DIRECTED DEPLOYABILITY POSTURE
  382.  
  383.   type Reconn_Types is (AL, AS, CM, CO, DF, DL, EC, EM, EL, FL, HH, HY,
  384.                         IR, LL, LA, MO, OP, PH, RA, RM, SG, SL, SP, TL,
  385.                         TM, TV, UV, VI, WX, MP, XX);
  386.  
  387.   type Wpnco_Types is (CO, EL, IR, PH, RA, SG, SL, VI);
  388.  
  389.   type Mecus_Types is (CT,TT,MT,DT,XT,CF,TF,MF,DF,XF,
  390.                        CE,CS,RA,FT);
  391. -- TRANSPORTABLE COMMUNICATIONS EQUIPMENT CURRENT USE CODES
  392.  
  393.   type Avcat_Types is (A,B,C,D,F,G,H,J);  -- AVAILABILITY CATEGORY
  394.  
  395.   type Resnd_Types is (A,B,C,E,F);
  396. -- REASON AVAILABILITY CATEGORY IS CODE "D"
  397.  
  398.   type Bilet_Types is (CG ,CO ,OIC,NCO);  -- BILLET
  399.  
  400.   type Cornk_Types is (SGT, LT, CAPT, MAJ, LTCOL, COL, GEN);  -- CORNK
  401.  
  402.   type Label_Types is (UDC  ,ANAME,UTC  ,ULC  ,MJCOM,MAJOR,REVAL,
  403.                        TPSN ,SCLAS,LNAME,COAFF,MONOR,  -- [A,B,C]
  404.                        CSERV,OPCON,ADCON,HOGEO,PRGEO,EMBRK,ACTIV,
  405.                        FLAG ,PUIC ,CBCOM,DFCON,POINT,NUCIN,PCTEF,
  406.                        BILET,CORNK,CONAM,MMCMD,NTASK,MODFG,PLETD,
  407.                        NDEST,DETA,CXMRS,  -- [D]
  408.                        TCAA ,MEDIA,TADC ,ROUTE,RWDTE,XRTE ,XDATE, -- [G]
  409.                        TPERS,PEGEO,STRUC,AUTH ,ASGD ,POSTR,PICDA,
  410.                        DEPS ,TDEPS,CASPW,CCASP,CCEBY,SCATD,MGO  ,
  411.                        AGO  ,NA   ,NFO  ,MENL ,NAVO ,NAVE ,OTHOF,
  412.                        OTHEN,PIAOD,  -- [J]
  413.                        TREAD,READY,REASN,PRRAT,PRRES,ESRAT,ESRES,
  414.                        ERRAT,ERRES,TRRAT,TRRES,SECRN,TERRN,CARAT,
  415.                        CADAT,LIM  ,RLIM ,RICDA,DOCNR,DOCID,PERTP,
  416.                        TPAUT,TPASG,TPAVL,PERTC,CPAUR,CPASG,CPAVL,
  417.                        TRUTC,TMTHD,TCARQ,TCRAS,TCRAV,TRSA1,TRSA2,
  418.                        TRSA3,TRSA4,TRSA5,EQSEE,EQSSE,MEARD,MEASG,
  419.                        MEPOS,ESSA1,ESSA2,ESSA3,ESSA4,ESSA5,ESSA6,
  420.                        ESSA7,ESSA8,ESSA9,EQREE,EQRED,MEMRA,ERSA1,
  421.                        ERSA2,ERSA3,ERSA4,ERSA5,ERSA6,ERSA7,ERSA8,
  422.                        SDOC ,READF,REASF,PRRAF,PRREF,ESRAF,ESREF,
  423.                        TRRAF,TRREF,SECRF,TERRF,CARAF,CADAF,LIMF ,
  424.                        RLIMF,RICDF,RESPF,SMCC1,SMRA1,SMAA1,SMRC1,
  425.                        SMAC1,SMCC2,SMRA2,SMAA2,SMRC2,SMAC2,SMCC3,
  426.                        SMRA3,SMAA3,SMRC3,SMAC3,SMCC4,SMRA4,SMAA4,
  427.                        SMRC4,SMAC4,GCCLA,GCCLB,GCCLC,SPCLU,PRMA ,
  428.                        MARAT,MAREA,CHDAT,FMART,FCDAT,  -- [K]
  429.                        MEQPT,FORDV,MEPSA,METAL,MEPSD,MEORD,MEORN,
  430.                        MEORC,MEORO,CREWA,CREAL,CREWF,CRMRD,CRMRN,
  431.                        CRMRC,CRMRO,MEREC,TEGEO,  -- [L,M]
  432.                        PIN,FRQNO,PLEAC,DDP,DDPRD,MDT,PUTCV,PEQPT,
  433.                        TPGEO,ALTYP,NUMBR,NUMEA,ALRET,NUSEQ,WPNCO,
  434.                        NUQPT,DSGEO,NUMWR,NUMWB,NUGUN,RTIME,DSSTA,
  435.                        RFDGS,NUSTO,NUECC,  -- [N,P,Q]
  436.                        TEQPT,MESEN,DECON,MECUS,AVCAT,RESND,ERDTE,
  437.                        EXDAC,CPGEO,CFGEO,EQDEP,EQARR,TPIN ,TLEAC,
  438.                        TLEQE,UEQPT,MEQS ,SEDY ,TEDY ,ERRDY,AVAIL,
  439.                        DCNDY,EQRET,GEOGR,OPERL,DAFLD,  -- [T]
  440.                        ACGEO,ACITY,ADATE,MDATE,RDATE,  -- [V]
  441.                        GCMD ,TDATE,TRGEO,DEPDT,ARRDT,RPTOR,INTR1,
  442.                        INTR2,SBRPT  -- [X]
  443.                       );  -- DATA ELEMENT LABEL
  444.  
  445.   type Mmcmd_Types is (M00048,M00049,M00051,M00053,M00055,M00070,
  446.                        M00074,M00101,M00201,M00300,M00400,M00407,
  447.                        M01333,M01369,M01531,M11000,M12000,M13000,
  448.                        M14000,M18032,M18045,M18172,M19001,M19009,
  449.                        M19012,M19015,M19033,M19100,M19137,M19500,
  450.                        M20000,M20020,M20040,M20051,M20080,M20128,
  451.                        M20135,M20146,M21580,M21610,M27100,M28300,
  452.                        M29000,M54000,M61610,M96300);
  453. -- MAJOR MARINE COMMAND
  454. --       SPECIAL CHECK FOR Mmcmd_Types "#     "
  455.  
  456.   type Docid_Types is (AM22,AG23,AM24,BM22,BG23,BM24,BG25,CM22,
  457.                        CG23,CM24,CG25,CD26,CM28,CM29,DM22,DG23,
  458.                        DM24,DG25,DM26,DG27,DM28,DG29,DM32,DG33,
  459.                        DM34,DG35,DG36,DG37,EM22,EG23,EM24,EG25,
  460.                        EM26,EG27,FM22,FG23,FD24,FM25,FG26,FM27,
  461.                        FG28,FM29,FG33,FM34,FG35,FM36,FG37,FD38,
  462.                        GM22,GG23,HM22,HG23,HM24,HG25,HM26,HG27,
  463.                        JM22,JG23,JM24,JG25,JM26,JG27,KM22,KG23,
  464.                        LM22,LG23,LM24,LG25,LM26,LG27,LM28,LG29,
  465.                        MM22,MG23,MM24,MG25,MM26,MM27,MM28,MM29,
  466.                        MM32,MM33,NM22,NG23,NM24,NG25,NM26,NG27,
  467.                        OA22,OA23,OG24,OG25,PM22,PG23,PM24,PG25,
  468.                        QM22,QG23,QM24,QG25,QG26,QM27,QD28,QD29,
  469.                        QD32,QD33,QD34,QD35,QD36,RM22,RM24,RM25,
  470.                        RM26,RM27,RM28,RM29,RM32,RM33,RG34,RG35,
  471.                        RG36,RG37,RG38,RG39,SM22,SM23,SG24,SG25,
  472.                        SM26,SG27,SG28,SG29,SM32,SD33,TM22,TG23,
  473.                        UG22,UG23,UG24,UM25,UD26,UM27,WS22,WS23,
  474.                        WS24,WS25,WS26,WS27,WS28,ZG23,ZM24,ZG25,
  475.                        ZM26);  -- PRIMARY DOC IDENTIDENTIFICATION CODE
  476.  
  477.   type Tmthd_Types is (B,C);  -- METHOD
  478.  
  479.   type Meqs_Types is (A,D,F,G,K,L,M,N,P,Q,R,T,U,V,
  480.                       Y,Z,X,B,C,E,H,J,S,W);
  481. -- PRIME EQUIPMENT OPERATIONAL STATUS
  482.  
  483.   type Sedy_Types is (A,B,C,F,I,J,M,N,R,V,W,Y,Z,X);
  484. -- PACKAGE SUPPORT EQUIPMENT STATUS
  485. --     SPECIAL CHECK FOR Sedy_Types "0" "5" "7" "9"
  486.  
  487.   type Tedy_Types is (C,D,F,G,H,M,N,P,T,X,Z);  -- ASSIGNED TEAM STATUS
  488.  
  489.   type Avail_Types is (A,B,C,D,E,F);  -- EQUIPMENT AVAILABILITY
  490.  
  491.   type Alphabetic_Types is (A, B, C, D, E, F, G, H, I, J, K, L, M, N,
  492.                             O, P, Q, R, S, T, U, V, W, X, Y, Z);
  493.  
  494.   type Error_Msg_Types is (Bad_Field, Bad_Sequence, No_Header, No_End,
  495.                            Field_Required, Bad_Card_Type,
  496.                            Mutually_Exclusive,
  497.                            Can_Not_Validate_Correctly);
  498.  
  499.   type Secur_Types is (U,C,S,T);  -- SECURITY CLASSIFICATION
  500.  
  501.   type Trtype_Types is (ADD,CHANGE,DELETE,REPLACE);  -- TRANSACTION TYPE
  502.  
  503.   type Card_Type_Types is (A  ,B  ,C  ,D  ,G  ,J  ,K  ,L  ,
  504.                            M  ,N  ,P  ,Q  ,T  ,V  ,X  ,R  ,
  505.                            DM1,DN1,JM1,KF1,KF2,KF3,KF4,KN1,
  506.                            RM3,TF1,H  ,E  );  -- CARD TYPE
  507.  
  508.  
  509.   type Month_Types is (JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC);
  510.  
  511.   type Real_or_Exercise_Types is (R,X);
  512.  
  513.  
  514.   type Oruic_Types is (DDAAAA,DEAAAA,DJJ010,DJ1000,DJ1200,DJ2000,
  515.                        DJ3000,DJ3020,DJ3021,DJ3023,DJ3024,DJ3025,
  516.                        DJ3026,DJ3090,DJ4000,DJ5000,DJ6000,DJ7000,
  517.                        DJ8000,DJ9000,DLAAAA,DMAAAA,W0ZUFF,W00QAA,
  518.                        W00YFF,W38BFF,W38AFF,W3VYFF,W3YBFF,WATMFF,
  519.                        W0ALFF,W0ANFF,W0ATFF,W32FFF,W0GTAA,W0GVAA,
  520.                        W0GWFF,W0QFAA,WATGFF,W4NHFF,N00011,N00033,
  521.                        N00060,N00061,N00070,N00072,N00071,FFQT10,
  522.                        FFB370,FFB790,FFBBB0,FFBCC0,FFBSD0,
  523.                        FFC4D0,FFCL80,FFCLM0,FFCMF0,FFCMJ0,FFCRS0,
  524.                        FFFHL0,FFFTC0,FFGKT0,FFGTW0,FFH5M0,
  525.                        FFH7B0,FFH7BA,FFH7BB,FFHCS0,FFJQ20,
  526.                        FFVGB0,M54000,M00400,M14000,M20000,
  527.                        M20020,E70098,E73130,E75120,E75150,XXAAAA,
  528.                        ZZZDAA,ZZZDAB,ZZZDAC,ZZZDAD,ZZZDAE,ZZZDAF,
  529.                        ZZZDAG,ZZZDAH,ZZZDAJ);  -- MAJOR COMMAND CODE
  530.  
  531.   type Picda_Types is
  532.     record
  533.       Year  : integer range 1901..2099;
  534.       Month : integer range 1..12;
  535.       Day   : integer range 1..31;
  536.     end record;
  537.  
  538.   type Altyp_Types is (AA,AB,AE,AL,AP,AR,AU,BD,BG,BN,
  539.                        BO,CD,CP,CS,DA,DB,DC,DD,DE,DF,
  540.                        DG,DH,DJ,DK,DL,DM,DN,DS,DW,EA,
  541.                        EG,IP,LC,LS,LT,ME,NE,PE,PG,PN,
  542.                        PS,RC,RN,RP,SA,SC,SD,SG,SI,SL,
  543.                        SM,SN,TA,TC,TD,TE,TF,TG,TL,TM,
  544.                        TN,TP,TR,TS,TT,TW,WR,WX);
  545. -- TYPE OF COMMITMENT CODES
  546.  
  547.   type Scatd_Types is (TO);
  548.  
  549.   type Prma_Types is (AAW  ,AMW  ,ASU  ,ASW  ,CCC  ,CON  ,ELW  ,
  550.                       FSO  ,INT  ,LOG  ,MIW  ,MOB  ,NCO  ,SPW  ,
  551.                       STW  ,ATN  ,ELT  ,IOP  ,MEP  ,MSA  ,SAR  );
  552. -- PRIMARY MISSION AREA
  553.  
  554.   type DDDYY_Types is
  555.     record
  556.       DDD         : string(1..3);
  557.       YY          : string(1..2);
  558.     end record;
  559.  
  560.   type YYMMDD_Types is
  561.     record
  562.       YY          : string(1..2);
  563.       MM          : string(1..2);
  564.       DD          : string(1..2);
  565.     end record;
  566.  
  567.   type YYMMDDHH_Types is
  568.     record
  569.       YY          : string(1..2);
  570.       MM          : string(1..2);
  571.       DD          : string(1..2);
  572.       HH          : string(1..2);
  573.     end record;
  574.  
  575.   type DDDHH_Types is
  576.     record
  577.       DDD         : string(1..3);
  578.       HH          : string(1..2);
  579.     end record;
  580.  
  581.   type HHHMM_Types is
  582.     record
  583.       HHH         : string(1..3);
  584.       MM          : string(1..2);
  585.     end record;
  586.  
  587.   type MMDDHH_Types is
  588.     record
  589.       Year        : integer;
  590.       MM          : string(1..2);
  591.       DD          : string(1..2);
  592.       HH          : string(1..2);
  593.     end record;
  594.  
  595.   type Card_Type_H is
  596.     record
  597.       Card_Number      : integer range 1..1;
  598.       Day              : integer range 1..31;
  599.       Month            : Month_Types;
  600.       Year             : integer range 0..99;
  601.       Real_or_Exercise : Real_or_Exercise_Types;
  602.       Oruic            : Oruic_Types;
  603.     end record;
  604.  
  605.   type Card_Type_E is
  606.     record
  607.       Not_Used : string(1..2);
  608.     end record;
  609.  
  610.   type Card_Type_A is
  611.     record
  612.       Udc         : string(1..1);
  613.       Aname       : string(1..30);
  614.       Utc         : string(1..5);
  615.       Ulc         : string(1..3);
  616.       Mjcom       : string(1..6);
  617.       Major       : string(1..1);
  618.       Reval       : string(1..1);
  619.       Tpsn        : string(1..7);
  620.       Sclas       : string(1..1);
  621.     end record;
  622.  
  623.   type Card_Type_B is
  624.     record
  625.       Lname       : string(1..55);
  626.     end record;
  627.  
  628.   type Card_Type_C is
  629.     record
  630.       Udc         : string(1..1);
  631.       Aname       : string(1..30);
  632.       Utc         : string(1..5);
  633.       Ulc         : string(1..3);
  634.       Coaff       : string(1..2);
  635.       Monor       : string(1..6);
  636.       Sclas       : string(1..1);
  637.     end record;
  638.  
  639.   type Card_Type_D is
  640.     record
  641.       Cserv       : string(1..1);
  642.       Opcon       : string(1..6);
  643.       Adcon       : string(1..6);
  644.       Hogeo       : string(1..4);
  645.       Prgeo       : string(1..4);
  646.       Embrk       : string(1..6);
  647.       Activ       : string(1..2);
  648.       Flag        : string(1..1);
  649.       Puic        : string(1..6);
  650.       Cbcom       : string(1..1);
  651.       Dfcon       : string(1..1);
  652.       Point       : string(1..15);
  653.       Nucin       : string(1..1);
  654.       Pctef       : string(1..1);
  655.     end record;
  656.  
  657.   type Card_Type_G is
  658.     record
  659.       Tcaa        : string(1..29);
  660.       Media       : string(1..1);
  661.       Tadc        : string(1..1);
  662.       Route       : string(1..7);
  663.       Rwdte       : DDDYY_Types;
  664.       Xrte        : string(1..7);
  665.       Xdate       : DDDYY_Types;
  666.     end record;
  667.  
  668.   type Card_Type_J is
  669.     record
  670.       Tpers       : string(1..2);
  671.       Pegeo       : string(1..6);
  672.       Struc       : string(1..5);
  673.       Auth        : string(1..5);
  674.       Asgd        : string(1..5);
  675.       Postr       : string(1..5);
  676.       Picda       : Picda_Types;
  677.       Deps        : string(1..5);
  678.       Tdeps       : string(1..5);
  679.       Caspw       : string(1..5);
  680.       Ccasp       : string(1..5);
  681.       Cceby       : string(1..1);
  682.     end record;
  683.  
  684.   type Card_Type_K is
  685.     record
  686.       Tread       : string(1..5);
  687.       Ready       : string(1..1);
  688.       Reasn       : string(1..1);
  689.       Prrat       : string(1..1);
  690.       Prres       : string(1..3);
  691.       Esrat       : string(1..1);
  692.       Esres       : string(1..3);
  693.       Errat       : string(1..1);
  694.       Erres       : string(1..3);
  695.       Trrat       : string(1..1);
  696.       Trres       : string(1..3);
  697.       Secrn       : string(1..3);
  698.       Terrn       : string(1..3);
  699.       Carat       : string(1..1);
  700.       Cadat       : YYMMDD_Types;
  701.       Lim         : string(1..1);
  702.       Rlim        : string(1..1);
  703.       Ricda       : YYMMDD_Types;
  704.     end record;
  705.  
  706.   type Card_Type_L is
  707.     record
  708.       Meqpt       : string(1..13);
  709.       Fordv       : string(1..1);
  710.       Mepsa       : string(1..3);
  711.       Metal       : string(1..3);
  712.       Mepsd       : string(1..3);
  713.       Meord       : string(1..3);
  714.       Meorn       : string(1..3);
  715.       Meorc       : string(1..3);
  716.       Meoro       : string(1..3);
  717.       Crewa       : string(1..2);
  718.       Creal       : string(1..2);
  719.       Crewf       : string(1..2);
  720.       Crmrd       : string(1..2);
  721.       Crmrn       : string(1..2);
  722.       Crmrc       : string(1..2);
  723.       Crmro       : string(1..2);
  724.       Merec_1     : string(1..2);
  725.       Merec_2     : string(1..2);
  726.       Merec_3     : string(1..2);
  727.     end record;
  728.  
  729.   type Card_Type_M is
  730.     record
  731.       Meqpt       : string(1..13);
  732.       Tegeo       : string(1..6);
  733.       Mepsd       : string(1..3);
  734.       Meord       : string(1..3);
  735.       Meorn       : string(1..3);
  736.       Meorc       : string(1..3);
  737.       Meoro       : string(1..3);
  738.       Crewf       : string(1..2);
  739.       Crmrd       : string(1..2);
  740.       Crmrn       : string(1..2);
  741.       Crmrc       : string(1..2);
  742.       Crmro       : string(1..2);
  743.       Merec_1     : string(1..2);
  744.       Merec_2     : string(1..2);
  745.       Merec_3     : string(1..2);
  746.     end record;
  747.  
  748.   type Card_Type_N is
  749.     record
  750.       Pin         : string(1..5);
  751.       Frqno       : string(1..5);
  752.       Pleac       : string(1..1);
  753.       Ddp         : string(1..2);
  754.       Ddprd       : YYMMDDHH_Types;
  755.       Mdt         : DDDHH_Types;
  756.       Putc        : string(1..5);
  757.     end record;
  758.  
  759.   type Card_Type_P is
  760.     record
  761.       Pin         : string(1..5);
  762.       Meqpt       : string(1..13);
  763.       Tpgeo       : string(1..6);
  764.       Altyp       : Altyp_Types;
  765.       Numbr       : string(1..3);
  766.       Numea       : string(1..3);
  767.       Alret       : HHHMM_Types;
  768.     end record;
  769.  
  770.   type Card_Type_Q is
  771.     record
  772.       Pin         : string(1..5);
  773.       Nuseq       : string(1..3);
  774.       Wpnco       : string(1..7);
  775.       Nuqpt       : string(1..10);
  776.       Dsgeo       : string(1..6);
  777.       Altyp       : string(1..2);
  778.       Numwr       : string(1..2);
  779.       Numwb       : string(1..2);
  780.       Nugun       : string(1..2);
  781.       Rtime       : string(1..5);
  782.       Dssta       : string(1..1);
  783.       Rfdgs       : string(1..5);
  784.       Nusto       : string(1..3);
  785.       Nuecc       : string(1..2);
  786.     end record;
  787.  
  788.   type Card_Type_T is
  789.     record
  790.       Teqpt       : string(1..11);
  791.       Mesen       : string(1..4);
  792.       Decon       : string(1..1);
  793.       Mecus       : string(1..2);
  794.       Avcat       : string(1..1);
  795.       Resnd       : string(1..1);
  796.       Erdte       : YYMMDD_Types;
  797.       Exdac       : string(1..1);
  798.       Cpgeo       : string(1..4);
  799.       Cfgeo       : string(1..4);
  800.       Eqdep       : YYMMDD_Types;
  801.       Eqarr       : YYMMDD_Types;
  802.       Pin         : string(1..5);
  803.       Tleac       : string(1..1);
  804.       Tleqe       : string(1..2);
  805.     end record;
  806.  
  807.   type Card_Type_V is
  808.     record
  809.       Acgeo       : string(1..4);
  810.       Acity       : string(1..2);
  811.       Adate       : YYMMDD_Types;
  812.       Mdate       : string(1..4);
  813.       Rdate       : YYMMDD_Types;
  814.     end record;
  815.  
  816.   type Card_Type_X is
  817.     record
  818.       Gcmd        : string(1..6);
  819.       Tdate       : YYMMDD_Types;
  820.       Trgeo       : string(1..4);
  821.       Depdt       : YYMMDD_Types;
  822.       Arrdt       : YYMMDD_Types;
  823.       Rptor       : string(1..6);
  824.       Intr1       : string(1..6);
  825.       Intr2       : string(1..6);
  826.       Sbrpt       : string(1..6);
  827.       Atach       : string(1..3);
  828.     end record;
  829.  
  830.   type Card_Type_R is
  831.     record
  832.       Seq         : integer range 1..9;
  833.       Tot         : integer range 1..9;
  834.       Label       : string(1..5);
  835.       Rmkid       : string(1..27);
  836.       Remrk       : string(1..21);
  837.     end record;
  838.  
  839.   type Card_Type_DM1 is
  840.     record
  841.       Billet      : string(1..3);
  842.       Cornk       : string(1..5);
  843.       Conam       : string(1..17);
  844.       Mmcmd       : string(1..6);
  845.     end record;
  846.  
  847.   type Card_Type_DN1 is
  848.     record
  849.       Ntask       : string(1..13);
  850.       Prgeo       : string(1..4);
  851.       Point       : string(1..11);
  852.       Modfg       : string(1..1);
  853.       Activ       : string(1..2);
  854.       Pletd       : MMDDHH_Types;
  855.       Ndest       : string(1..11);
  856.       Deta        : MMDDHH_Types;
  857.       Cxmrs       : string(1..1);
  858.     end record;
  859.  
  860.   type Card_Type_JM1 is
  861.     record
  862.       Scatd       : Scatd_Types;
  863.       Mgo         : string(1..5);
  864.       Ago         : string(1..5);
  865.       Na          : string(1..5);
  866.       Nfo         : string(1..5);
  867.       Menl        : string(1..5);
  868.       Navo        : string(1..5);
  869.       Nave        : string(1..5);
  870.       Othof       : string(1..5);
  871.       Othen       : string(1..5);
  872.       Piaod       : string(1..6);
  873.     end record;
  874.  
  875.   type Card_Type_KF1 is
  876.     record
  877.       Docnr       : string(1..1);
  878.       Docid       : string(1..4);
  879.       Pertp       : string(1..2);
  880.       Tpaut       : string(1..4);
  881.       Tpasg       : string(1..4);
  882.       Tpavl       : string(1..4);
  883.       Pertc       : string(1..2);
  884.       Cpaur       : string(1..4);
  885.       Cpasg       : string(1..4);
  886.       Cpavl       : string(1..4);
  887.       Trutc       : string(1..2);
  888.       Tmthd       : string(1..1);
  889.       Tcarq       : string(1..3);
  890.       Tcras       : string(1..3);
  891.       Tcrav       : string(1..3);
  892.       Trsa1       : string(1..2);
  893.       Trsa2       : string(1..2);
  894.       Trsa3       : string(1..2);
  895.       Trsa4       : string(1..2);
  896.       Trsa5       : string(1..2);
  897.     end record;
  898.  
  899.   type Card_Type_KF2 is
  900.     record
  901.       Docnr       : string(1..1);
  902.       Eqsee       : string(1..2);
  903.       Eqsse       : string(1..2);
  904.       Meard       : string(1..3);
  905.       Measq       : string(1..3);
  906.       Mepos       : string(1..3);
  907.       Essa1       : string(1..2);
  908.       Essa2       : string(1..2);
  909.       Essa3       : string(1..2);
  910.       Essa4       : string(1..2);
  911.       Essa5       : string(1..2);
  912.       Essa6       : string(1..2);
  913.       Essa7       : string(1..2);
  914.       Essa8       : string(1..2);
  915.       Essa9       : string(1..2);
  916.       Eqree       : string(1..2);
  917.       Eqred       : string(1..2);
  918.       Memra       : string(1..3);
  919.       Ersa1       : string(1..2);
  920.       Ersa2       : string(1..2);
  921.       Ersa3       : string(1..2);
  922.       Ersa4       : string(1..2);
  923.       Ersa5       : string(1..2);
  924.       Ersa6       : string(1..2);
  925.       Ersa7       : string(1..2);
  926.       Ersa8       : string(1..2);
  927.       Ersa9       : string(1..2);
  928.     end record;
  929.  
  930.   type Card_Type_KF3 is
  931.     record
  932.       Docnr       : string(1..1);
  933.       Sdoc        : string(1..4);
  934.       Readf       : string(1..1);
  935.       Reasf       : string(1..1);
  936.       Prraf       : string(1..1);
  937.       Prref       : string(1..3);
  938.       Esraf       : string(1..1);
  939.       Esref       : string(1..3);
  940.       Erraf       : string(1..1);
  941.       Erref       : string(1..3);
  942.       Trraf       : string(1..1);
  943.       Trref       : string(1..3);
  944.       Secrf       : string(1..3);
  945.       Terrf       : string(1..3);
  946.       Caraf       : string(1..1);
  947.       Cadaf       : YYMMDD_Types;
  948.       Limf        : string(1..1);
  949.       Rlimf       : string(1..1);
  950.       Ricdf       : YYMMDD_Types;
  951.       Respf       : string(1..5);
  952.     end record;
  953.  
  954.   type Card_Type_KF4 is
  955.     record
  956.       Smcc1       : string(1..2);
  957.       Smra1       : string(1..2);
  958.       Smaa1       : string(1..2);
  959.       Smrc1       : string(1..2);
  960.       Smac1       : string(1..2);
  961.       Smcc2       : string(1..2);
  962.       Smra2       : string(1..2);
  963.       Smaa2       : string(1..2);
  964.       Smrc2       : string(1..2);
  965.       Smac2       : string(1..2);
  966.       Smcc3       : string(1..2);
  967.       Smra3       : string(1..2);
  968.       Smaa3       : string(1..2);
  969.       Smrc3       : string(1..2);
  970.       Smac3       : string(1..2);
  971.       Smcc4       : string(1..2);
  972.       Smra4       : string(1..2);
  973.       Smaa4       : string(1..2);
  974.       Smrc4       : string(1..2);
  975.       Smac4       : string(1..2);
  976.       Gccla       : string(1..2);
  977.       Gcclb       : string(1..2);
  978.       Gcclc       : string(1..2);
  979.       Spclu       : string(1..9);
  980.     end record;
  981.  
  982.   type Card_Type_KN1 is
  983.     record
  984.       Prma        : Prma_Types;
  985.       Marat       : string(1..1);
  986.       Marea       : string(1..3);
  987.       Chdat       : YYMMDD_Types;
  988.       Fmart       : string(1..1);
  989.       Fcdat       : YYMMDD_Types;
  990.     end record;
  991.  
  992.   type Card_Type_TF1 is
  993.     record
  994.       Ueqpt       : string(1..11);
  995.       Mesen       : string(1..4);
  996.       Meqs        : string(1..1);
  997.       Sedy        : string(1..1);
  998.       Tedy        : string(1..1);
  999.       Erddy       : YYMMDD_Types;
  1000.       Avail       : string(1..1);
  1001.       Dcndy       : string(1..5);
  1002.       Eqret       : YYMMDD_Types;
  1003.       Geogr       : string(1..4);
  1004.       Operl       : YYMMDD_Types;
  1005.       Dafld       : string(1..4);
  1006.     end record;
  1007.  
  1008.   type Access_Card_Type_H is access Card_Type_H;
  1009.   type Access_Card_Type_E is access Card_Type_E;
  1010.   type Access_Card_Type_A is access Card_Type_A;
  1011.   type Access_Card_Type_B is access Card_Type_B;
  1012.   type Access_Card_Type_C is access Card_Type_C;
  1013.   type Access_Card_Type_D is access Card_Type_D;
  1014.   type Access_Card_Type_G is access Card_Type_G;
  1015.   type Access_Card_Type_J is access Card_Type_J;
  1016.   type Access_Card_Type_K is access Card_Type_K;
  1017.   type Access_Card_Type_L is access Card_Type_L;
  1018.   type Access_Card_Type_M is access Card_Type_M;
  1019.   type Access_Card_Type_N is access Card_Type_N;
  1020.   type Access_Card_Type_P is access Card_Type_P;
  1021.   type Access_Card_Type_Q is access Card_Type_Q;
  1022.   type Access_Card_Type_T is access Card_Type_T;
  1023.   type Access_Card_Type_V is access Card_Type_V;
  1024.   type Access_Card_Type_X is access Card_Type_X;
  1025.   type Access_Card_Type_R is access Card_Type_R;
  1026.   type Access_Card_Type_DM1 is access Card_Type_DM1;
  1027.   type Access_Card_Type_DN1 is access Card_Type_DN1;
  1028.   type Access_Card_Type_JM1 is access Card_Type_JM1;
  1029.   type Access_Card_Type_KF1 is access Card_Type_KF1;
  1030.   type Access_Card_Type_KF2 is access Card_Type_KF2;
  1031.   type Access_Card_Type_KF3 is access Card_Type_KF3;
  1032.   type Access_Card_Type_KF4 is access Card_Type_KF4;
  1033.   type Access_Card_Type_KN1 is access Card_Type_KN1;
  1034.   type Access_Card_Type_TF1 is access Card_Type_TF1;
  1035.  
  1036.  
  1037. end MSG_Types;
  1038. --::::::::::
  1039. --sys.src
  1040. --::::::::::
  1041. --**********************************************************************
  1042. --
  1043. --
  1044. --                      S Y S T E M   U T I L I T I E S 
  1045. --
  1046. --
  1047. --**********************************************************************
  1048. with msg_types;
  1049. use  msg_types;
  1050. with text_io;
  1051. use  text_io;
  1052.  
  1053. package System_Utilities is
  1054.  
  1055.    type Module_Id is (MMI_ID, MI_ID, MV_ID, DBB_ID, SYS_ID);
  1056.    type Function_Code is (Coldstart_Module,   Restart_Module,
  1057.                           Terminate_Module,   Module_Initialized,
  1058.                           Module_Terminated,  Send_Statistics,
  1059.                           Fixed_Alert,        Variable_Text,
  1060.                           UNITREP_Message,    Validated_Data,
  1061.                           Invalid_Message,    Delete_Record,
  1062.                           Replace_Record,     Add_Record,
  1063.                           Message_On,         Message_Off,
  1064.                           Statistics);
  1065.  
  1066.    type Msg_Card_List;
  1067.    type Access_Msg_Card_List is access Msg_Card_List;
  1068.    type Msg_Card_List is
  1069.      record
  1070.        Next : Access_Msg_Card_List;
  1071.        Card : string(1..80);
  1072.      end record;
  1073.   
  1074.    Text_Length : constant integer := 60;
  1075.    subtype Text_Type is string(1..text_length);
  1076.    type Access_Text_Type is access Text_Type;
  1077.  
  1078.    type Alert_Msg is 
  1079.         (System_Initialized,
  1080.  
  1081.          Invalid_Ftn_Code,   Invalid_Unitrep_Msg, Invalid_Module_Id,
  1082.          Msg_Interface_Down, Msg_Interface_Up,    Dbm_Interface_Down,
  1083.          Dbm_Interface_Up,   Dbm_Full,            Packet_Error,
  1084.          All_Msgs_Processed, No_Msgs_In_Directory,
  1085.  
  1086.          System_Terminated);
  1087.  
  1088.   type Msg_List;
  1089.   type Access_Msg_List is access Msg_List;
  1090.   type Msg_List is
  1091.     record
  1092.       Next        : Access_Msg_List                := null;
  1093.       Card_Number : integer range 2..999;
  1094.       Secur       : Secur_Types;
  1095.       Trtype      : Trtype_Types;
  1096.       Card_Type   : Card_Type_Types;
  1097.       Oruic       : Oruic_Types;
  1098.       Uic         : string(1..6);
  1099.       Access_A    : Access_Card_Type_A   := null;
  1100.       Access_B    : Access_Card_Type_B   := null;
  1101.       Access_C    : Access_Card_Type_C   := null;
  1102.       Access_D    : Access_Card_Type_D   := null;
  1103.       Access_G    : Access_Card_Type_G   := null;
  1104.       Access_J    : Access_Card_Type_J   := null;
  1105.       Access_K    : Access_Card_Type_K   := null;
  1106.       Access_L    : Access_Card_Type_L   := null;
  1107.       Access_M    : Access_Card_Type_M   := null;
  1108.       Access_N    : Access_Card_Type_N   := null;
  1109.       Access_P    : Access_Card_Type_P   := null;
  1110.       Access_Q    : Access_Card_Type_Q   := null;
  1111.       Access_T    : Access_Card_Type_T   := null;
  1112.       Access_V    : Access_Card_Type_V   := null;
  1113.       Access_X    : Access_Card_Type_X   := null;
  1114.       Access_R    : Access_Card_Type_R   := null;
  1115.       Access_DM1  : Access_Card_Type_DM1 := null;
  1116.       Access_DN1  : Access_Card_Type_DN1 := null;
  1117.       Access_JM1  : Access_Card_Type_JM1 := null;
  1118.       Access_KF1  : Access_Card_Type_KF1 := null;
  1119.       Access_KF2  : Access_Card_Type_KF2 := null;
  1120.       Access_KF3  : Access_Card_Type_KF3 := null;
  1121.       Access_KF4  : Access_Card_Type_KF4 := null;
  1122.       Access_KN1  : Access_Card_Type_KN1 := null;
  1123.       Access_TF1  : Access_Card_Type_TF1 := null;
  1124.       Access_H    : Access_Card_Type_H   := null;
  1125.       Access_E    : Access_Card_Type_E   := null;
  1126.     end record;
  1127.  
  1128.    type Packet;
  1129.    type Packet_Access is access Packet;
  1130.    type Packet is
  1131.       record
  1132.          SMID        : Module_Id;
  1133.          RMID        : Module_Id;
  1134.          FTN         : Function_Code;
  1135.          BAP         : Access_Msg_Card_List;
  1136.          VAR_STRING  : Text_Type;
  1137.          VAR_INTEGER : integer;
  1138.          ALERT_ID    : Alert_Msg;
  1139.          NEXT        : Packet_Access;
  1140.          MSG_PTR     : Access_Msg_List;
  1141.       end record;
  1142. --Null task packet parameters for the possibly unused fields:
  1143.          TP1 : Access_Msg_Card_List;
  1144.          TP2 : Text_Type;
  1145.          TP3 : integer;
  1146.          TP4 : Alert_Msg;
  1147.          TP5 : Access_Msg_List;
  1148.  
  1149.    procedure TPSEND (SMID, RMID  : in Module_Id;
  1150.                      FTN         : in Function_Code;
  1151.                      BAP         : in Access_Msg_Card_List;
  1152.                      VAR_STRING  : in Text_Type;
  1153.                      VAR_INTEGER : in integer;
  1154.                      ALERT_ID    : in Alert_Msg;
  1155.                      MSG_PTR     : in Access_Msg_List);
  1156.  
  1157.   type Queue is
  1158.      record
  1159.        First:Packet_Access:=null;
  1160.        Last :Packet_Access:=null;
  1161.        Count:integer:= 0;
  1162.      end record;
  1163.   MI_Queue, MV_Queue, DBB_Queue, MMI_Queue : Queue;
  1164.  
  1165.   subtype Str3 is string(1..3);
  1166.   function String_To_Integer(s : in string) return integer;
  1167.  
  1168.   function Integer_To_String(Number: in integer) return Str3;
  1169.  
  1170.  
  1171. end System_Utilities;
  1172.  
  1173.  
  1174. package body System_Utilities is
  1175.  
  1176.  
  1177. --**********************************************************************
  1178. --                                 TPSEND
  1179. --
  1180. --  This routine builds and queues task packets to the receiving modules
  1181. --  as specified by the sending module.  
  1182. --**********************************************************************
  1183.  
  1184.  
  1185.    procedure TPSEND (SMID, RMID : in Module_Id;
  1186.                      FTN : in Function_Code;
  1187.                      BAP : in Access_Msg_Card_List;
  1188.                      VAR_STRING : in text_type;
  1189.                      VAR_INTEGER : in integer;
  1190.                      ALERT_ID : in Alert_Msg;
  1191.                      MSG_PTR : in Access_Msg_List) is
  1192.  
  1193.       T,P:Packet_Access;
  1194.    begin
  1195.       T:= new Packet;
  1196.       T.SMID:= SMID;
  1197.       T.RMID:= RMID;
  1198.       T.FTN:= FTN;
  1199.       T.BAP:= BAP;
  1200.       T.VAR_STRING:= VAR_STRING;
  1201.       T.VAR_INTEGER:= VAR_INTEGER;
  1202.       T.ALERT_ID:= ALERT_ID;
  1203.       T.MSG_PTR:= MSG_PTR;
  1204.       
  1205.       case RMID is
  1206.          when DBB_ID => 
  1207.             if DBB_Queue.First = null then
  1208.                DBB_Queue.First:=T;
  1209.                DBB_Queue.Last:= T;
  1210.                DBB_Queue.Count:= 1;
  1211.            else
  1212.                P:=DBB_Queue.Last;
  1213.                P.Next:= T;
  1214.                DBB_Queue.Last:= T;
  1215.                DBB_Queue.Count:= DBB_Queue.Count + 1;
  1216.             end if;
  1217.  
  1218.          when MI_ID => 
  1219.             if MI_Queue.First = null then
  1220.                MI_Queue.First:= T;
  1221.                MI_Queue.Last:= T;
  1222.                MI_Queue.Count:= 1;
  1223.             else
  1224.                P:=MI_Queue.Last;
  1225.                P.Next:= T;
  1226.                MI_Queue.Last:= T;
  1227.                MI_Queue.Count:= MI_Queue.Count + 1;
  1228.             end if;
  1229.  
  1230.          when MV_ID => 
  1231.             if MV_Queue.First = null then
  1232.                MV_Queue.First:= T;
  1233.                MV_Queue.Last:= T;
  1234.                MV_Queue.Count:= 1;
  1235.             else
  1236.                P:=MV_Queue.Last;
  1237.                P.Next:= T;
  1238.                MV_Queue.Last:= T;
  1239.                MV_Queue.Count:= MV_Queue.Count + 1;
  1240.             end if;
  1241.  
  1242.          when MMI_ID => 
  1243.             if MMI_Queue.First = null then
  1244.                MMI_Queue.First:= T;
  1245.                MMI_Queue.Last:= T;
  1246.                MMI_Queue.Count:= 1;
  1247.             else
  1248.                P:=MMI_Queue.Last;
  1249.                P.Next:= T;
  1250.                MMI_Queue.Last:= T;
  1251.                MMI_Queue.Count:= MMI_Queue.Count + 1;
  1252.             end if;
  1253.          when others => 
  1254.            TPSEND(SYS_ID,MMI_ID,Fixed_Alert,TP1,
  1255.                   TP2,TP3,Packet_Error,TP5);
  1256.       end case;
  1257.  
  1258.  
  1259. exception
  1260.    when constraint_error =>
  1261.      put_line("TPSEND CONSTRAINT ERROR");
  1262.      TPSEND(SYS_ID,MMI_ID,Fixed_Alert,TP1,TP2,TP3,Packet_Error,TP5);
  1263.    when others =>
  1264.      put_line("TPSEND OTHER ERRORS");
  1265.   end TPSEND;
  1266.  
  1267.  
  1268. --**********************************************************************
  1269. --                          String To Integer
  1270. --  This routine converts a three character string to a integer.
  1271. --**********************************************************************
  1272.  
  1273.   function String_To_Integer(s : in string) return integer is
  1274.     val_int, i, exp : integer;
  1275.   begin
  1276.     exp := 10;
  1277.     i   := 0;
  1278.     val_int  := 0;
  1279.     for j in s'range loop
  1280.       if s(j) = '0' then
  1281.         i := 0;
  1282.       elsif s(j) = '1' then
  1283.         i := 1;
  1284.       elsif s(j) = '2' then
  1285.         i := 2;
  1286.       elsif s(j) = '3' then
  1287.         i := 3;
  1288.       elsif s(j) = '4' then
  1289.         i := 4;
  1290.       elsif s(j) = '5' then
  1291.         i := 5;
  1292.       elsif s(j) = '6' then
  1293.         i := 6;
  1294.       elsif s(j) = '7' then
  1295.         i := 7;
  1296.       elsif s(j) = '8' then
  1297.         i := 8;
  1298.       elsif s(j) = '9' then
  1299.         i := 9;
  1300.       else
  1301.         raise constraint_error;
  1302.       end if;
  1303.  
  1304.       val_int := val_int + (i * (exp ** (s'last - j)));
  1305.  
  1306.     end loop;
  1307.  
  1308.     return val_int;
  1309.  
  1310.   exception
  1311.     when others           => return -1;
  1312.   end String_To_Integer;
  1313.  
  1314.  
  1315. --**********************************************************************
  1316. --                         Integer To String
  1317. --   This routine converts an integer to a three digit string.
  1318. --**********************************************************************
  1319.  
  1320.   function Integer_To_String(Number: in integer) return Str3 is
  1321.     s1 : string(1..4);
  1322.     s  : Str3;
  1323.  
  1324.   begin
  1325.     s := "000";
  1326.     if Number < 0 or Number > 999 then
  1327.       s := "***";
  1328.     elsif Number < 10 then
  1329.       s1(1..2) := integer'image(Number);
  1330.       s(3..3)  := s1(2..2);
  1331.     elsif Number < 100 then
  1332.       s1(1..3) := integer'image(Number);
  1333.       s(2..3)  := s1(2..3);
  1334.     else
  1335.       s1(1..4) := integer'image(Number);
  1336.       s        := s1(2..4);
  1337.     end if;
  1338.  
  1339.     return s;
  1340.  
  1341.   exception
  1342.     when others   => put_line("integer to string dead");
  1343.   end Integer_To_String;
  1344.  
  1345. begin
  1346.   null;
  1347.  
  1348.   exception
  1349.     when others => put_line("system utilities dead");
  1350. end System_Utilities;
  1351. --::::::::::
  1352. --idmio.src
  1353. --::::::::::
  1354. with idm_defs;
  1355. use  idm_defs;
  1356.  
  1357. package idm_io is
  1358.  
  1359.   procedure idm_abort(idmrun : in out idmrun_type);
  1360.  
  1361.   procedure idm_begin(idmrun : in out idmrun_type);
  1362.  
  1363.   procedure idm_cancel(idmrun : in out idmrun_type);
  1364.  
  1365.   procedure idm_closerun(idmrun : in out idmrun_type);
  1366.  
  1367.   procedure idm_column(idmrun : in out idmrun_type;
  1368.                        column : in positive;
  1369.                        result : out integer);
  1370.  
  1371.   procedure idm_column(idmrun : in out idmrun_type;
  1372.                        column : in positive;
  1373.                        result : out float);
  1374.  
  1375.   procedure idm_column(idmrun : in out idmrun_type;
  1376.                        column : in positive;
  1377.                        result : out string;
  1378.                        last   : out natural);
  1379.  
  1380.   procedure idm_command(idmrun  : in out idmrun_type;
  1381.                         command : in string);
  1382.  
  1383.   procedure idm_describe(idmrun : in out idmrun_type;
  1384.                          column : in positive;
  1385.                          format : out idm_data_type;
  1386.                          width  : out positive;
  1387.                          name   : out string;
  1388.                          last   : out natural);
  1389.  
  1390.   procedure idm_end(idmrun : in out idmrun_type);
  1391.  
  1392.   procedure idm_execute(idmrun : in out idmrun_type);
  1393.  
  1394.   procedure idm_fetch(idmrun : in out idmrun_type);
  1395.  
  1396.   procedure idm_flush(idmrun : in out idmrun_type);
  1397.  
  1398.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1399.                           result : out idm_exception;
  1400.                           itemid : in idm_status_type);
  1401.  
  1402.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1403.                           result : out integer;
  1404.                           itemid : in idm_status_type);
  1405.  
  1406.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1407.                           result : out boolean;
  1408.                           itemid : in idm_status_type);
  1409.  
  1410.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1411.                           result : out integer;
  1412.                           itemid : in idm_status_type;
  1413.                           errno  : in positive);
  1414.  
  1415.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1416.                           result : out string;
  1417.                           itemid : in idm_status_type;
  1418.                           errno  : in positive;
  1419.                           last   : out natural);
  1420.  
  1421.   procedure idm_initrun(printerrs : in boolean := true);
  1422.  
  1423.   procedure idm_nextcmd(idmrun : in out idmrun_type);
  1424.  
  1425.   procedure idm_opendb(idmrun : in out idmrun_type;
  1426.                        dbname : in string);
  1427.  
  1428.   procedure idm_openrun(idmrun : in out idmrun_type;
  1429.                         name   : in string);
  1430.  
  1431.   procedure idm_param(idmrun  : in out idmrun_type;
  1432.                       param   : in string;
  1433.                       value   : in integer;
  1434.                       convert : in idm_data_type := idm_int2);
  1435.  
  1436.   procedure idm_param(idmrun  : in out idmrun_type;
  1437.                       param   : in string;
  1438.                       value   : in float;
  1439.                       convert : in idm_data_type := idm_flt4);
  1440.  
  1441.   procedure idm_param(idmrun  : in out idmrun_type;
  1442.                       param   : in string;
  1443.                       value   : in string;
  1444.                       convert : in idm_data_type := idm_char);
  1445.  
  1446. end idm_io;
  1447.  
  1448. package body idm_io is
  1449.  
  1450.   procedure idm_abort(idmrun : in out idmrun_type) is
  1451.   begin
  1452.     null;
  1453.   end idm_abort;
  1454.  
  1455.   procedure idm_begin(idmrun : in out idmrun_type) is
  1456.   begin
  1457.     null;
  1458.   end idm_begin;
  1459.  
  1460.   procedure idm_cancel(idmrun : in out idmrun_type) is
  1461.   begin
  1462.     null;
  1463.   end idm_cancel;
  1464.  
  1465.   procedure idm_closerun(idmrun : in out idmrun_type) is
  1466.   begin
  1467.     null;
  1468.   end idm_closerun;
  1469.  
  1470.   procedure idm_column(idmrun : in out idmrun_type;
  1471.                        column : in positive;
  1472.                        result : out integer) is
  1473.   begin
  1474.     null;
  1475.   end idm_column;
  1476.  
  1477.   procedure idm_column(idmrun : in out idmrun_type;
  1478.                        column : in positive;
  1479.                        result : out float) is
  1480.   begin
  1481.     null;
  1482.   end idm_column;
  1483.  
  1484.   procedure idm_column(idmrun : in out idmrun_type;
  1485.                        column : in positive;
  1486.                        result : out string;
  1487.                        last   : out natural) is
  1488.   begin
  1489.     null;
  1490.   end idm_column;
  1491.  
  1492.   procedure idm_command(idmrun  : in out idmrun_type;
  1493.                         command : in string) is
  1494.   begin
  1495.     null;
  1496.   end idm_command;
  1497.  
  1498.   procedure idm_describe(idmrun : in out idmrun_type;
  1499.                          column : in positive;
  1500.                          format : out idm_data_type;
  1501.                          width  : out positive;
  1502.                          name   : out string;
  1503.                          last   : out natural) is
  1504.   begin
  1505.     null;
  1506.   end idm_describe;
  1507.  
  1508.   procedure idm_end(idmrun : in out idmrun_type) is
  1509.   begin
  1510.     null;
  1511.   end idm_end;
  1512.  
  1513.   procedure idm_execute(idmrun : in out idmrun_type) is
  1514.   begin
  1515.     null;
  1516.   end idm_execute;
  1517.  
  1518.   procedure idm_fetch(idmrun : in out idmrun_type) is
  1519.   begin
  1520.     null;
  1521.   end idm_fetch;
  1522.  
  1523.   procedure idm_flush(idmrun : in out idmrun_type) is
  1524.   begin
  1525.     null;
  1526.   end idm_flush;
  1527.  
  1528.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1529.                           result : out idm_exception;
  1530.                           itemid : in idm_status_type) is
  1531.   begin
  1532.     null;
  1533.   end idm_getstatus;
  1534.  
  1535.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1536.                           result : out integer;
  1537.                           itemid : in idm_status_type) is
  1538.   begin
  1539.     null;
  1540.   end idm_getstatus;
  1541.  
  1542.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1543.                           result : out boolean;
  1544.                           itemid : in idm_status_type) is
  1545.   begin
  1546.     null;
  1547.   end idm_getstatus;
  1548.  
  1549.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1550.                           result : out integer;
  1551.                           itemid : in idm_status_type;
  1552.                           errno  : in positive) is
  1553.   begin
  1554.     null;
  1555.   end idm_getstatus;
  1556.  
  1557.   procedure idm_getstatus(idmrun : in out idmrun_type;
  1558.                           result : out string;
  1559.                           itemid : in idm_status_type;
  1560.                           errno  : in positive;
  1561.                           last   : out natural) is
  1562.   begin
  1563.     null;
  1564.   end idm_getstatus;
  1565.  
  1566.   procedure idm_initrun(printerrs : in boolean := true) is
  1567.   begin
  1568.     null;
  1569.   end idm_initrun;
  1570.  
  1571.   procedure idm_nextcmd(idmrun : in out idmrun_type) is
  1572.   begin
  1573.     null;
  1574.   end idm_nextcmd;
  1575.  
  1576.   procedure idm_opendb(idmrun : in out idmrun_type;
  1577.                        dbname : in string) is
  1578.   begin
  1579.     null;
  1580.   end idm_opendb;
  1581.  
  1582.   procedure idm_openrun(idmrun : in out idmrun_type;
  1583.                         name   : in string) is
  1584.   begin
  1585.     null;
  1586.   end idm_openrun;
  1587.  
  1588.   procedure idm_param(idmrun  : in out idmrun_type;
  1589.                       param   : in string;
  1590.                       value   : in integer;
  1591.                       convert : in idm_data_type := idm_int2) is
  1592.   begin
  1593.     null;
  1594.   end idm_param;
  1595.  
  1596.   procedure idm_param(idmrun  : in out idmrun_type;
  1597.                       param   : in string;
  1598.                       value   : in float;
  1599.                       convert : in idm_data_type := idm_flt4) is
  1600.   begin
  1601.     null;
  1602.   end idm_param;
  1603.  
  1604.   procedure idm_param(idmrun  : in out idmrun_type;
  1605.                       param   : in string;
  1606.                       value   : in string;
  1607.                       convert : in idm_data_type := idm_char) is
  1608.   begin
  1609.     null;
  1610.   end idm_param;
  1611.  
  1612. end idm_io;
  1613. --::::::::::
  1614. --mmi.src
  1615. --::::::::::
  1616. --**********************************************************************
  1617. --
  1618. --
  1619. --                   M A N / M A C H I N E   I N T E R F A C E
  1620. --
  1621. --
  1622. --**********************************************************************
  1623. with text_io;
  1624. with System_Utilities;
  1625. use  text_io;
  1626. use  System_Utilities;
  1627.  
  1628. package Man_Machine_Interface is
  1629.  
  1630.   task MMI_Packet_Path is
  1631.     entry Packet_Process(PP : in packet_access);
  1632.   end MMI_Packet_Path;
  1633.  
  1634.  
  1635. end Man_Machine_Interface;
  1636.  
  1637.  
  1638. package body Man_Machine_Interface is
  1639.  
  1640.   task Command_Entry is
  1641.     entry Enable_Operator_Input;
  1642.   end Command_Entry;
  1643.  
  1644.   procedure Msg_Out(P   : in packet_access);
  1645.   procedure Sys_Term(P  : in packet_access);
  1646.   procedure Print_Messages(B : in Access_Msg_Card_List);
  1647.   procedure Initialization;
  1648.   procedure Accept_Text(read_me : out text_type);
  1649.   procedure Alert_Out(P : in packet_access);
  1650.   procedure Stats_Out(P : in packet_access);
  1651.   procedure Init_Completed(P : in packet_access);
  1652.   function  Demand_Yes(write_me : in text_type) return boolean;
  1653.  
  1654.   type Alert_Text_Type is array(alert_msg range
  1655.                                 system_initialized..system_terminated)
  1656.                                 of text_type;
  1657.  
  1658.   Alert_Text                     : Alert_Text_Type :=
  1659.        ("System Initialization Complete                              ",
  1660.         "Received task packet with invalid function code field value ",
  1661.         "Invalid Unitrep Message                                     ",
  1662.         "Invalid Module Id                                           ",
  1663.         "Message Interface Down                                      ",
  1664.         "Message Interface Up                                        ",
  1665.         "Database Interface Down                                     ",
  1666.         "Database Interface Up                                       ",
  1667.         "Database Full                                               ",
  1668.         "There is an error in the task packet data.                  ",
  1669.         "Have processed all messages in current UNITREP directory    ",
  1670.         "No UNITREP messages in specified directory                  ",
  1671.         "System Termination Complete                                 ");
  1672.  
  1673.   Message_Interface_On           : boolean := FALSE;
  1674.   MI_Init_Flag, MV_Init_Flag     : boolean := FALSE;
  1675.   DBB_Init_Flag                  : boolean := false;
  1676.   DBB_Term_Flag                  : boolean := false;
  1677.   MI_Term_Flag, MV_Term_Flag     : boolean := false;
  1678.   MI_STATS_FLAG, MV_STATS_FLAG   : boolean := false;
  1679.   DBB_STATS_FLAG                 : boolean := false;
  1680.   type Command_Types is (start, stop, ss, term);
  1681.   Command                        : Command_Types;
  1682.  
  1683. --**********************************************************************
  1684. --                          Command Entry
  1685. --  This is the operator entry validation task.
  1686. --**********************************************************************
  1687.  
  1688. task body Command_Entry is
  1689.   temp,Tbuf : text_type :=
  1690.      "                                                            ";
  1691.     --123456789 123456789 123456789 123456789 123456789 123456789 
  1692.   Invalid_Command : boolean;
  1693. begin
  1694.   --initialize system
  1695.   Initialization;
  1696.   loop --task loop
  1697.     --entry point to this task
  1698.     accept Enable_Operator_Input;
  1699.     Invalid_Command:= True;
  1700.     while Invalid_Command loop
  1701.       --initialize i/o buffer
  1702.       temp:= "                                                            ";
  1703. put_line(temp);
  1704.       temp:= " Valid Commands    Description                              ";
  1705. put_line(temp);
  1706.       temp:= "ss.................Receive Statistical Information          ";
  1707. put_line(temp);
  1708.       temp:= "term...............Shutdown the System                      ";
  1709. put_line(temp);
  1710.       temp:= "start..............Start Message Interface and Validation   ";
  1711. put_line(temp);
  1712.       temp:= "stop...............Stop Message Interface and Validation    ";
  1713. put_line(temp);
  1714.       temp:= "                                                            ";
  1715.       put_line(temp);
  1716.       temp(1..15):= "Enter command: ";
  1717.       put_line(temp);
  1718.       accept_text(Tbuf);
  1719.       begin
  1720.         Command := Command_Types'value(Tbuf);
  1721.         case Command is
  1722.           when start => 
  1723.         Invalid_Command:= False;
  1724.             if Message_Interface_On then
  1725.               temp(1..33):= "Message Interface already started";
  1726.               put_line(temp);
  1727.             else
  1728.               temp(1..40):= "Enter name of UNITREP message directory:";
  1729.               put_line(temp);
  1730.               accept_text(Tbuf);
  1731.               tpsend(mmi_id,mi_id,message_on,tp1,Tbuf,tp3,tp4,tp5);
  1732.               Message_Interface_On:= TRUE;
  1733.             end if;
  1734.  
  1735.           when stop  =>
  1736.             if not Message_Interface_On then
  1737.               temp(1..33):= "Message Interface already stopped";
  1738.               put_line(temp);
  1739.           Invalid_Command:= True;
  1740.             else  --turn message interface off
  1741.               tpsend(mmi_id,mi_id,message_off,tp1,tp2,tp3,tp4,tp5);
  1742.           Invalid_Command:= False;
  1743.             end if;
  1744.  
  1745.           when ss    => Invalid_Command:= False;
  1746.             tpsend(mmi_id,mi_id,send_statistics,tp1,tp2,tp3,tp4,tp5);
  1747.             tpsend(mmi_id,mv_id,send_statistics,tp1,tp2,tp3,tp4,tp5);
  1748.             tpsend(mmi_id,dbb_id,send_statistics,tp1,tp2,tp3,tp4,tp5);
  1749.  
  1750.           when term  => Invalid_Command:= False;
  1751.             tpsend(mmi_id,mi_id,terminate_module,tp1,tp2,tp3,tp4,tp5);
  1752.             tpsend(mmi_id,mv_id,terminate_module,tp1,tp2,tp3,tp4,tp5);
  1753.             tpsend(mmi_id,dbb_id,terminate_module,tp1,tp2,tp3,tp4,tp5);
  1754.  
  1755.         end case;
  1756.  
  1757.         exception
  1758.           when constraint_error =>
  1759.             temp(1..33):= "Command not valid,   try again...";
  1760.             put_line(temp);
  1761.             Invalid_Command:= True;
  1762.           when others           =>
  1763.             put_line("Problem in declare block of command entry");
  1764.       end;
  1765.  
  1766.     end loop;
  1767.  
  1768.   end loop;
  1769.  
  1770.     exception
  1771.        when others => put_line("Command Entry dead");
  1772. end Command_Entry;
  1773.  
  1774. --**********************************************************************
  1775. --                             MMI_Packet_Path
  1776. --
  1777. --  This task handles the reception and processing of task packets from
  1778. --  the other system modules.  The inputs will be received from the
  1779. --  MMI_Monitor task with the input being the packet pointer.
  1780. --**********************************************************************
  1781.  
  1782. task body MMI_Packet_Path is
  1783.   P : packet_access;
  1784. begin
  1785.   loop
  1786.     accept Packet_Process(PP:in packet_access) do
  1787.       P:= PP;
  1788.     end Packet_Process;
  1789.  
  1790.     case P.FTN is
  1791.       when Fixed_Alert        => Alert_Out(P);
  1792.       when Variable_Text      => Msg_Out(P);
  1793.       when Statistics         => Stats_Out(P);
  1794.       when Module_Terminated  => Sys_Term(P);
  1795.       when Module_Initialized => Init_Completed(P);
  1796.       when Invalid_Message    => Print_Messages(P.BAP);
  1797.  
  1798.       when others             => put_line(Alert_Text(invalid_ftn_code));
  1799.     end case;
  1800.  
  1801.   end loop;
  1802.  
  1803.   exception
  1804.     when others => put_line("MMI Packet Path dead");
  1805. end MMI_Packet_Path;
  1806.  
  1807. --**********************************************************************
  1808. --                                Alert_Out
  1809. --
  1810. --  This routine outputs the fixed text alerts to the operator.  The
  1811. --  input is task packet pointer to the packet containing the fixed text
  1812. --  alert message name.
  1813. --**********************************************************************
  1814.  
  1815. procedure Alert_Out(P : in packet_access) is
  1816.   
  1817. begin
  1818.   put_line(Alert_Text(P.alert_id));
  1819.   case P.alert_id is
  1820.     when Msg_Interface_Down => Message_Interface_On:= FALSE;
  1821.                    Command_Entry.Enable_Operator_Input;
  1822.     when others             => null;
  1823.   end case;
  1824.  
  1825.   exception
  1826.     when others => put_line("alert out dead");
  1827. end Alert_Out;
  1828.  
  1829. --**********************************************************************
  1830. --                           Stats_Out
  1831. --  This routine converts the value held in the VAR_INTEGER field of the
  1832. --  packet to ASCII then outputs this collected statistical value after
  1833. --  the title held in the VAR_STRING field of the packet.
  1834. --**********************************************************************
  1835.  
  1836. procedure Stats_Out(P : in packet_access) is
  1837.   T : text_type
  1838.   :="                                                            ";
  1839. --   123456789 123456789 123456789 123456789 123456789 123456789 
  1840.   S : str3;
  1841. begin
  1842.   S := integer_to_string(P.VAR_INTEGER);
  1843.   T(1..3):= S;
  1844.   put(P.VAR_STRING);
  1845.   put_line(T);
  1846.   case p.smid is
  1847.     when MI_ID  => MI_STATS_FLAG := true;
  1848.     when MV_ID  => MV_STATS_FLAG := true;
  1849.     when DBB_ID => DBB_STATS_FLAG:= true;
  1850.     when others => put_line("Error in STATS_OUT case statement");
  1851.   end case;
  1852.   if (MI_STATS_FLAG and MV_STATS_FLAG and DBB_STATS_FLAG)
  1853.     then
  1854.       MI_STATS_FLAG := false;
  1855.       MV_STATS_FLAG := false;
  1856.       DBB_STATS_FLAG := false;
  1857.       Command_Entry.Enable_Operator_Input;
  1858.   end if;
  1859.  
  1860.   exception
  1861.     when others => put_line("stats out dead");
  1862. end Stats_Out;
  1863.  
  1864. --**********************************************************************
  1865. --                          Init Completed
  1866. --  Processes the initialization complete task packets received from the
  1867. --  other system modules.  When all have been received, the operator is
  1868. --  notified.
  1869. --**********************************************************************
  1870.  
  1871. procedure Init_Completed(P : in packet_access) is
  1872.  
  1873. begin
  1874.   case P.smid is 
  1875.     when MI_ID  => MI_Init_Flag := TRUE;
  1876.     when MV_ID  => MV_Init_Flag := TRUE;
  1877.     when DBB_ID => DBB_Init_Flag:= TRUE;
  1878.     
  1879.     when others => put_line("problem with case in init completed");
  1880.   end case;
  1881.  
  1882.   if (MI_Init_Flag and MV_Init_Flag and DBB_Init_Flag) then
  1883.     --notify operator that system is initialized
  1884.     put_line(Alert_Text(system_initialized));
  1885.     --reset initialization flags
  1886.     MI_Init_Flag := False;
  1887.     MV_Init_Flag := False;
  1888.     DBB_Init_Flag:= False;
  1889.     --enable operator entry of commands
  1890.     Command_Entry.Enable_Operator_Input;
  1891.   end if;
  1892.  
  1893. end Init_Completed;
  1894.  
  1895.  
  1896. --**********************************************************************
  1897. --                                Msg_Out
  1898. --
  1899. --  This routine outputs the variable text alerts to the operator.  The
  1900. --  input is a task packet pointer to the packet containing the variable
  1901. --  text alert message.
  1902. --**********************************************************************
  1903.  
  1904. procedure Msg_Out(P : in packet_access) is
  1905.   
  1906. begin
  1907.  
  1908.   put_line(P.var_string);
  1909.  
  1910.   exception
  1911.     when others => put_line("msg out dead");
  1912. end Msg_Out;
  1913.  
  1914.  
  1915. --**********************************************************************
  1916. --                            Sys_Term
  1917. --
  1918. --  This routine receives the system termination complete packets from
  1919. --  the various system modules.   When all modules have responded,  this
  1920. --  routine outputs a system terminated notification to the operator
  1921. --  then terminates the system.  
  1922. --**********************************************************************
  1923.  
  1924. procedure Sys_Term(P : in packet_access) is
  1925.  
  1926. begin
  1927.   case P.SMID is
  1928.     when MI_ID  => MI_Term_Flag := true;
  1929.     when MV_ID  => MV_Term_Flag := true;
  1930.     when DBB_ID => DBB_Term_Flag:= true;
  1931.  
  1932.     when others => put_line(Alert_Text(packet_error));
  1933.   end case;
  1934.  
  1935.   if (MI_Term_Flag and MV_Term_Flag and DBB_Term_Flag) then
  1936.     --notify operator that system is terminated
  1937.     put_line(Alert_Text(system_terminated));
  1938.     --reset termination flags
  1939.     MI_Term_Flag := False;
  1940.     MV_Term_Flag := False;
  1941.     DBB_Term_Flag:= False;
  1942.     --reinitialize system, Ask operator to coldstart or restart
  1943.     Initialization;
  1944.   end if;
  1945.  
  1946.   exception
  1947.     when others => put_line("sys term dead");
  1948. end Sys_Term;
  1949.  
  1950.  
  1951. --**********************************************************************
  1952. --                           Print Messages
  1953. --  This routine prints the invalid UNITREP messages for the operator.
  1954. --**********************************************************************
  1955.  
  1956. procedure Print_Messages(B : in Access_Msg_Card_List) is
  1957.   Message : Access_Msg_Card_List;
  1958. begin
  1959.   Message := B;
  1960.   loop
  1961.     exit when Message.next = null;
  1962.     Message := Message.next;
  1963.     put_line(Message.card);
  1964.   end loop;
  1965.  
  1966. end Print_Messages;
  1967.  
  1968.  
  1969. --**********************************************************************
  1970. --                            Initialization
  1971. --  This routine performs the system initialization querying of the
  1972. --  operator and sends the initialization task packets to the other
  1973. --  system modules.
  1974. --**********************************************************************
  1975.  
  1976. procedure Initialization is
  1977.   Coldstart, Done : boolean;
  1978.   T : text_type
  1979.   :="                                                            ";
  1980. --   123456789 123456789 123456789 123456789 123456789 123456789 
  1981.   F : function_code;
  1982. begin
  1983.   --query operator for system coldstart or restart
  1984.   T(1..21):= "Coldstart the System?";
  1985.   if demand_yes(T) then
  1986.     Coldstart:= TRUE;
  1987.     F:= Coldstart_Module;
  1988.   else
  1989.     Coldstart:= FALSE;
  1990.     F:= Restart_Module;
  1991.   end if;
  1992.   --coldstart/restart system modules
  1993.   tpsend(mmi_id,mi_id,F,tp1,tp2,tp3,tp4,tp5);
  1994.   tpsend(mmi_id,mv_id,F,tp1,tp2,tp3,tp4,tp5);
  1995.   tpsend(mmi_id,dbb_id,F,tp1,tp2,tp3,tp4,tp5);
  1996.  
  1997.   exception
  1998.     when others => put_line("initialization dead");
  1999. end Initialization;
  2000.  
  2001.  
  2002. procedure Accept_Text(read_me : out text_type) is
  2003.   i:integer;
  2004. begin
  2005.   put(">");
  2006.   for i in 1..text_length loop
  2007.     read_me(i):= ' ';
  2008.   end loop;
  2009.   get_line(read_me,i);
  2010. end Accept_Text;
  2011.  
  2012. function Demand_Yes(write_me : in text_type) return boolean is
  2013.   temp : text_type;
  2014. begin
  2015.   loop
  2016.     put_line(write_me);
  2017.     accept_text(temp);
  2018.     if (temp(1..3) = "yes") or
  2019.        (temp(1) = 'y') then return true;
  2020.     elsif (temp(1..2) = "no") or
  2021.           (temp(1) = 'n') then return false;
  2022.     end if;
  2023.     temp(1..30):="Please answer yes or no...    ";
  2024.     put_line(temp);
  2025.   end loop;
  2026. end Demand_Yes;
  2027.  
  2028.  
  2029. begin --mmi
  2030.   null;
  2031.  
  2032.   exception
  2033.     when constraint_error => put_line("MMI constraint error");
  2034.     when others => put_line("MMI dead");
  2035. end Man_Machine_Interface;
  2036. --::::::::::
  2037. --msginput.src
  2038. --::::::::::
  2039.             --  MESSAGE INPUT MODULE PACKAGE SPECIFICATIONS AND BODY
  2040.  
  2041. with text_io;
  2042. use  text_io;
  2043. with System_Utilities;
  2044. use  System_Utilities;
  2045.  
  2046. package Message_Input_Module is
  2047.  
  2048.   task Message_Request is
  2049.     entry Request_Function(R : in packet_access);
  2050.   end Message_Request;
  2051.  
  2052. end Message_Input_Module;
  2053.  
  2054.  
  2055. package body Message_Input_Module is
  2056.  
  2057.   task Message_Interface is
  2058.     entry Input_Function(R : in packet_access);
  2059.   end Message_Interface;
  2060.  
  2061.   procedure Read_Unitrep_Messages(Receive_a_packet : in packet_access);
  2062.  
  2063.   Stop_Interface_Flag   : boolean := false;
  2064.   Terminate_Input_Flag  : boolean := false;
  2065.   Queued_Messages       : integer := 0;
  2066.   Total_Queued_Messages : integer := 0;
  2067.   First_Message_List    : access_msg_card_list;
  2068.   Message_List          : access_msg_card_list;
  2069.   Last_Message_Flag     : integer := 0;
  2070.   Input_Initialized     : boolean := false;
  2071.   tmp_text              : string(1..60) :=
  2072.      "                                                            ";
  2073. --    123456789 123456789 123456789 123456789 123456789 123456789
  2074.   Blank_Card            : constant string(1..80) :=
  2075.      "                                        " &
  2076.      "                                        ";
  2077. --    123456789 123456789 123456789 123456789 
  2078.   I                     : integer := 0;
  2079.   I1                    : integer := 0;
  2080.   Message_File   : file_type;
  2081.  
  2082. --**********************************************************************
  2083. --
  2084. --     MESSAGE_REQUEST
  2085. --
  2086. --  This Task is the main controlling task of the Message Input Module.
  2087. --  It receives commands from the Man/Machine Interface (MMI), validates
  2088. --  and processes the command.  The Message Interface Task is turned on
  2089. --  and off from this task.
  2090. --
  2091. --**********************************************************************
  2092.  
  2093.   task body Message_Request is
  2094.     Receive_a_packet : packet_access;
  2095.   begin
  2096.       loop
  2097.         accept Request_Function(R : in packet_access) do
  2098.           Receive_a_packet := R;
  2099.         end Request_Function;
  2100.     --
  2101.     --  validation and processing of request
  2102.     --
  2103.     --  requests handled
  2104.     --        Restart_Module    => initialize flags
  2105.     --                             clear buffers
  2106.     --        Message_On        => turn on message interface
  2107.     --        Message_Off       => set Stop_Interface_Flag to
  2108.     --                             turn off message interface
  2109.     --        Terminate_Module  => set Terminate_Module_Flag to
  2110.     --                             turn off message interface
  2111.     --        Send_Statistics   => queue statistics to MMI
  2112.     --        Coldstart_Module  => zero statistics
  2113.     --                             clear buffers
  2114.     --                             initialize flags
  2115.     --        others            => invalid request queue to MMI
  2116.     --                             with message stating invalid
  2117.     --
  2118.         if not Input_Initialized then
  2119.           if Receive_a_packet.ftn = Coldstart_Module or
  2120.              Receive_a_packet.ftn = Restart_Module then
  2121.             Input_Initialized      := true;
  2122.             Terminate_Input_Flag := false;
  2123.             Stop_Interface_Flag   := true;
  2124.             Last_Message_Flag     := -1;
  2125.             First_Message_List    := null;
  2126.             Message_List          := null;
  2127.             if Receive_a_packet.ftn = Coldstart_Module then
  2128.               Total_Queued_Messages       := 0;
  2129.             end if;
  2130.               tpsend(mi_id,mmi_id,module_initialized,tp1,
  2131.                      tp2,tp3,tp4,tp5);
  2132.           else
  2133.            tpsend(mi_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2134.                   invalid_ftn_code,tp5);
  2135.           end if;
  2136.         else
  2137.           case Receive_a_packet.ftn is
  2138.             when Message_On       =>
  2139.               Stop_Interface_Flag := false;
  2140.               Last_Message_Flag   := 0;
  2141.               Message_Interface.Input_Function(Receive_a_packet);
  2142.             when Message_Off      =>
  2143.               Stop_Interface_Flag  := true;
  2144.             when Terminate_Module =>
  2145.               Terminate_Input_Flag:= true;
  2146.               if Last_Message_Flag = -1 then
  2147.                 tpsend(mi_id,mmi_id,module_terminated,
  2148.                        tp1,tp2,tp3,tp4,tp5);
  2149.                 Input_initialized := false;
  2150.               end if;
  2151.             when Send_Statistics  =>
  2152.               Tmp_Text(1..32) := "Number of UNITREP Messages Input";
  2153.               tpsend(mi_id,mmi_id,statistics,tp1,tmp_text,
  2154.                      Total_Queued_Messages,tp4,tp5);
  2155.             when others           =>
  2156.               tpsend(mi_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2157.                      invalid_ftn_code,tp5);
  2158.           end case;
  2159.         end if;
  2160.  
  2161.       end loop;
  2162.  
  2163.       exception
  2164.         when others => put_line("message request dead");
  2165.     end Message_Request;
  2166.  
  2167. --**********************************************************************
  2168. --
  2169. --     MESSAGE_INTERFACE
  2170. --
  2171. --  This Task is the Message Interface for messages input.  This task
  2172. --  handles Coldstart and Message Interface On requests.  Message
  2173. --  Interface On will start the procedure Read_Unitrep_Messages which
  2174. --  reads UNITREP Messages.
  2175. --
  2176. --**********************************************************************
  2177.  
  2178.     task body Message_Interface is
  2179.       Receive_a_packet : packet_access;
  2180.     begin
  2181.       loop
  2182.         accept Input_Function(R : in packet_access) do
  2183.           Receive_a_packet := R;
  2184.         end Input_Function;
  2185.     --
  2186.     if Stop_Interface_Flag then
  2187.       tpsend(mi_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2188.              msg_interface_down,tp5);
  2189.     else
  2190.       tpsend(mi_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2191.              msg_interface_up,tp5);
  2192.     end if;
  2193.     --
  2194.     --  start procedure to read UNITREP Messages
  2195.     --
  2196.       Read_Unitrep_Messages(Receive_a_packet);
  2197.     --
  2198.     if Stop_Interface_Flag then
  2199.       tpsend(mi_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2200.              msg_interface_down,tp5);
  2201.     else
  2202.       tpsend(mi_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2203.              msg_interface_up,tp5);
  2204.     end if;
  2205.  
  2206.       end loop;
  2207.     
  2208.       exception
  2209.         when others => put_line("message interface dead");
  2210.     end Message_Interface;
  2211.  
  2212.  
  2213. procedure Read_Unitrep_Messages(Receive_a_packet : in packet_access) is
  2214.   File_Name : string(1..60);
  2215. begin
  2216.   I1 := 0;
  2217.   Queued_Messages := 0;
  2218.   for I in 1..text_length
  2219.   loop
  2220.     I1 := I1 + 1;
  2221.     exit when Receive_a_packet.var_string(I) = ' ';
  2222.   end loop;
  2223.   I := I1 - 1;
  2224.   File_Name(1..I) := Receive_a_packet.var_string(1..I);
  2225.   File_Name(I + 1 .. I + 8) := "MESSAGE.";
  2226.   I := I + 9;
  2227.   loop
  2228.     I1   := Queued_Messages + 1;
  2229.     File_Name(I..I + 2) := integer_to_string(I1);
  2230.     open(Message_File,in_file,File_Name);
  2231.     First_Message_List      := new msg_card_list;
  2232.     Message_List            := new msg_card_list;
  2233.     First_Message_List.next := Message_list;
  2234.  
  2235.     begin
  2236.       loop
  2237.         exit when end_of_file(Message_File);
  2238.         Message_List.card  := Blank_Card;
  2239.         get_line(Message_File,Message_List.card,I1);
  2240.  
  2241.         if I1 /= 0 then
  2242.           Message_List.next := new msg_card_list;
  2243.           Message_List      := Message_List.next;
  2244.         end if;
  2245.       end loop;
  2246.  
  2247.       exception
  2248.         when end_error   => Message_List.next := null;
  2249.         when others      => put_line("problem reading message file");
  2250.     end;
  2251.  
  2252.     close(Message_File);
  2253.     if Terminate_Input_Flag then
  2254.       Last_Message_Flag := -1;
  2255.       tpsend(mi_id,mv_id,UNITREP_message,First_Message_List,tp2,
  2256.              Last_Message_Flag,tp4,tp5);
  2257.       Queued_Messages := Queued_Messages + 1;
  2258.       Total_Queued_Messages := Total_Queued_Messages + 1;
  2259.       tpsend(mi_id,mmi_id,module_terminated,tp1,tp2,tp3,tp4,tp5);
  2260.       Input_Initialized := false;
  2261.       exit;
  2262.     elsif Stop_Interface_Flag then
  2263.       Last_Message_Flag := -1;
  2264.       tpsend(mi_id,mv_id,UNITREP_message,First_Message_List,tp2,
  2265.              Last_Message_Flag,tp4,tp5);
  2266.       Queued_Messages := Queued_Messages + 1;
  2267.       Total_Queued_Messages := Total_Queued_Messages + 1;
  2268.       exit;
  2269.     else
  2270.       tpsend(mi_id,mv_id,UNITREP_message,First_Message_List,tp2,
  2271.              Last_Message_Flag,tp4,tp5);
  2272.       Queued_Messages := Queued_Messages + 1;
  2273.       Total_Queued_Messages := Total_Queued_Messages + 1;
  2274.     end if;
  2275.  
  2276.   end loop;
  2277.  
  2278. exception
  2279.   when name_error         =>
  2280.     if Queued_Messages = 0 then
  2281.       tpsend(mi_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2282.              no_msgs_in_directory,tp5);
  2283.     else
  2284.       tpsend(mi_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2285.              all_msgs_processed,tp5);
  2286.       Last_Message_Flag := -1;
  2287.       tpsend(mi_id,mv_id,UNITREP_Message,tp1,tp2,
  2288.              Last_Message_Flag,tp4,tp5);
  2289.     end if;
  2290.     Stop_Interface_Flag := true;
  2291.   when constraint_error   => put_line("MI Constraint");
  2292.   when numeric_error      => put_line("MI Numeric");
  2293.   when others             =>
  2294.           put_line("problem with read unitrep messages");
  2295. end Read_Unitrep_Messages;
  2296.  
  2297. end Message_Input_Module;
  2298. --::::::::::
  2299. --msgvalid.src
  2300. --::::::::::
  2301.             -- MESSAGE VALIDATION MODULE PACKAGE SPECIFICATION AND BODY
  2302.  
  2303. with MSG_Types;
  2304. use  MSG_Types;
  2305. with System_Utilities;
  2306. use  System_Utilities;
  2307. with calendar;
  2308. use  calendar;
  2309. with idm_defs;
  2310. use  idm_defs;
  2311. with idm_io;
  2312. use  idm_io;
  2313. with text_io;
  2314. use  text_io;
  2315.  
  2316. package Message_Validation_Module is
  2317.  
  2318.   task Message_Receive is
  2319.     entry Receive_Function(R : in packet_access);
  2320.   end Message_Receive;
  2321.  
  2322. end Message_Validation_Module;
  2323.  
  2324.  
  2325. package body Message_Validation_Module is
  2326.  
  2327.   task Message_Validation is
  2328.     entry Validation_Function;
  2329.   end Message_Validation;
  2330.  
  2331.   procedure Validate_Cards;
  2332.   procedure Validate_Common_Data;
  2333.   procedure Process_Card_H;
  2334.   procedure Process_Card_A;
  2335.   procedure Process_Card_B;
  2336.   procedure Process_Card_C;
  2337.   procedure Process_Card_D;
  2338.   procedure Process_Card_G;
  2339.   procedure Process_Card_J;
  2340.   procedure Process_Card_K;
  2341.   procedure Process_Card_L;
  2342.   procedure Process_Card_M;
  2343.   procedure Process_Card_N;
  2344.   procedure Process_Card_P;
  2345.   procedure Process_Card_Q;
  2346.   procedure Process_Card_T;
  2347.   procedure Process_Card_V;
  2348.   procedure Process_Card_X;
  2349.   procedure Process_Card_R;
  2350.   procedure Process_Card_DM1;
  2351.   procedure Process_Card_DN1;
  2352.   procedure Process_Card_JM1;
  2353.   procedure Process_Card_KF1;
  2354.   procedure Process_Card_KF2;
  2355.   procedure Process_Card_KF3;
  2356.   procedure Process_Card_KF4;
  2357.   procedure Process_Card_KN1;
  2358.   procedure Process_Card_TF1;
  2359.   procedure Process_Card_E;
  2360.   procedure Invalid_Unitrep_Message;
  2361.   procedure Valid_Message;
  2362.   procedure Send_Stats;
  2363.   procedure Get_and_Store_System_Date;
  2364.   procedure Link_List;
  2365.   procedure Error_Message(s : in string ;
  2366.                           e : in Error_Msg_Types);
  2367.   procedure Validate_Uic(Uic : in string ;
  2368.                          Field_Name : in string);
  2369.   procedure Validate_YYMMDD(YY : in string ;
  2370.                             MM : in string ;
  2371.                             DD : in string ;
  2372.                             Field_Name : in string);
  2373.   procedure Validate_Oruic(Oruic : in string ;
  2374.                            Field_Name : in string);
  2375.   procedure Validate_Udc(Udc : in string ;
  2376.                          Field_Name : in string);
  2377.   procedure Validate_Ulc(Ulc : in string ;
  2378.                          Field_Name : in string);
  2379.   procedure Validate_DDDYY(DDD : in string ;
  2380.                            YY  : in string ;
  2381.                            Field_Name : in string);
  2382.   procedure Validate_Numeric(Num : in string ;
  2383.                              Field_Name : in string);
  2384.   procedure Validate_Pin(Valid_Pin : in string ;
  2385.                          Field_Name : in string);
  2386.   procedure Validate_Meqpt(Meqpt : in string ;
  2387.                            Field_Name : in string);
  2388.   procedure Validate_Geolocation(Geolocation : in string ;
  2389.                                  Field_Name : in string);
  2390.   procedure Load_Meq_Values;
  2391.   procedure Load_Crew_Values;
  2392.   function Invalid_Uic(Uic : in string) return boolean;
  2393.   function Invalid_Geo(Geo : in string) return boolean;
  2394.  
  2395.   Department_Type   : Department_Types;
  2396.   Uic2_Department_Type : Uic2_Department_Types;
  2397.   Secur_Type        : Secur_Types;
  2398.   Trtype_Type       : Trtype_Types;
  2399.   Udc_Type          : Udc_Types;
  2400.   Ulc_Type          : Ulc_Types;
  2401.   Oruic_Type        : Oruic_Types;
  2402.   Major_Type        : Major_Types;
  2403.   Reval_Type        : Reval_Types;
  2404.   Cserv_Type        : Cserv_Types;
  2405.   Activ_Type        : Activ_Types;
  2406.   Flag_Type         : Flag_Types;
  2407.   Cbcom_Type        : Cbcom_Types;
  2408.   Dfcon_Type        : Dfcon_Types;
  2409.   Nucin_Type        : Nucin_Types;
  2410.   Media_Type        : Media_Types;
  2411.   Tadc_Type         : Tadc_Types;
  2412.   Tpers_Type        : Tpers_Types;
  2413.   Cceby_Type        : Cceby_Types;
  2414.   Tread_Type        : Tread_Types;
  2415.   Reasn_Type        : Reasn_Types;
  2416.   Prres_Type        : Prres_Prres_Types;
  2417.   Esres_Type        : Esres_Prres_Types;
  2418.   Erres_Type        : Erres_Prres_Types;
  2419.   Trres_Type        : Trres_Prres_Types;
  2420.   Secrn_Type        : Prres_Types;
  2421.   Terrn_Type        : Prres_Types;
  2422.   Marea_Type        : Prres_Types;
  2423.   Rlim_Type         : Rlim_Types;
  2424.   Fordv_Type        : Fordv_Types;
  2425.   Merec_Type        : Merec_Types;
  2426.   Pin_Type          : Pin_Types;
  2427.   Pleac_Type        : Pleac_Types;
  2428.   Ddp_Type          : Ddp_Types;
  2429.   altyp_type        : altyp_types;
  2430.   Reconn_Type       : Reconn_Types;
  2431.   Wpnco_Type        : Wpnco_Types;
  2432.   Mecus_Type        : Mecus_Types;
  2433.   Avcat_Type        : Avcat_Types;
  2434.   Resnd_Type        : Resnd_Types;
  2435.   Label_Type        : Label_Types;
  2436.   Bilet_Type        : Bilet_Types;
  2437.   Cornk_Type        : Cornk_Types;
  2438.   Scatd_Type        : Scatd_Types;
  2439.   Docid_Type        : Docid_Types;
  2440.   Tmthd_Type        : Tmthd_Types;
  2441.   Meqs_type         : Meqs_types;
  2442.   Sedy_Type         : Sedy_Types;
  2443.   Tedy_Type         : Tedy_Types;
  2444.   Avail_Type        : Avail_Types;
  2445.   Coaff_Type        : Coaff_Types;
  2446.   Alphabetic_Type   : Alphabetic_Types;
  2447.   Mmcmd_Type        : Mmcmd_Types;
  2448.   Error_Msg_Type    : Error_MSG_Types;
  2449.  
  2450.   Card_H                     : Access_Card_Type_H; -- header
  2451.   Card_E                     : Access_Card_Type_E; -- end
  2452.   Card_A                     : Access_Card_Type_A;
  2453.   Card_B                     : Access_Card_Type_B;
  2454.   Card_C                     : Access_Card_Type_C;
  2455.   Card_D                     : Access_Card_Type_D;
  2456.   Card_G                     : Access_Card_Type_G;
  2457.   Card_J                     : Access_Card_Type_J;
  2458.   Card_K                     : Access_Card_Type_K;
  2459.   Card_L                     : Access_Card_Type_L;
  2460.   Card_M                     : Access_Card_Type_M;
  2461.   Card_N                     : Access_Card_Type_N;
  2462.   Card_P                     : Access_Card_Type_P;
  2463.   Card_Q                     : Access_Card_Type_Q;
  2464.   Card_T                     : Access_Card_Type_T;
  2465.   Card_V                     : Access_Card_Type_V;
  2466.   Card_X                     : Access_Card_Type_X;
  2467.   Card_R                     : Access_Card_Type_R;
  2468.   Card_DM1                   : Access_Card_Type_DM1;
  2469.   Card_DN1                   : Access_Card_Type_DN1;
  2470.   Card_JM1                   : Access_Card_Type_JM1;
  2471.   Card_KF1                   : Access_Card_Type_KF1;
  2472.   Card_KF2                   : Access_Card_Type_KF2;
  2473.   Card_KF3                   : Access_Card_Type_KF3;
  2474.   Card_KF4                   : Access_Card_Type_KF4;
  2475.   Card_KN1                   : Access_Card_Type_KN1;
  2476.   Card_TF1                   : Access_Card_Type_TF1;
  2477.   idmrun                     : idmrun_type;
  2478.   Length_of_String           : integer := 0;
  2479.   First_Valid_Msg            : Access_Msg_List;
  2480.   Valid_Msg                  : Access_Msg_List;
  2481.   First_Input_Msg            : Access_Msg_Card_List;
  2482.   Input_Msg                  : Access_Msg_Card_List;
  2483.   First_Error_Msg            : Access_Msg_Card_List;
  2484.   Error_Msg                  : Access_Msg_Card_List;
  2485.   Receive_packet             : packet_access;
  2486.   Bad_Message                : boolean;
  2487.   Udc_Valid                  : boolean;
  2488.   No_Header_Exception        : exception;
  2489.   No_End_Exception           : exception;
  2490.   Bad_Sequence_Exception     : exception;
  2491.   Seq_Number, Old_Seq_Number : integer := 0;
  2492.   Nbr_of_Valid_Messages      : integer := 0;
  2493.   Nbr_of_Invalid_Messages    : integer := 0;
  2494.   System_Time                : time;
  2495.   System_Year                : integer;
  2496.   System_Month               : integer;
  2497.   System_Day                 : integer;
  2498.   Header_Date                : string(1..6);
  2499.   Header_Year                : integer;
  2500.   Header_Month               : integer;
  2501.   Header_Day                 : integer;
  2502.   Header_Oruic               : string(1..6);
  2503.   Header_Report_Number       : string(1..3);
  2504.   Terminate_Module_Flag      : boolean := false;
  2505.   Task_Initialized           : boolean := false;
  2506.   Validating_Messages        : boolean := false;
  2507.   Last_Message               : integer :=0;
  2508.   Validating_Field_Name      : string(1..5);
  2509.   Common_Card_Number         : string(1..3) := "   ";
  2510.   Common_Card_Type           : string(1..3) := "   ";
  2511.   Tmp_Text_Type              : string(1..60) :=
  2512.          "                                                            ";
  2513. --       "123456789 123456789 123456789 123456789 123456789 123456789 "
  2514.   Last_Message_String        : constant string(1..60) :=
  2515.          "LAST MESSAGE                                                ";
  2516. --       "123456789 123456789 123456789 123456789 123456789 123456789 "
  2517.   type Error_Msg_Text_Type is array
  2518.         (Error_MSG_Types range Bad_Field..Can_Not_Validate_Correctly)
  2519.         of string(1..80);
  2520.   Error_Msg_Text             : Error_Msg_Text_Type :=
  2521.        ("Bad       Field in card sequence number " &
  2522.         "    .                                   ",
  2523.         "Card Sequence Numbers out of sequence.  " &
  2524.         "                                        ",
  2525.         "No Header Card Found.                   " &
  2526.         "                                        ",
  2527.         "No End Card Found.                      " &
  2528.         "                                        ",
  2529.         "      Field is Required card sequence nu" &
  2530.         "mber    .                               ",
  2531.         "Bad Card Type card sequence number    . " &
  2532.         "                                        ",
  2533.         "Mutually exclusive fields reported card " &
  2534.         "sequence    .                           ",
  2535.         "Can not validate       Field correctly i" &
  2536.         "n card sequence number    .             ");
  2537.   Mepsd_Value                : integer;
  2538.   Meord_Value                : integer;
  2539.   Meorn_Value                : integer;
  2540.   Meorc_Value                : integer;
  2541.   Meoro_Value                : integer;
  2542.   Crewf_Value                : integer;
  2543.   Crmrd_Value                : integer;
  2544.   Crmrn_Value                : integer;
  2545.   Crmrc_Value                : integer;
  2546.   Crmro_Value                : integer;
  2547.   Valid_Value                : integer := 0;
  2548.   Month_of_Year              : integer;
  2549.   Leap_Year                  : integer;
  2550.   Days_in_Year               : integer := 365;
  2551.   type Days_in_Month_Type is array(1..12) of integer;
  2552.   Days_in_Month : Days_in_Month_Type := (31,28,31,30,31,30,31,
  2553.                                          31,30,31,30,31);
  2554.   Working_String             : string(1..10) := "          ";
  2555.   String_Length              : integer;
  2556.  
  2557.  
  2558. --**********************************************************************
  2559. --
  2560. --    MESSAGE_RECEIVE
  2561. --
  2562. --  This Task is the main controlling task of the Message Validation
  2563. --  Module.  It receives commands from Man/Machine Interface (MMI),
  2564. --  Message Input (MV) and the Database Build, validates and processes
  2565. --  the command.  Message Validation is turned on when a message is
  2566. --  waiting in queue.
  2567. --
  2568. --**********************************************************************
  2569.  
  2570.   task body Message_Receive is
  2571.  
  2572.   begin
  2573.     loop
  2574.       accept Receive_Function(R : in packet_access) do
  2575.         Receive_packet := R;
  2576.       end Receive_Function;
  2577.   --
  2578.   --  validation and processing of Request
  2579.   --
  2580.   --  requests handled
  2581.   --     Coldstart_Module     => zero statistics
  2582.   --                             clear buffers
  2583.   --                             initialize flags
  2584.   --     Unitrep_Message      => turn on Message_Validation task
  2585.   --                             to validate unitrep message
  2586.   --     Terminate_Module     => set Terminate_Module_Flag to
  2587.   --                             turn off validation
  2588.   --     Restart_Module       => initialize flags
  2589.   --                             clear buffers
  2590.   --     Send_Statistics      => queue Statistics to MMI
  2591.   --     others               => invalid request queue to MMI
  2592.   --                             with message stating invalid
  2593.   --
  2594.       if not Task_Initialized then
  2595.         if Receive_packet.ftn = Coldstart_Module or
  2596.            Receive_packet.ftn = Restart_Module then
  2597.             Task_Initialized      := true;
  2598.             Terminate_Module_Flag := false;
  2599.             Validating_Messages   := false;
  2600.             Last_Message          := 0;
  2601.             First_Valid_Msg       := null;
  2602.             Valid_Msg             := null;
  2603.             First_Input_Msg       := null;
  2604.             Input_Msg             := null;
  2605.             First_Error_Msg       := null;
  2606.             Error_Msg             := null;
  2607.           if Receive_packet.ftn = Coldstart_Module then
  2608.               Nbr_of_Valid_Messages      := 0;
  2609.               Nbr_of_Invalid_Messages    := 0;
  2610.           end if;
  2611.           tpsend(mv_id,mmi_id,module_initialized,tp1,tp2,tp3,tp4,tp5);
  2612.         else
  2613.           tpsend(mv_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2614.                  invalid_ftn_code,tp5);
  2615.         end if;
  2616.       else
  2617.         case Receive_packet.ftn is
  2618.           when UNITREP_Message   =>
  2619.             if Receive_packet.bap = null then
  2620.               Validating_Messages := false;
  2621.             else
  2622.               Validating_Messages := true;
  2623.               Message_Validation.Validation_Function;
  2624.             end if;
  2625.           when Terminate_Module  =>
  2626.             Terminate_Module_Flag := true;
  2627.             if not Validating_Messages then
  2628.               tpsend(mv_id,mmi_id,module_terminated,tp1,tp2,
  2629.                      tp3,tp4,tp5);
  2630.               task_initialized := false;
  2631.             end if;
  2632.           when Send_Statistics   =>
  2633.             Send_Stats;
  2634.           when others            =>
  2635.             tpsend(mv_id,mmi_id,fixed_alert,tp1,tp2,tp3,
  2636.                    invalid_ftn_code,tp5);
  2637.         end case;
  2638.       end if;
  2639.  
  2640.     end loop;
  2641.      
  2642.     exception
  2643.       when others => put_line("Message Receive dead");
  2644.   end Message_Receive;
  2645.  
  2646. --**********************************************************************
  2647. --
  2648. --        MESSAGE VALIDATION
  2649. --
  2650. --      This Procedure accepts a message, extracts cards from the
  2651. --    message and validates the message and cards building a buffer
  2652. --    of validated cards for queue to DBB
  2653. --
  2654. --**********************************************************************
  2655.  
  2656.   task body Message_Validation is
  2657.  
  2658.   begin
  2659.     --
  2660.     Get_and_Store_System_Date;
  2661.     --
  2662.     loop
  2663.       accept Validation_Function;
  2664.  
  2665.       idm_initrun(true);
  2666.       idm_openrun(idmrun,"sys_idm");
  2667.       idm_opendb(idmrun,"unitrep");
  2668.  
  2669.       Validate_Cards;
  2670.  
  2671.       idm_closerun(idmrun);
  2672.  
  2673.       if Last_Message = -1 then
  2674.         Validating_Messages := false;
  2675.         if Terminate_Module_Flag then
  2676.           tpsend(mv_id,mmi_id,module_terminated,tp1,tp2,tp3,tp4,tp5);
  2677.           task_initialized := false;
  2678.         end if;
  2679.       end if;
  2680.  
  2681.     end loop;
  2682.  
  2683.     exception
  2684.       when others => put_line("Message Validation dead");
  2685.   end Message_Validation;
  2686.   
  2687.  
  2688.   procedure Validate_Cards is
  2689.       --
  2690.       --  start validation of UNITREP Messages
  2691.       --
  2692.       begin
  2693.         --
  2694.         --    set up link to first error message
  2695.         --
  2696.         First_Error_Msg        := new Msg_Card_List;
  2697.         Error_Msg              := new Msg_Card_List;
  2698.         First_Error_Msg.next   := Error_Msg;
  2699.         --
  2700.         --    get first input message and set pointer to first message
  2701.         --    in list
  2702.         --
  2703.         First_Input_Msg        := Receive_packet.bap;
  2704.         Input_Msg              := First_Input_Msg.next;
  2705.         --
  2706.         --    get last message flag
  2707.         --
  2708.         Last_Message           := Receive_packet.var_integer;
  2709.         --
  2710.         --    set up first valid message and pointer to first valid
  2711.         --    message
  2712.         --
  2713.         First_Valid_Msg        := new Msg_List;
  2714.         Valid_Msg              := new Msg_List;
  2715.         First_Valid_Msg.Next   := Valid_Msg;
  2716.         --
  2717.         --    set bad message flag to false
  2718.         --
  2719.         Bad_Message            := false;
  2720.         --
  2721.         --    search input Message List for header card.  If no header
  2722.         --    card found raise no_header_exception
  2723.         --
  2724.         loop
  2725.           if Input_Msg.next = null then
  2726.             raise No_Header_exception;
  2727.           end if;
  2728.           Common_Card_Number := Input_Msg.card(1..3);
  2729.           Common_Card_Type   := Input_Msg.card(6..8);
  2730.           Seq_Number := string_to_Integer(Common_Card_Number);
  2731.           if Common_Card_Type = "H  " and Seq_Number = 1 then
  2732.             Old_Seq_Number := Seq_Number + 1;
  2733.             exit;
  2734.           end if;
  2735.           Input_Msg := Input_Msg.next;
  2736.         end loop;
  2737.         --
  2738.         --    Validate Card/Fields
  2739.         --
  2740.         loop
  2741.           --
  2742.           --      validate card type field card.  convert to card type
  2743.           --    enumeration value.  if no valid use enumeration value of
  2744.           --    bad.
  2745.           --
  2746.           begin
  2747.             Validating_Field_Name := "     ";
  2748.             Error_Msg_Type        := Bad_Card_Type;
  2749.             Valid_Msg.Card_Type :=
  2750.                          Card_Type_Types'value(Common_Card_Type);
  2751.             --
  2752.             --    validate common data for all cards except Header and End
  2753.             --    cards
  2754.             --
  2755.             case Valid_Msg.Card_Type is
  2756.               when H | E  => null;
  2757.               when others => Validate_Common_Data;
  2758.             end case;
  2759.             --
  2760.             --      process each card type.  case statement is used to do
  2761.             --    appropriate processing for each enumeration value (card
  2762.             --    type)
  2763.             --
  2764.             case Valid_Msg.Card_Type is
  2765.               when H        =>  Process_Card_H;
  2766.               when A        =>  Process_Card_A;
  2767.               when B        =>  Process_Card_B;
  2768.               when C        =>  Process_Card_C;
  2769.               when D        =>  Process_Card_D;
  2770.               when G        =>  Process_Card_G;
  2771.               when J        =>  Process_Card_J;
  2772.               when K        =>  Process_Card_K;
  2773.               when L        =>  Process_Card_L;
  2774.               when M        =>  Process_Card_M;
  2775.               when N        =>  Process_Card_N;
  2776.               when P        =>  Process_Card_P;
  2777.               when Q        =>  Process_Card_Q;
  2778.               when T        =>  Process_Card_T;
  2779.               when V        =>  Process_Card_V;
  2780.               when X        =>  Process_Card_X;
  2781.               when R | RM3  =>  Process_Card_R;
  2782.               when DM1      =>  Process_Card_DM1;
  2783.               when DN1      =>  Process_Card_DN1;
  2784.               when JM1      =>  Process_Card_JM1;
  2785.               when KF1      =>  Process_Card_KF1;
  2786.               when KF2      =>  Process_Card_KF2;
  2787.               when KF3      =>  Process_Card_KF3;
  2788.               when KF4      =>  Process_Card_KF4;
  2789.               when KN1      =>  Process_Card_KN1;
  2790.               when TF1      =>  Process_Card_TF1;
  2791.               when E        =>  Process_Card_E;
  2792.             end case;
  2793.  
  2794.           exception
  2795.             when constraint_error  =>
  2796.               Error_Message(Validating_Field_Name,Error_Msg_Type);
  2797.             when others            =>
  2798.               put_line("problem in validate card/fields");
  2799.           end;
  2800.           if Valid_Msg.card_type = E then
  2801.             exit;
  2802.           end if;
  2803.           --
  2804.           --    Read in Cards following Header Card watching for an End
  2805.           --    Card
  2806.           --
  2807.           --
  2808.           Input_Msg := Input_Msg.next;
  2809.           if Input_Msg.next = null then
  2810.             raise No_End_Exception;
  2811.           end if;
  2812.           Common_Card_Number := Input_Msg.card(1..3);
  2813.           Common_Card_Type   := Input_Msg.card(6..8);
  2814.           Seq_Number := string_to_Integer(Common_Card_Number);
  2815.           if Seq_Number /= Old_Seq_Number then
  2816.             raise Bad_Sequence_Exception;
  2817.           end if;
  2818.           Old_Seq_Number := Seq_Number + 1;
  2819.  
  2820.         end loop;
  2821.  
  2822.         if Bad_Message then
  2823.           Invalid_Unitrep_Message;
  2824.         end if;
  2825.   
  2826.       exception
  2827.         when No_Header_Exception    => Error_Message("",No_Header);
  2828.                                        Invalid_Unitrep_Message;
  2829.         when No_End_Exception       => Error_Message("",No_End);
  2830.                                        Invalid_Unitrep_Message;
  2831.         when Bad_Sequence_Exception => Error_Message("",Bad_Sequence);
  2832.                                        Invalid_Unitrep_Message;
  2833.  
  2834.         when others                 =>
  2835.           put_line("Something wrong in Validation procedure");
  2836.       end Validate_Cards;
  2837.  
  2838.  
  2839. --**********************************************************************
  2840. --
  2841. --      This procedure does the processing for the validation of the
  2842. --    common fields of all cards except the Header and End card.
  2843. --
  2844. --**********************************************************************
  2845.  
  2846.   procedure Validate_Common_Data is
  2847.   begin
  2848.     --
  2849.     --    validate and place card sequence number in card number field
  2850.     --
  2851.     Valid_Msg.Card_Number := Seq_Number;
  2852.     --
  2853.     --    convert and validate security classification field
  2854.     --
  2855.     begin
  2856.       Working_String        := "          ";
  2857.       Working_String(1..1)  := Input_Msg.card(4..4);
  2858.       Valid_Msg.Secur       := Secur_Types'value(Working_String);
  2859.     exception
  2860.       when others  => Error_Message("SECUR",Bad_Field);
  2861.     end;
  2862.     --
  2863.     --    validate and convert transaction type
  2864.     --
  2865.     if Input_Msg.Card(5) = 'A' then
  2866.       Valid_Msg.Trtype := ADD;
  2867.     elsif Input_Msg.Card(5) = 'C' then
  2868.       Valid_Msg.Trtype := CHANGE;
  2869.     elsif Input_Msg.Card(5) = 'D' then
  2870.       Valid_Msg.Trtype := DELETE;
  2871.     elsif Input_Msg.Card(5) = 'R' then
  2872.       Valid_Msg.Trtype := REPLACE;
  2873.     else
  2874.       Validating_Field_Name  := "TRTYP";
  2875.       Error_Msg_Type         := Bad_Field;
  2876.       raise constraint_error;
  2877.     end if;
  2878.     --
  2879.     Valid_Msg.Uic          := Input_Msg.card(9..14);
  2880.     Validate_Uic(Valid_Msg.Uic,"UIC  ");
  2881.     --
  2882.     --    convert and validate Originator's UIC field
  2883.     --
  2884.     begin
  2885.       if Input_Msg.card(70..75) /= Header_Oruic then
  2886.         Error_Message("ORUIC",Bad_Field);
  2887.       else
  2888.         Valid_Msg.Oruic := Oruic_Types'value(Header_Oruic);
  2889.       end if;
  2890.     exception
  2891.       when others  => null;
  2892.     end;
  2893.     --
  2894.     --  validate report number
  2895.     --
  2896.     if Input_Msg.card(78..80) /= Header_Report_Number then
  2897.       Error_Message("RPTNR",Bad_Field);
  2898.     else
  2899.       Validate_Numeric(Input_Msg.card(78..80),"RPTNR");
  2900.     end if;
  2901.  
  2902.   end Validate_Common_Data;
  2903.  
  2904.  
  2905. --**********************************************************************
  2906. --
  2907. --      This procedure does the processing for the validation of the
  2908. --    fields of a Header card.
  2909. --
  2910. --**********************************************************************
  2911.  
  2912.   procedure Process_Card_H is
  2913.  
  2914.   begin
  2915.     --
  2916.     --    set up new access pointer to card H
  2917.     --
  2918.     Card_H := new Card_Type_H;
  2919.     --
  2920.     --    validate and place card sequence number in card number field
  2921.     --
  2922.     begin
  2923.       Card_H.Card_Number := Seq_Number;
  2924.     exception
  2925.       when others  => Error_Message("CRDSQ",Bad_Field);
  2926.     end;
  2927.     --
  2928.     --    convert and validate security classification
  2929.     --
  2930.     begin
  2931.       Working_String          := "          ";
  2932.       Working_String(1..1)    := Input_Msg.card(4..4);
  2933.       Valid_Msg.Secur         := Secur_Types'value(Working_String);
  2934.     exception
  2935.       when others  => Error_Message("SECUR",Bad_Field);
  2936.     end;
  2937.     --
  2938.     --    convert and validate "as of" date field
  2939.     --
  2940.     Header_Date  := "      ";
  2941.     Header_Year  := 0;
  2942.     Header_Month := 0;
  2943.     Header_Day   := 0;
  2944.     begin
  2945.       Working_String       := "          ";
  2946.       Working_String(1..2) := Input_Msg.card(9..10);
  2947.       Card_H.Day           := string_to_integer(Working_String(1..2));
  2948.       Working_String       := "          ";
  2949.       Working_String(1..3) := Input_Msg.card(16..18);
  2950.       Card_H.Month         := Month_Types'value(Working_String);
  2951.       Working_String       := "          ";
  2952.       Working_String(1..2) := Input_Msg.card(19..20);
  2953.       Card_H.Year          := string_to_integer(Working_String(1..2));
  2954.       Leap_Year := Card_H.Year / 4;
  2955.       Leap_Year := Leap_Year - (Card_H.Year * 4);
  2956.       if Leap_Year = 0 then
  2957.         Days_in_Month(2) := 29;
  2958.       else
  2959.         Days_in_Month(2) := 28;
  2960.       end if;
  2961.       if Card_H.Day >
  2962.          Days_in_Month((Month_Types'pos(Card_H.Month) + 1)) then
  2963.         raise constraint_error;
  2964.       end if;
  2965.       Working_String(1..3) :=
  2966.          integer_to_string((Month_Types'pos(Card_H.Month) + 1));
  2967.       Header_Date  := Input_Msg.Card(19..20) &
  2968.                       Working_String(2..3) &
  2969.                       Input_Msg.card(9..10);
  2970.       Header_Year  := Card_H.Year;
  2971.       Header_Month := Month_Types'pos(Card_H.Month) + 1;
  2972.       Header_Day   := Card_H.Day;
  2973.     exception
  2974.       when others  => Error_Message("as of",Bad_Field);
  2975.     end;
  2976.     --
  2977.     --    validate and convert Real or Exercise field
  2978.     --
  2979.     begin
  2980.       Working_String          := "          ";
  2981.       Working_String(1..1)    := Input_Msg.card(21..21);
  2982.       Card_H.Real_or_Exercise :=
  2983.                    Real_or_Exercise_Types'value(Working_String);
  2984.     exception
  2985.       when others  => Error_Message("REXER",Bad_Field);
  2986.     end;
  2987.     --
  2988.     --    convert and validate Originator's UIC field
  2989.     --
  2990.     begin
  2991.       Header_Oruic    := Input_Msg.card(70..75);
  2992.       Valid_Msg.Oruic := Oruic_Types'value(Header_Oruic);
  2993.     exception
  2994.       when others  => Error_Message("ORUIC",Bad_Field);
  2995.     end;
  2996.     --
  2997.     --  validate report number
  2998.     --
  2999.     Header_Report_Number := Input_Msg.card(78..80);
  3000.     Validate_Numeric(Header_Report_Number,"RPTNR");
  3001.     --
  3002.     --    if card is valid place access pointer in message list and
  3003.     --    set up new access pointer for message list
  3004.     --
  3005.     if not Bad_Message then
  3006.       Valid_Msg.access_h  := Card_H;
  3007.       Link_List;
  3008.     end if;
  3009.  
  3010.   end Process_Card_H;
  3011.  
  3012.  
  3013. --**********************************************************************
  3014. --
  3015. --      This procedure does the processing for the validation of the
  3016. --    fields of a "A  " card.
  3017. --
  3018. --**********************************************************************
  3019.  
  3020.   procedure Process_Card_A is
  3021.  
  3022.   begin
  3023.     --
  3024.     --    set up new access pointer to card A
  3025.     --
  3026.     Card_A := new Card_Type_A;
  3027.     --
  3028.     --    place strings in field components
  3029.     --
  3030.     Card_A.Udc          := Input_Msg.card(15..15);
  3031.     Card_A.Aname        := Input_Msg.card(16..45);
  3032.     Card_A.Utc          := Input_Msg.card(46..50);
  3033.     Card_A.Ulc          := Input_Msg.card(51..53);
  3034.     Card_A.Mjcom        := Input_Msg.card(54..59);
  3035.     Card_A.Major        := Input_Msg.card(60..60);
  3036.     Card_A.Reval        := Input_Msg.card(61..61);
  3037.     Card_A.Tpsn         := Input_Msg.card(62..68);
  3038.     Card_A.Sclas        := Input_Msg.card(69..69);
  3039.     --
  3040.     Validate_Ulc(Card_A.Ulc,"ULC  ");
  3041.     --
  3042.     --    validate MJCOM field.  this field is required if transaction
  3043.     --    type is "A"
  3044.     --
  3045.     if Card_A.Mjcom /= "      " then
  3046.       Validate_Oruic(Card_A.Mjcom,"MJCOM");
  3047.     elsif Valid_Msg.Trtype = ADD then
  3048.       Error_Message("MJCOM",Field_Required);
  3049.     end if;
  3050.     --
  3051.     begin
  3052.       if Card_A.Major /= " " then
  3053.         if Card_A.Major = "#" and Valid_Msg.Trtype = CHANGE then
  3054.           null;
  3055.         else
  3056.           Major_Type  := Major_Types'value(Card_A.Major);
  3057.         end if;
  3058.       end if;
  3059.     exception
  3060.       when others  => Error_Message("MAJOR",Bad_Field);
  3061.     end;
  3062.     --
  3063.     --    validate REVAL and UDC fields.  if UDC is blank REVAL must be
  3064.     --    blank. if UDC is one of the following "A B C D E F T U V W X Y
  3065.     --    Z" REVAL must be "X".  if UDC is one of the following "1 3 5 7
  3066.     --    9 G H J K L N P Q R S" REVAL must be "R".  if UDC in one of
  3067.     --    the following "0 2 4 6 8 G H J K L N P Q R S" REVAL must be "G".
  3068.     --
  3069.     begin
  3070.       if Card_A.Udc = " " then
  3071.         if Card_A.Reval /= " " then
  3072.           Error_Message("REVAL",Bad_Field);
  3073.         end if;
  3074.       else
  3075.         Validate_Udc(Card_A.Udc,"UDC  ");
  3076.         if Udc_Valid then
  3077.           Reval_Type := Reval_Types'value(Card_A.Reval);
  3078.           if Valid_Value < 0 then
  3079.             if Udc_type < G and Reval_Type /= X then
  3080.               Error_Message("REVAL",Bad_Field);
  3081.             elsif Udc_Type > Z and Reval_Type = X then
  3082.               Error_Message("REVAL",Bad_Field);
  3083.             end if;
  3084.           elsif (Valid_Value = 1 or Valid_Value = 3 or
  3085.                  Valid_Value = 5 or Valid_Value = 7 or
  3086.                  Valid_Value = 9) and Reval_Type /= R then
  3087.             Error_Message("REVAL",Bad_Field);
  3088.           elsif (Valid_Value = 0 or Valid_Value = 2 or
  3089.                  Valid_Value = 4 or Valid_Value = 6 or
  3090.                  Valid_Value = 8) and Reval_Type /= G then
  3091.             Error_Message("REVAL",Bad_Field);
  3092.           end if;
  3093.         end if;
  3094.       end if;
  3095.     exception
  3096.       when others  => Error_Message("REVAL",Bad_Field);
  3097.     end;
  3098.     --
  3099.     --    validation of TPSN if char 1-5 are blank char 6-7 must be blank
  3100.     --    if char 1-5 is not blank, char 1-5 must be numeric, char 6-7
  3101.     --    must be numeric or blank
  3102.     --
  3103.     if Card_A.Tpsn(1..5) = "     " then
  3104.       if Card_A.Tpsn(6..7) /= "  " then
  3105.         Error_Message("TPSN ",Bad_Field);
  3106.       end if;
  3107.     else
  3108.       Validate_Numeric(Card_A.Tpsn(1..5),"TPSN  ");
  3109.       Validate_Numeric(Card_A.Tpsn(6..7),"TPSN  ");
  3110.     end if;
  3111.     --
  3112.     --    if SCLAS is reported, it must be <= SECUR.  if not reported
  3113.     --    and transaction type is Add, set SCLAS = SECUR.
  3114.     --
  3115.     begin
  3116.       if Card_A.Sclas /= " " then
  3117.         Secur_Type      := Secur_Types'value(Card_A.Sclas);
  3118.         if Secur_Type > Valid_Msg.Secur then
  3119.           Error_Message("SCLAS",Bad_Field);
  3120.         end if;
  3121.       elsif Valid_Msg.Trtype = ADD then
  3122.         Card_A.Sclas := Secur_Types'image(Valid_Msg.Secur);
  3123.       end if;
  3124.     exception
  3125.       when others  => Error_Message("SCLAS",Bad_Field);
  3126.     end;
  3127.     --
  3128.     --    if card is valid, place access pointer in message list and
  3129.     --  set up new access pointer for message list
  3130.     --
  3131.     if not Bad_Message then
  3132.       Valid_Msg.access_a  := Card_A;
  3133.       Link_List;
  3134.     end if;
  3135.  
  3136.   end Process_Card_A;
  3137.  
  3138.  
  3139. --**********************************************************************
  3140. --
  3141. --      This procedure does the processing for the validation of the
  3142. --    fields of a "B  " card.
  3143. --
  3144. --**********************************************************************
  3145.  
  3146.   procedure Process_Card_B is
  3147.  
  3148.   begin
  3149.     --
  3150.     --    set up new access pointer for card B
  3151.     --
  3152.     Card_B := new Card_Type_B;
  3153.     --
  3154.     --    place strings in field components
  3155.     --
  3156.     Card_B.Lname        := Input_Msg.card(15..69);
  3157.     --
  3158.     --    LNAME must be reported when transaction is either an Add or
  3159.     --    Change
  3160.     --
  3161.     case Valid_Msg.Trtype is
  3162.       when ADD | CHANGE  =>
  3163.         if Card_B.Lname = "                             " &
  3164.                           "                          " then
  3165.           Error_Message("LNAME",Field_Required);
  3166.         end if;
  3167.       when others        => null;
  3168.     end case;
  3169.     --
  3170.     --    if card is valid, place access pointer in message list and
  3171.     --  set up a new access pointer for message list
  3172.     --
  3173.     if not Bad_Message then
  3174.       Valid_Msg.access_b  := Card_B;
  3175.       Link_List;
  3176.     end if;
  3177.  
  3178.   end Process_Card_B;
  3179.  
  3180.  
  3181. --**********************************************************************
  3182. --
  3183. --      This procedure does the processing for the validation of the
  3184. --    fields of a "C  " card.
  3185. --
  3186. --**********************************************************************
  3187.  
  3188.   procedure Process_Card_C is
  3189.  
  3190.   begin
  3191.     --
  3192.     --    set up new access pointer for card C
  3193.     --
  3194.     Card_C := new Card_Type_C;
  3195.     --
  3196.     --    place strings in field components
  3197.     --
  3198.     Card_C.Udc          := Input_Msg.card(15..15);
  3199.     Card_C.Aname        := Input_Msg.card(16..45);
  3200.     Card_C.Utc          := Input_Msg.card(46..50);
  3201.     Card_C.Ulc          := Input_Msg.card(51..53);
  3202.     Card_C.Coaff        := Input_Msg.card(54..55);
  3203.     Card_C.Monor        := Input_Msg.card(56..61);
  3204.     Card_C.Sclas        := Input_Msg.card(69..69);
  3205.     --
  3206.     Validate_Udc(Card_C.Udc,"UDC  ");
  3207.     --
  3208.     Validate_Ulc(Card_C.Ulc,"ULC  ");
  3209.     --
  3210.     begin
  3211.       if Card_C.Coaff /= "  " then
  3212.         if Card_C.Coaff = "DO" or
  3213.            Card_C.Coaff = "IN" or
  3214.            Card_C.Coaff = "IS" then
  3215.           null;
  3216.         else
  3217.           Coaff_Type      := Coaff_Types'value(Card_C.Coaff);
  3218.         end if;
  3219.       end if;
  3220.     exception
  3221.       when others  => Error_Message("COAFF",Bad_Field);
  3222.     end;
  3223.     --
  3224.     --    validate MONOR field.  required to be reported if transaction
  3225.     --    type is "A"
  3226.     --
  3227.     if Card_C.Monor /= "      " then
  3228.       Validate_Oruic(Card_C.Monor,"MONOR");
  3229.     elsif Valid_Msg.Trtype = ADD then
  3230.       Error_Message("MONOR",Field_Required);
  3231.     end if;
  3232.     --
  3233.     --    if SCLAS is reported must be <= SECUR.  if not reported
  3234.     --    and transaction type is Add, then set SCLAS = SECUR.
  3235.     --
  3236.     begin
  3237.       if Card_C.Sclas /= " " then
  3238.         Secur_Type      := Secur_Types'value(Card_C.Sclas);
  3239.         if Secur_Type > Valid_Msg.Secur then
  3240.           Error_Message("SCLAS",Bad_Field);
  3241.         end if;
  3242.       elsif Valid_Msg.Trtype = ADD then
  3243.         Card_C.Sclas := Secur_Types'image(Valid_Msg.Secur);
  3244.       end if;
  3245.     exception
  3246.       when others  => Error_Message("SCLAS",Bad_Field);
  3247.     end;
  3248.     --
  3249.     --    if card is valid, place access pointer in message list and
  3250.     --    set up new access pointer for message list
  3251.     --
  3252.     if not Bad_Message then
  3253.       Valid_Msg.access_c  := Card_C;
  3254.       Link_List;
  3255.     end if;
  3256.  
  3257.   end Process_Card_C;
  3258.  
  3259.  
  3260. --**********************************************************************
  3261. --
  3262. --      This procedure does the processing for the validation of the
  3263. --    fields of a "D  " card.
  3264. --
  3265. --**********************************************************************
  3266.  
  3267.   procedure Process_Card_D is
  3268.  
  3269.   begin
  3270.     --
  3271.     --    set up new access pointer for card D
  3272.     --
  3273.     Card_D := new Card_Type_D;
  3274.     --
  3275.     --    place strings in field components
  3276.     --
  3277.     Card_D.Cserv        := Input_Msg.card(15..15);
  3278.     Card_D.Opcon        := Input_Msg.card(16..21);
  3279.     Card_D.Adcon        := Input_Msg.card(22..27);
  3280.     Card_D.Hogeo        := Input_Msg.card(28..31);
  3281.     Card_D.Prgeo        := Input_Msg.card(32..35);
  3282.     Card_D.Embrk        := Input_Msg.card(36..41);
  3283.     Card_D.Activ        := Input_Msg.card(42..43);
  3284.     Card_D.Flag         := Input_Msg.card(44..44);
  3285.     Card_D.Puic         := Input_Msg.card(45..50);
  3286.     Card_D.Cbcom        := Input_Msg.card(51..51);
  3287.     Card_D.Dfcon        := Input_Msg.card(52..52);
  3288.     Card_D.Point        := Input_Msg.card(53..67);
  3289.     Card_D.Nucin        := Input_Msg.card(68..68);
  3290.     Card_D.Pctef        := Input_Msg.card(69..69);
  3291.     --
  3292.     --    if CSERV is reported must be 1-9 or C D A N F M E J
  3293.     --
  3294.     begin
  3295.       if Card_D.Cserv /= " " then
  3296.         Valid_Value   := string_to_integer(Card_D.Cserv);
  3297.         if Valid_Value < 1 then
  3298.           Cserv_Type  := Cserv_Types'value(Card_D.Cserv);
  3299.         elsif Valid_Value > 9 then
  3300.           raise constraint_error;
  3301.         end if;
  3302.       end if;
  3303.     exception
  3304.       when others  => Error_Message("CSERV",Bad_Field);
  3305.     end;
  3306.     --
  3307.     if Card_D.Opcon /= "      " then
  3308.       Validate_Uic(Card_D.Opcon,"OPCON");
  3309.     end if;
  3310.     --
  3311.     if Card_D.Adcon /= "      " then
  3312.       Validate_Uic(Card_D.Adcon,"ADCON");
  3313.     end if;
  3314.     --
  3315.     --    if HOGEO is reported it will be validated against an IDM
  3316.     --    database relation Geoloc
  3317.     --
  3318.     --    Card_D.Hogeo
  3319.     --
  3320.     --    if PRGEO is reported it will be validated against an IDM
  3321.     --    database relation Geoloc
  3322.     --
  3323.     --    Card_D.Prgeo
  3324.     --
  3325.     --    if transaction type is Add and PRGEO is blank, set PRGEO to
  3326.     --    HOGEO
  3327.     --
  3328.     Validate_Geolocation(Card_D.Hogeo,"HOGEO");
  3329.     --
  3330.     if Card_D.Prgeo /= "    " and
  3331.        Card_D.Embrk /= "      " then
  3332.       Error_Message("",Mutually_Exclusive);
  3333.     elsif Card_D.Embrk /= "      " then
  3334.       Validate_Uic(Card_D.Embrk,"EMBRK");
  3335.     else
  3336.       Validate_Geolocation(Card_D.Prgeo,"PRGEO");
  3337.     end if;
  3338.     --
  3339.     if Valid_Msg.Trtype = ADD and Card_D.PRGEO = "    " then
  3340.       Card_D.Prgeo := Card_D.Hogeo;
  3341.     end if;
  3342.     --
  3343.     begin
  3344.       if Card_D.Activ /= "  " then
  3345.         if Card_D.Activ /= "IN" then
  3346.           Activ_Type  := Activ_Types'value(Card_D.Activ);
  3347.         end if;
  3348.       end if;
  3349.     exception
  3350.       when others  => Error_Message("ACTIV",Bad_Field);
  3351.     end;
  3352.     --
  3353.     begin
  3354.       if Card_D.Flag /= " " then
  3355.         if Card_D.Flag = "#" and Valid_Msg.Trtype = CHANGE then
  3356.           null;
  3357.         else
  3358.           Flag_Type     := Flag_Types'value(Card_D.Flag);
  3359.         end if;
  3360.       end if;
  3361.     exception
  3362.       when others  => Error_Message("FLAG ",Bad_Field);
  3363.     end;
  3364.     --
  3365.     if Card_D.Puic /= "      " then
  3366.       if Card_D.Puic = "#     " and Valid_Msg.Trtype = CHANGE then
  3367.         null;
  3368.       else
  3369.         Validate_Uic(Card_D.Puic,"PUIC ");
  3370.       end if;
  3371.     end if;
  3372.     --
  3373.     begin
  3374.       if Card_D.Cbcom /= " " then
  3375.         if Card_D.Cbcom = "#" and Valid_Msg.Trtype = CHANGE then
  3376.           null;
  3377.         else
  3378.           Cbcom_Type    := Cbcom_Types'value(Card_D.Cbcom);
  3379.         end if;
  3380.       end if;
  3381.     exception
  3382.       when others  => Error_Message("CBCOM",Bad_Field);
  3383.     end;
  3384.     --
  3385.     --    if DFCON is reported,it must be 1-5 or N T V S R G
  3386.     --
  3387.     begin
  3388.       if Card_D.Dfcon /= " " then
  3389.         Valid_Value := string_to_integer(Card_D.Dfcon);
  3390.         if Valid_Value not in 1..5 then
  3391.           Dfcon_Type  := Dfcon_Types'value(Card_D.Dfcon);
  3392.         end if;
  3393.       end if;
  3394.     exception
  3395.       when others  => Error_Message("DFCON",Bad_Field);
  3396.     end;
  3397.     --
  3398.     begin
  3399.       if Card_D.Point /= "               " then
  3400.         Valid_Value := string_to_integer(Card_D.Point(1..2));
  3401.         if Valid_Value not in 0..90 then
  3402.           raise constraint_error;
  3403.         end if;
  3404.         Valid_Value := string_to_integer(Card_D.Point(3..4));
  3405.         if Valid_Value not in 0..59 then
  3406.           raise constraint_error;
  3407.         end if;
  3408.         Valid_Value := string_to_integer(Card_D.Point(5..6));
  3409.         if Valid_Value not in 0..59 then
  3410.           raise constraint_error;
  3411.         end if;
  3412.         if Card_D.Point(7) = 'N' or Card_D.Point(7) = 'S' then
  3413.           null;
  3414.         else
  3415.           raise constraint_error;
  3416.         end if;
  3417.         Valid_Value := string_to_integer(Card_D.Point(8..10));
  3418.         if Valid_Value not in 0..180 then
  3419.           raise constraint_error;
  3420.         end if;
  3421.         Valid_Value := string_to_integer(Card_D.Point(11..12));
  3422.         if Valid_Value not in 0..59 then
  3423.           raise constraint_error;
  3424.         end if;
  3425.         Valid_Value := string_to_integer(Card_D.Point(13..14));
  3426.         if Valid_Value not in 0..59 then
  3427.           raise constraint_error;
  3428.         end if;
  3429.         if Card_D.Point(15) = 'E' or Card_D.Point(15) = 'W' then
  3430.           null;
  3431.         else
  3432.           raise constraint_error;
  3433.         end if;
  3434.       end if;
  3435.     exception
  3436.       when others  => Error_Message("Point",Bad_Field);
  3437.     end;
  3438.     --
  3439.     begin
  3440.       if Card_D.Nucin /= " " then
  3441.         Nucin_Type    := Nucin_Types'value(Card_D.Nucin);
  3442.       end if;
  3443.     exception
  3444.       when others  => Error_Message("NUCIN",Bad_Field);
  3445.     end;
  3446.     --
  3447.     if Card_D.Pctef /= " " then
  3448.       if Card_D.Pctef = "#" and Valid_Msg.Trtype = CHANGE then
  3449.         null;
  3450.       else
  3451.         Valid_Value := string_to_integer(Card_D.Pctef);
  3452.         if Valid_Value = 2 or Valid_Value = 4 or
  3453.            Valid_Value = 6 or Valid_Value = 8 then
  3454.           Error_Message("PCTEF",Bad_Field);
  3455.         end if;
  3456.       end if;
  3457.     end if;
  3458.     --
  3459.     --    if card is valid, place access pointer in message list and
  3460.     --    set up new access pointer for message list
  3461.     --
  3462.     if not Bad_Message then
  3463.       Valid_Msg.access_d  := Card_D;
  3464.       Link_List;
  3465.     end if;
  3466.  
  3467.   end Process_Card_D;
  3468.  
  3469.  
  3470. --**********************************************************************
  3471. --
  3472. --      This procedure does the processing for the validation of the
  3473. --    fields of a "G  " card.
  3474. --
  3475. --**********************************************************************
  3476.  
  3477.   procedure Process_Card_G is
  3478.  
  3479.   begin
  3480.     --
  3481.     --    set up new access pointer for card G
  3482.     --
  3483.     Card_G := new Card_Type_G;
  3484.     --
  3485.     --    place strings in field components
  3486.     --
  3487.     Card_G.Tcaa         := Input_Msg.card(15..43);
  3488.     Card_G.Media        := Input_Msg.card(44..44);
  3489.     Card_G.Tadc         := Input_Msg.card(45..45);
  3490.     Card_G.Route        := Input_Msg.card(46..52);
  3491.     Card_G.Rwdte.DDD    := Input_Msg.card(53..55);
  3492.     Card_G.Rwdte.YY     := Input_Msg.card(56..57);
  3493.     Card_G.Xrte         := Input_Msg.card(58..64);
  3494.     Card_G.Xdate.DDD    := Input_Msg.card(65..67);
  3495.     Card_G.Xdate.YY     := Input_Msg.card(68..69);
  3496.     --
  3497.     if Card_G.Tcaa = "#                            " and
  3498.        Valid_Msg.Trtype /= CHANGE then
  3499.       Error_Message("TCAA ",Bad_Field);
  3500.     end if;
  3501.     --
  3502.     begin
  3503.       if Card_G.Media /= " " then
  3504.         Media_Type    := Media_types'value(Card_G.Media);
  3505.       end if;
  3506.     exception
  3507.       when others  => Error_Message("MEDIA",Bad_Field);
  3508.     end;
  3509.     --
  3510.     begin
  3511.       if Card_G.Tadc /= " " then
  3512.         if Card_G.Tadc = "#" and Valid_Msg.Trtype = CHANGE then
  3513.           null;
  3514.         else
  3515.           Tadc_Type    := Tadc_types'value(Card_G.Tadc);
  3516.         end if;
  3517.       end if;
  3518.     exception
  3519.       when others  => Error_Message("TADC ",Bad_Field);
  3520.     end;
  3521.     --
  3522.     if Card_G.Route = "#      " and Valid_Msg.Trtype /= CHANGE then
  3523.       Error_Message("ROUTE",Bad_Field);
  3524.     end if;
  3525.     --
  3526.     Validate_DDDYY(Card_G.Rwdte.DDD,
  3527.                    Card_G.Rwdte.YY,
  3528.                    "RWDTE");
  3529.     --
  3530.     --    XRTE and XDATE are mutually inclusive
  3531.     --
  3532.     if Card_G.Xrte  = "       " and
  3533.        Card_G.Xdate.DDD & Card_G.Xdate.YY /= "     " then
  3534.       Error_Message("XRTE ",Field_Required);
  3535.     elsif Card_G.Xrte /= "       " and
  3536.           Card_G.Xdate.DDD & Card_G.Xdate.YY = "     " then
  3537.       Error_Message("XDATE",Field_Required);
  3538.     else
  3539.       if Card_G.Xrte = "#      " and Valid_Msg.Trtype /= CHANGE then
  3540.         Error_Message("XRTE ",Bad_Field);
  3541.       end if;
  3542.       Validate_DDDYY(Card_G.Xdate.DDD,
  3543.                      Card_G.Xdate.YY,
  3544.                      "XDATE");
  3545.     end if;
  3546.     --
  3547.     --    if card is valid, place access pointer in message list and
  3548.     --    set up new access pointer for message list
  3549.     --
  3550.     if not Bad_Message then
  3551.       Valid_Msg.access_g  := Card_G;
  3552.       Link_List;
  3553.     end if;
  3554.  
  3555.   end Process_Card_G;
  3556.  
  3557.  
  3558. --**********************************************************************
  3559. --
  3560. --      This procedure does the processing for the validation of the
  3561. --    fields of a "J  " card.
  3562. --
  3563. --**********************************************************************
  3564.  
  3565.   procedure Process_Card_J is
  3566.  
  3567.   begin
  3568.     --
  3569.     --    set up new access pointer for card J
  3570.     --
  3571.     Card_J := new Card_Type_J;
  3572.     --
  3573.     --    place strings in field components
  3574.     --
  3575.     Card_J.Tpers        := Input_Msg.card(15..16);
  3576.     Card_J.Pegeo        := Input_Msg.card(17..22);
  3577.     Card_J.Struc        := Input_Msg.card(23..27);
  3578.     Card_J.Auth         := Input_Msg.card(28..32);
  3579.     Card_J.Asgd         := Input_Msg.card(33..37);
  3580.     Card_J.Postr        := Input_Msg.card(38..42);
  3581.     Card_J.Deps         := Input_Msg.card(49..53);
  3582.     Card_J.Tdeps        := Input_Msg.card(54..58);
  3583.     Card_J.Caspw        := Input_Msg.card(59..63);
  3584.     Card_J.Ccasp        := Input_Msg.card(64..68);
  3585.     Card_J.Cceby        := Input_Msg.card(69..69);
  3586.     --
  3587.     --    validate TPERS must be reported
  3588.     --
  3589.     begin
  3590.       if Card_J.Tpers = "  " then
  3591.         Error_Message("TPERS",Field_Required);
  3592.       elsif Card_J.Tpers /= "AT" then
  3593.         Tpers_Type  := Tpers_Types'value(Card_J.Tpers);
  3594.       end if;
  3595.     exception
  3596.       when others  => Error_Message("TPERS",Bad_Field);
  3597.     end;
  3598.     --
  3599.     --    if PEGEO is reported it will be validated against an IDM
  3600.     --    database relation either the Geolocation database or the
  3601.     --    Uic database.  if PEGEO is blank and transaction is Change,
  3602.     --    then find the tuple for this unit in the "D" (Status data)
  3603.     --    relation, read the value of PRGEO or EMBRK (whichever one
  3604.     --    is non-blank), and set PEGEO to this value.
  3605.     --
  3606.     if Card_J.Pegeo /= "      " then
  3607.       if Invalid_Uic(Card_J.Pegeo) and
  3608.          Invalid_Geo(Card_J.Pegeo) then
  3609.         Error_Message("PEGEO",Bad_Field);
  3610.       end if;
  3611.     --
  3612.     --    if transaction is Change, use PRGEO or EMBRK value stored in
  3613.     --    database.
  3614.     --
  3615.     elsif Valid_Msg.Trtype = CHANGE then
  3616.       begin
  3617.         idm_command(idmrun,"return_status_prgeo $1");
  3618.         idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  3619.         idm_execute(idmrun);
  3620.         idm_fetch(idmrun);
  3621.         idm_column(idmrun,1,Card_J.Pegeo(1..4),Length_of_String);
  3622.         if Card_J.Pegeo = "      " then
  3623.           idm_command(idmrun,"return_status_embrk $1");
  3624.           idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  3625.           idm_execute(idmrun);
  3626.           idm_fetch(idmrun);
  3627.           idm_column(idmrun,1,Card_J.Pegeo,Length_of_String);
  3628.         end if;
  3629.       exception
  3630.         when others   =>
  3631.           Error_Message("PEGEO",Can_Not_Validate_Correctly);
  3632.       end;
  3633.     end if;
  3634.     --
  3635.     Validate_Numeric(Card_J.Struc,"STRUC");
  3636.     Validate_Numeric(Card_J.Auth,"AUTH ");
  3637.     Validate_Numeric(Card_J.Asgd,"ASGD ");
  3638.     --
  3639.     if Card_J.Postr = "#    " and Valid_Msg.Trtype = CHANGE then
  3640.       null;
  3641.     else
  3642.       Validate_Numeric(Card_J.Postr,"POSTR");
  3643.     end if;
  3644.     --
  3645.     --    validate PICDA if blank put system date in PICDA
  3646.     --
  3647.     begin
  3648.       if Input_Msg.card(43..48) = "      " then
  3649.         Card_J.Picda.Year  := System_Year;
  3650.         Card_J.Picda.Month := System_Month;
  3651.         Card_J.Picda.Day   := System_Day;
  3652.       else
  3653.         Valid_Value := string_to_integer(Input_Msg.card(43..44));
  3654.         if Valid_Value < 0 then
  3655.           raise constraint_error;
  3656.         end if;
  3657.         Card_J.Picda.Year := Valid_Value + 1900;
  3658.         Leap_Year := Valid_Value /4;
  3659.         Leap_Year := Valid_Value - (Leap_Year * 4);
  3660.         if Leap_Year = 0 then
  3661.           Days_in_Month(2) := 29;
  3662.         else
  3663.           Days_in_Month(2) := 28;
  3664.         end if;
  3665.         Card_J.Picda.Month := string_to_integer(Input_Msg.card(45..46));
  3666.         Card_J.Picda.Day   := string_to_integer(Input_Msg.card(47..48));
  3667.         if Card_J.Picda.Day > Days_in_Month(Card_J.Picda.Month) then
  3668.           raise constraint_error;
  3669.         end if;
  3670.       end if;
  3671.  
  3672.     exception
  3673.       when others  => Error_Message("PICDA",Bad_Field);
  3674.     end;
  3675.     --
  3676.     if Card_J.Deps = "#    " and Valid_Msg.Trtype = CHANGE then
  3677.       null;
  3678.     else
  3679.       Validate_Numeric(Card_J.Deps,"DEPS ");
  3680.     end if;
  3681.     --
  3682.     if Card_J.Tdeps = "#    " and Valid_Msg.Trtype = CHANGE then
  3683.       null;
  3684.     else
  3685.       Validate_Numeric(Card_J.Tdeps,"TDEPS");
  3686.     end if;
  3687.     --
  3688.     --    CASPW and CCASP are mutually inclusive
  3689.     --
  3690.     if Card_J.Caspw /= "     " and
  3691.        Card_J.Ccasp  = "     " then
  3692.       Error_Message("CCASP",Field_Required);
  3693.     elsif Card_J.Caspw  = "     " and
  3694.           Card_J.Ccasp /= "     " then
  3695.       Error_Message("CASPW",Field_Required);
  3696.     else
  3697.       Validate_Numeric(Card_J.Caspw,"CASPW");
  3698.       Validate_Numeric(Card_J.Ccasp,"CCASP");
  3699.     end if;
  3700.     --
  3701.     begin
  3702.       if Card_J.Cceby /= " " then
  3703.         Cceby_Type    := Cceby_Types'value(Card_J.Cceby);
  3704.       end if;
  3705.     exception
  3706.       when others  => Error_Message("CCEBY",Bad_Field);
  3707.     end;
  3708.     --
  3709.     --    if card is valid place access pointer in message list and
  3710.     --    set up new access pointer for message list
  3711.     --
  3712.     if not Bad_Message then
  3713.       Valid_Msg.access_j  := Card_J;
  3714.       Link_List;
  3715.     end if;
  3716.  
  3717.   end Process_Card_J;
  3718.  
  3719.  
  3720. --**********************************************************************
  3721. --
  3722. --      This procedure does the processing for the validation of the
  3723. --    fields of a "K  " card.
  3724. --
  3725. --**********************************************************************
  3726.  
  3727.   procedure Process_Card_K is
  3728.     Ready_Value : integer;
  3729.     Prrat_Value : integer;
  3730.     Esrat_Value : integer;
  3731.     Errat_Value : integer;
  3732.     Trrat_Value : integer;
  3733.   begin
  3734.     --
  3735.     --    initialize variables
  3736.     --
  3737.     Ready_Value := 0;
  3738.     Prrat_Value := 0;
  3739.     Esrat_Value := 0;
  3740.     Errat_Value := 0;
  3741.     Trrat_Value := 0;
  3742.     --
  3743.     --    set up access pointer for card K
  3744.     --
  3745.     Card_K := new Card_Type_K;
  3746.     --
  3747.     --    place strings in field components
  3748.     --
  3749.     Card_K.Tread        := Input_Msg.card(15..19);
  3750.     Card_K.Ready        := Input_Msg.card(20..20);
  3751.     Card_K.Reasn        := Input_Msg.card(21..21);
  3752.     Card_K.Prrat        := Input_Msg.card(22..22);
  3753.     Card_K.Prres        := Input_Msg.card(23..25);
  3754.     Card_K.Esrat        := Input_Msg.card(26..26);
  3755.     Card_K.Esres        := Input_Msg.card(27..29);
  3756.     Card_K.Errat        := Input_Msg.card(30..30);
  3757.     Card_K.Erres        := Input_Msg.card(31..33);
  3758.     Card_K.Trrat        := Input_Msg.card(34..34);
  3759.     Card_K.Trres        := Input_Msg.card(35..37);
  3760.     Card_K.Secrn        := Input_Msg.card(38..40);
  3761.     Card_K.Terrn        := Input_Msg.card(41..43);
  3762.     Card_K.Carat        := Input_Msg.card(44..44);
  3763.     Card_K.Cadat.YY     := Input_Msg.card(45..46);
  3764.     Card_K.Cadat.MM     := Input_Msg.card(47..48);
  3765.     Card_K.Cadat.DD     := Input_Msg.card(49..50);
  3766.     Card_K.Lim          := Input_Msg.card(51..51);
  3767.     Card_K.Rlim         := Input_Msg.card(52..52);
  3768.     Card_K.Ricda.YY     := Input_Msg.card(53..54);
  3769.     Card_K.Ricda.MM     := Input_Msg.card(55..56);
  3770.     Card_K.Ricda.DD     := Input_Msg.card(57..58);
  3771.     --
  3772.     --    if TREAD is reported must be JCRR1 POMCS or 001HRS - 072HRS
  3773.     --
  3774.     begin
  3775.       if Card_K.Tread /= "     " then
  3776.         if Card_K.Tread(3..5) = "HRS" then
  3777.           Valid_Value := string_to_integer(Card_K.Tread(1..2));
  3778.           if Valid_Value not in 1..72 then
  3779.             raise constraint_error;
  3780.           end if;
  3781.         else
  3782.           Tread_Type  := Tread_Types'value(Card_K.Tread);
  3783.         end if;
  3784.       end if;
  3785.     exception
  3786.       when others  => Error_Message("TREAD",Bad_Field);
  3787.     end;
  3788.     --
  3789.     if Card_K.Ready /= " " then
  3790.       Ready_Value := string_to_integer(Card_K.Ready);
  3791.       if Ready_Value not in 1..5 then
  3792.         Error_Message("READY",Bad_Field);
  3793.       end if;
  3794.     end if;
  3795.     --
  3796.     if Card_K.Prrat /= " " then
  3797.       Prrat_Value := string_to_integer(Card_K.Prrat);
  3798.       if Prrat_Value not in 1..6 then
  3799.         Error_Message("PRRAT",Bad_Field);
  3800.       elsif Prrat_Value /= 6 and Card_K.Reasn /= "X" then
  3801.         if Prrat_Value > Ready_Value then
  3802.           Error_Message("PRRAT",Bad_Field);
  3803.         end if;
  3804.       end if;
  3805.     end if;
  3806.     --
  3807.     begin
  3808.       if Card_K.Prres = "   " then
  3809.         if Prrat_Value in 2..4 then
  3810.           Error_Message("PRRES",Field_Required);
  3811.         end if;
  3812.       else
  3813.         Prres_Type    := Prres_Prres_Types'value(Card_K.Prres);
  3814.       end if;
  3815.     exception
  3816.       when others  => Error_Message("PRRES",Bad_Field);
  3817.     end;
  3818.     --
  3819.     if Card_K.Esrat /= " " then
  3820.       Esrat_Value := string_to_integer(Card_K.Esrat);
  3821.       if Esrat_Value not in 1..6 then
  3822.         Error_Message("ESRAT",Bad_Field);
  3823.       elsif Esrat_Value /= 6 and Card_K.Reasn /= "X" then
  3824.         if Esrat_Value > Ready_Value then
  3825.           Error_Message("ESRAT",Bad_Field);
  3826.         end if;
  3827.       end if;
  3828.     end if;
  3829.     --
  3830.     begin
  3831.       if Card_K.Esres = "   " then
  3832.         if Esrat_Value in 2..4 then
  3833.           Error_Message("ESRES",Field_Required);
  3834.         end if;
  3835.       else
  3836.         Esres_Type    := Esres_Prres_Types'value(Card_K.Esres);
  3837.       end if;
  3838.     exception
  3839.       when others  => Error_Message("ESRES",Bad_Field);
  3840.     end;
  3841.     --
  3842.     if Card_K.Errat /= " " then
  3843.       Errat_Value := string_to_integer(Card_K.Errat);
  3844.       if Errat_Value not in 1..6 then
  3845.         Error_Message("ERRAT",Bad_Field);
  3846.       elsif Errat_Value /= 6 and Card_K.Reasn /= "X" then
  3847.         if Errat_Value > Ready_Value then
  3848.           Error_Message("ERRAT",Bad_Field);
  3849.         end if;
  3850.       end if;
  3851.     end if;
  3852.     --
  3853.     begin
  3854.       if Card_K.Erres = "   " then
  3855.         if Errat_Value in 2..4 then
  3856.           Error_Message("ERRES",Field_Required);
  3857.         end if;
  3858.       else
  3859.         Erres_Type    := Erres_Prres_Types'value(Card_K.Erres);
  3860.       end if;
  3861.     exception
  3862.       when others  => Error_Message("ERRES",Bad_Field);
  3863.     end;
  3864.     --
  3865.     if Card_K.Trrat /= " " then
  3866.       Trrat_Value := string_to_integer(Card_K.Trrat);
  3867.       if Trrat_Value not in 1..6 then
  3868.         Error_Message("TRRAT",Bad_Field);
  3869.       elsif Trrat_Value /= 6 and Card_K.Reasn /= "X" then
  3870.         if Trrat_Value > Ready_Value then
  3871.           Error_Message("TRRAT",Bad_Field);
  3872.         end if;
  3873.       end if;
  3874.     end if;
  3875.     --
  3876.     begin
  3877.       if Card_K.Trres = "   " then
  3878.         if Trrat_Value in 2..4 then
  3879.           Error_Message("TRRES",Field_Required);
  3880.         end if;
  3881.       else
  3882.         Trres_Type    := Trres_Prres_Types'value(Card_K.Trres);
  3883.       end if;
  3884.     exception
  3885.       when others  => Error_Message("TRRES",Bad_Field);
  3886.     end;
  3887.     --
  3888.     begin
  3889.       if Card_K.Reasn /= " " then
  3890.         Reasn_Type := Reasn_Types'value(Card_K.Reasn);
  3891.         case Reasn_Type is
  3892.           when N | M  => if Ready_Value /= 5 then
  3893.                            Error_Message("READY",Bad_Field);
  3894.                          end if;
  3895.           when X      => if Card_K.Ready = " " then
  3896.                            Error_Message("READY",Field_Required);
  3897.                          end if;
  3898.           when others => Valid_Value := 0;
  3899.                          if Prrat_Value /= 6 and
  3900.                             Prrat_Value > Valid_Value then
  3901.                            Valid_Value := Prrat_Value;
  3902.                          end if;
  3903.                          if Esrat_Value /= 6 and
  3904.                             Esrat_Value > Valid_Value then
  3905.                            Valid_Value := Esrat_Value;
  3906.                          end if;
  3907.                          if Errat_Value /= 6 and
  3908.                             Errat_Value > Valid_Value then
  3909.                            Valid_Value := Errat_Value;
  3910.                          end if;
  3911.                          if Trrat_Value /= 6 and
  3912.                             Trrat_Value > Valid_Value then
  3913.                            Valid_Value := Trrat_Value;
  3914.                          end if;
  3915.                          if Ready_Value /= Valid_Value then
  3916.                            Error_Message("READY",Bad_Field);
  3917.                          end if;
  3918.           end case;
  3919.       end if;
  3920.     exception
  3921.       when others  => Error_Message("REASN",Bad_Field);
  3922.     end;
  3923.     --
  3924.     --    if SECRN is reported, REASN must be reported on this card or be
  3925.     --    stored already in the database.
  3926.     --
  3927.     begin
  3928.       if Card_K.Secrn /= "   " then
  3929.         if Valid_Msg.Trtype = ADD and Card_K.Reasn = " " then
  3930.           Error_Message("REASN",Field_Required);
  3931.         end if;
  3932.         if Valid_Msg.Trtype = CHANGE and Card_K.Reasn = " " then
  3933.           begin
  3934.             idm_command(idmrun,"return_readiness_reason $1");
  3935.             idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  3936.             idm_execute(idmrun);
  3937.             idm_fetch(idmrun);
  3938.             idm_column(idmrun,1,Working_String(1..1),Length_of_String);
  3939.             if Working_String(1..1) = " " then
  3940.               Error_Message("REASN",Field_Required);
  3941.             end if;
  3942.           exception
  3943.             when others  =>
  3944.               Error_Message("REASN",Can_Not_Validate_Correctly);
  3945.           end;
  3946.         end if;
  3947.         if Valid_Msg.Trtype = CHANGE and Card_K.Secrn = "#  " then
  3948.           null;
  3949.         else
  3950.           Secrn_Type    := Prres_Types'value(Card_K.Secrn);
  3951.         end if;
  3952.       end if;
  3953.     exception
  3954.       when others  => Error_Message("SECRN",Bad_Field);
  3955.     end;
  3956.     --
  3957.     --    if TERRN is reported, REASN and SECRN must be reported on this
  3958.     --    card or be stored already in the database.  TERRN must not be
  3959.     --    equal to SECRN.
  3960.     --
  3961.     begin
  3962.       if Card_K.Terrn /= "   " then
  3963.         if Valid_Msg.Trtype = ADD then
  3964.           if Card_K.Reasn = " " then
  3965.             Error_Message("REASN",Field_Required);
  3966.           end if;
  3967.           if Card_K.Secrn = "   " then
  3968.             Error_Message("SECRN",Field_Required);
  3969.           end if;
  3970.         elsif Valid_Msg.Trtype = CHANGE then
  3971.           begin
  3972.             Working_String := "          ";
  3973.             if Card_K.Secrn = " " then
  3974.               idm_command(idmrun,"return_readiness_reason2 $1");
  3975.               idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  3976.               idm_execute(idmrun);
  3977.               idm_fetch(idmrun);
  3978.              idm_column(idmrun,1,Working_String(1..1),Length_of_String);
  3979.               if Working_String(1..1) = " " then
  3980.                 Error_Message("SECRN",Field_Required);
  3981.               else
  3982.                 Secrn_Type := Prres_Types'value(Working_String);
  3983.               end if;
  3984.             end if;
  3985.             if Card_K.Reasn = " " then
  3986.               idm_command(idmrun,"return_readiness_reason $1");
  3987.               idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  3988.               idm_execute(idmrun);
  3989.               idm_fetch(idmrun);
  3990.              idm_column(idmrun,1,Working_String(1..1),Length_of_String);
  3991.               if Working_String(1..1) = " " then
  3992.                 Error_Message("REASN",Field_Required);
  3993.               end if;
  3994.             end if;
  3995.           exception
  3996.             when others  =>
  3997.               Error_Message("TERRN",Can_Not_Validate_Correctly);
  3998.           end;
  3999.         end if;
  4000.         if Valid_Msg.Trtype = CHANGE and Card_K.Terrn = "#  " then
  4001.           null;
  4002.         else
  4003.           Terrn_Type    := Prres_Types'value(Card_K.Terrn);
  4004.           if Terrn_Type = Secrn_Type then
  4005.             Error_Message("TERRN",Bad_Field);
  4006.           end if;
  4007.         end if;
  4008.       end if;
  4009.     exception
  4010.       when others  => Error_Message("TERRN",Bad_Field);
  4011.     end;
  4012.     --
  4013.     --    CARAT and CADAT are mutually inclusive and are fields that can
  4014.     --    be "#" when transaction is Change.  CARAT must not be equal to
  4015.     --    READY.  CADAT must not be < Header Date.
  4016.     --
  4017.     if (Card_K.Carat = " " and Card_K.Cadat.YY &
  4018.         Card_K.Cadat.MM & Card_K.Cadat.DD = "      ") or
  4019.        (Valid_Msg.Trtype = CHANGE and Card_K.Carat = "#" and
  4020.         Card_K.Cadat.YY &
  4021.         Card_K.Cadat.MM & Card_K.Cadat.DD = "#     ") then
  4022.       null;
  4023.     elsif Card_K.Carat = " " then
  4024.       Error_Message("CARAT",Field_Required);
  4025.     elsif Card_K.Cadat.YY &
  4026.           Card_K.Cadat.MM & Card_K.Cadat.DD = "      " then
  4027.       Error_Message("CADAT",Field_Required);
  4028.     else
  4029.     --
  4030.     --    if CARAT is reported must equal 1 2 3 4 5 6 and not be equal to
  4031.     --    READY
  4032.     --
  4033.       Valid_Value := string_to_integer(Card_K.Carat);
  4034.       if Valid_Value not in 1..6 or Card_K.Carat = Card_K.Ready then
  4035.         Error_Message("CARAT",Bad_Field);
  4036.       end if;
  4037.     --
  4038.     --    if CADAT is reported it must be > the header date
  4039.     --
  4040.       if Card_K.Cadat.YY &
  4041.          Card_K.Cadat.MM & Card_K.Cadat.DD <= Header_Date then
  4042.         Error_Message("CADAT",Bad_Field);
  4043.       else
  4044.         Validate_YYMMDD(Card_K.Cadat.YY,
  4045.                         Card_K.Cadat.MM,
  4046.                         Card_K.Cadat.DD,
  4047.                         "CADAT");
  4048.       end if;
  4049.     end if;
  4050.     --
  4051.     if Card_K.Lim /= " " then
  4052.       if Valid_Msg.Trtype = CHANGE and Card_K.Lim = "#" then
  4053.         null;
  4054.       else
  4055.         Valid_Value := string_to_integer(Card_K.Lim);
  4056.         if Valid_Value not in 1..6 or Card_K.Lim = Card_K.Ready then
  4057.           Error_Message("LIM  ",Bad_Field);
  4058.         end if;
  4059.       end if;
  4060.     end if;
  4061.     --
  4062.     begin
  4063.       if Card_K.Rlim /= " " then
  4064.         if Valid_Msg.Trtype = CHANGE and Card_K.Rlim = "#" then
  4065.           null;
  4066.         else
  4067.           Rlim_Type     := Rlim_Types'value(Card_K.Rlim);
  4068.         end if;
  4069.       end if;
  4070.     exception
  4071.       when others  => Error_Message("RLIM ",Bad_Field);
  4072.     end;
  4073.     --
  4074.     --    if reported RICDA can not be < RICDA stored in database if
  4075.     --    transaction type is "C"
  4076.     --
  4077.     if Card_K.Ricda.YY &
  4078.        Card_K.Ricda.MM & Card_K.Ricda.DD /= "      " then
  4079.       Validate_YYMMDD(Card_K.Ricda.YY,
  4080.                       Card_K.Ricda.MM,
  4081.                       Card_K.Ricda.DD,
  4082.                       "RICDA");
  4083.       if Valid_Msg.Trtype = CHANGE then
  4084.         begin
  4085.           Working_String := "          ";
  4086.           idm_command(idmrun,"return_readiness_ricda $1");
  4087.           idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  4088.           idm_execute(idmrun);
  4089.           idm_fetch(idmrun);
  4090.           idm_column(idmrun,1,Working_String(1..8),Length_of_String);
  4091.         exception
  4092.           when others  =>
  4093.             Error_Message("RICDA",Can_Not_Validate_Correctly);
  4094.         end;
  4095.       end if;
  4096.     end if;
  4097.     --
  4098.     --    if card is valid, place access pointer in message list and
  4099.     --    set up new access pointer for message list
  4100.     --
  4101.     if not Bad_Message then
  4102.       Valid_Msg.access_k  := Card_K;
  4103.       Link_List;
  4104.     end if;
  4105.  
  4106.   end Process_Card_K;
  4107.  
  4108.  
  4109. --**********************************************************************
  4110. --
  4111. --      This procedure does the processing for the validation of the
  4112. --    fields of a "L  " card.
  4113. --
  4114. --**********************************************************************
  4115.  
  4116.   procedure Process_Card_L is
  4117.  
  4118.   begin
  4119.     --
  4120.     --    initialize variables
  4121.     --
  4122.     Mepsd_Value := 0;
  4123.     Meord_Value := 0;
  4124.     Meorn_Value := 0;
  4125.     Meorc_Value := 0;
  4126.     Meoro_Value := 0;
  4127.     Crewf_Value := 0;
  4128.     Crmrd_Value := 0;
  4129.     Crmrn_Value := 0;
  4130.     Crmrc_Value := 0;
  4131.     Crmro_Value := 0;
  4132.     --
  4133.     --    set up new access pointer for card L
  4134.     --
  4135.     Card_L := new Card_Type_L;
  4136.     --
  4137.     --    place strings in field components
  4138.     --
  4139.     Card_L.Meqpt        := Input_Msg.card(15..27);
  4140.     Card_L.Fordv        := Input_Msg.card(28..28);
  4141.     Card_L.Mepsa        := Input_Msg.card(29..31);
  4142.     Card_L.Metal        := Input_Msg.card(32..34);
  4143.     Card_L.Mepsd        := Input_Msg.card(35..37);
  4144.     Card_L.Meord        := Input_Msg.card(38..40);
  4145.     Card_L.Meorn        := Input_Msg.card(41..43);
  4146.     Card_L.Meorc        := Input_Msg.card(44..46);
  4147.     Card_L.Meoro        := Input_Msg.card(47..49);
  4148.     Card_L.Crewa        := Input_Msg.card(50..51);
  4149.     Card_L.Creal        := Input_Msg.card(52..53);
  4150.     Card_L.Crewf        := Input_Msg.card(54..55);
  4151.     Card_L.Crmrd        := Input_Msg.card(56..57);
  4152.     Card_L.Crmrn        := Input_Msg.card(58..59);
  4153.     Card_L.Crmrc        := Input_Msg.card(60..61);
  4154.     Card_L.Crmro        := Input_Msg.card(62..63);
  4155.     Card_L.Merec_1      := Input_Msg.card(64..65);
  4156.     Card_L.Merec_2      := Input_Msg.card(66..67);
  4157.     Card_L.Merec_3      := Input_Msg.card(68..69);
  4158.     --
  4159.     --    MEQPT is required to be reported
  4160.     --
  4161.     if Card_L.Meqpt = "             " then
  4162.       Error_Message("MEQPT",Field_Required);
  4163.     else
  4164.       Validate_Meqpt(Card_L.Meqpt,"MEQPT");
  4165.     end if;
  4166.     --
  4167.     begin
  4168.       if Card_L.Fordv /= " " then
  4169.         Fordv_Type    := Fordv_Types'value(Card_L.Fordv);
  4170.       end if;
  4171.     exception
  4172.       when others  => Error_Message("FORDV",Bad_Field);
  4173.     end;
  4174.     --
  4175.     Validate_Numeric(Card_L.Mepsa,"MEPSA");
  4176.     Validate_Numeric(Card_L.Metal,"METAL");
  4177.     --
  4178.     if Card_L.Mepsd /= "   " then
  4179.       Mepsd_Value := string_to_integer(Card_L.Mepsd);
  4180.       if Mepsd_Value < 0 then
  4181.         Error_Message("MEPSD",Bad_Field);
  4182.       else
  4183.         Load_Meq_Values;
  4184.       end if;
  4185.     end if;
  4186.     --
  4187.     if Card_L.Meord /= "   " then
  4188.       Meord_Value := string_to_integer(Card_L.Meord);
  4189.       if Meord_Value < 0 then
  4190.         Error_Message("MEORD",Bad_Field);
  4191.       end if;
  4192.     end if;
  4193.     --
  4194.     if Card_L.Meorn /= "   " then
  4195.       Meorn_Value := string_to_integer(Card_L.Meorn);
  4196.       if Meorn_Value < 0 then
  4197.         Error_Message("MEORN",Bad_Field);
  4198.       end if;
  4199.     end if;
  4200.     --
  4201.     if Card_L.Meorc /= "   " then
  4202.       Meorc_Value := string_to_integer(Card_L.Meorc);
  4203.       if Meorc_Value < 0 then
  4204.         Error_Message("MEORC",Bad_Field);
  4205.       end if;
  4206.     end if;
  4207.     --
  4208.     if Card_L.Meoro /= "   " then
  4209.       Meoro_Value := string_to_integer(Card_L.Meoro);
  4210.       if Meoro_Value < 0 then
  4211.         Error_Message("MEORO",Bad_Field);
  4212.       end if;
  4213.     end if;
  4214.     --
  4215.     --    if MEPSD is reported, the four fields being add together below
  4216.     --    must be reported at the same time or have values already in the
  4217.     --    database.
  4218.     --
  4219.     if Mepsd_Value < 0 or
  4220.        Mepsd_Value < Meord_Value +
  4221.                      Meorn_Value + Meorc_Value + Meoro_Value then
  4222.       Error_Message("MEPSD",Bad_Field);
  4223.     end if;
  4224.     --
  4225.     Validate_Numeric(Card_L.Crewa,"CREWA");
  4226.     Validate_Numeric(Card_L.Creal,"CREAL");
  4227.     --
  4228.     if Card_L.Crewf /= "  " then
  4229.       Crewf_Value := string_to_integer(Card_L.Crewf);
  4230.       if Crewf_Value < 0 then
  4231.         Error_Message("CREWF",Bad_Field);
  4232.       else
  4233.         Load_Crew_Values;
  4234.       end if;
  4235.     end if;
  4236.     --
  4237.     if Card_L.Crmrd /= "  " then
  4238.       Crmrd_Value := string_to_integer(Card_L.Crmrd);
  4239.       if Crmrd_Value < 0 then
  4240.         Error_Message("CRMRD",Bad_field);
  4241.       end if;
  4242.     end if;
  4243.     --
  4244.     if Card_L.Crmrn /= "  " then
  4245.       Crmrn_Value := string_to_integer(Card_L.Crmrn);
  4246.       if Crmrn_Value < 0 then
  4247.         Error_Message("CRMRN",Bad_field);
  4248.       end if;
  4249.     end if;
  4250.     --
  4251.     if Card_L.Crmrc /= "  " then
  4252.       Crmrc_Value := string_to_integer(Card_L.Crmrc);
  4253.       if Crmrc_Value < 0 then
  4254.         Error_Message("CRMRC",Bad_field);
  4255.       end if;
  4256.     end if;
  4257.     --
  4258.     if Card_L.Crmro /= "  " then
  4259.       Crmro_Value := string_to_integer(Card_L.Crmro);
  4260.       if Crmro_Value < 0 then
  4261.         Error_Message("CRMRO",Bad_field);
  4262.       end if;
  4263.     end if;
  4264.     --
  4265.     --    if CREWF is reported, the four fields being add together below
  4266.     --    must be reported at the same time or have values already in the
  4267.     --    database.
  4268.     --
  4269.     if Crewf_Value < 0 or
  4270.        Crewf_Value < Crmrd_Value +
  4271.        Crmrn_Value + Crmrc_Value + Crmro_Value then
  4272.       Error_Message("CREWF",Bad_Field);
  4273.     end if;
  4274.     --
  4275.     begin
  4276.       if Card_L.Merec_1 /= "  " then
  4277.         if Card_L.Merec_1 /= "# " then
  4278.           Merec_Type  := Merec_Types'value(Card_L.Merec_1);
  4279.         end if;
  4280.       end if;
  4281.       if Card_L.Merec_2 /= "  " then
  4282.         if Card_L.Merec_2 /= "# " then
  4283.           Merec_Type  := Merec_Types'value(Card_L.Merec_2);
  4284.         end if;
  4285.       end if;
  4286.       if Card_L.Merec_3 /= "  " then
  4287.         if Card_L.Merec_3 /= "# " then
  4288.           Merec_Type  := Merec_Types'value(Card_L.Merec_3);
  4289.         end if;
  4290.       end if;
  4291.     exception
  4292.       when others  => Error_Message("MEREC",Bad_Field);
  4293.     end;
  4294.     --
  4295.     --    if card is valid, place access pointer in message list and
  4296.     --    set up new access pointer for message list
  4297.     --
  4298.     if not Bad_Message then
  4299.       Valid_Msg.access_l  := Card_L;
  4300.       Link_List;
  4301.     end if;
  4302.  
  4303.   end Process_Card_L;
  4304.  
  4305.  
  4306. --**********************************************************************
  4307. --
  4308. --      This procedure does the processing for the validation of the
  4309. --    fields of a "M  " card.
  4310. --
  4311. --**********************************************************************
  4312.  
  4313.   procedure Process_Card_M is
  4314.  
  4315.   begin
  4316.     --
  4317.     --    initialize variables
  4318.     --
  4319.     Mepsd_Value := 0;
  4320.     Meord_Value := 0;
  4321.     Meorn_Value := 0;
  4322.     Meorc_Value := 0;
  4323.     Meoro_Value := 0;
  4324.     Crewf_Value := 0;
  4325.     Crmrd_Value := 0;
  4326.     Crmrn_Value := 0;
  4327.     Crmrc_Value := 0;
  4328.     Crmro_Value := 0;
  4329.     --
  4330.     --    set up new access pointer for card M
  4331.     --
  4332.     Card_M := new Card_Type_M;
  4333.     --
  4334.     --    place strings in field components
  4335.     --
  4336.     Card_M.Meqpt        := Input_Msg.card(15..27);
  4337.     Card_M.Tegeo        := Input_Msg.card(28..33);
  4338.     Card_M.Mepsd        := Input_Msg.card(34..36);
  4339.     Card_M.Meord        := Input_Msg.card(37..39);
  4340.     Card_M.Meorn        := Input_Msg.card(40..42);
  4341.     Card_M.Meorc        := Input_Msg.card(43..45);
  4342.     Card_M.Meoro        := Input_Msg.card(46..48);
  4343.     Card_M.Crewf        := Input_Msg.card(49..50);
  4344.     Card_M.Crmrd        := Input_Msg.card(51..52);
  4345.     Card_M.Crmrn        := Input_Msg.card(53..54);
  4346.     Card_M.Crmrc        := Input_Msg.card(55..56);
  4347.     Card_M.Crmro        := Input_Msg.card(57..58);
  4348.     Card_M.Merec_1      := Input_Msg.card(59..60);
  4349.     Card_M.Merec_2      := Input_Msg.card(61..62);
  4350.     Card_M.Merec_3      := Input_Msg.card(63..64);
  4351.     --
  4352.     --    MEQPT must be reported
  4353.     --
  4354.     if Card_M.Meqpt = "             " then
  4355.       Error_Message("MEQPT",Field_Required);
  4356.     else
  4357.       Validate_Meqpt(Card_M.Meqpt,"MEQPT");
  4358.     end if;
  4359.     --
  4360.     --    if TEGEO is reported it will be validated against an IDM
  4361.     --    database relation, either the Geoloc or UIC.
  4362.     --
  4363.     if Card_M.Tegeo = "      " then
  4364.       Error_Message("TEGEO",Field_Required);
  4365.     elsif Invalid_Uic(Card_M.Tegeo) and
  4366.           Invalid_Geo(Card_M.Tegeo) then
  4367.       Error_Message("TEGEO",Field_Required);
  4368.     end if;
  4369.     --
  4370.     --
  4371.     if Card_M.Mepsd /= "   " then
  4372.       Mepsd_Value := string_to_integer(Card_M.Mepsd);
  4373.       if Mepsd_Value < 0 then
  4374.         Error_Message("MEPSD",Bad_Field);
  4375.       else
  4376.         Load_Meq_Values;
  4377.       end if;
  4378.     end if;
  4379.     --
  4380.     if Card_M.Meord /= "   " then
  4381.       Meord_Value := string_to_integer(Card_M.Meord);
  4382.       if Meord_Value < 0 then
  4383.         Error_Message("MEORD",Bad_Field);
  4384.       end if;
  4385.     end if;
  4386.     --
  4387.     if Card_M.Meorn /= "   " then
  4388.       Meorn_Value := string_to_integer(Card_M.Meorn);
  4389.       if Meorn_Value < 0 then
  4390.         Error_Message("MEORN",Bad_Field);
  4391.       end if;
  4392.     end if;
  4393.     --
  4394.     if Card_M.Meorc /= "   " then
  4395.       Meorc_Value := string_to_integer(Card_M.Meorc);
  4396.       if Meorc_Value < 0 then
  4397.         Error_Message("MEORC",Bad_Field);
  4398.       end if;
  4399.     end if;
  4400.     --
  4401.     if Card_M.Meoro /= "   " then
  4402.       Meoro_Value := string_to_integer(Card_M.Meoro);
  4403.       if Meoro_Value < 0 then
  4404.         Error_Message("MEORO",Bad_Field);
  4405.       end if;
  4406.     end if;
  4407.     --
  4408.     --    if MEPSD is reported, the four fields being add together below
  4409.     --    must be reported at the same time or have values already in the
  4410.     --    database.
  4411.     --
  4412.     if Mepsd_Value < 0 or
  4413.        Mepsd_Value < Meord_Value +
  4414.                      Meorn_Value + Meorc_Value + Meoro_Value then
  4415.       Error_Message("MEPSD",Bad_Field);
  4416.     end if;
  4417.     --
  4418.     if Card_M.Crewf /= "  " then
  4419.       Crewf_Value := string_to_integer(Card_M.Crewf);
  4420.       if Crewf_Value < 0 then
  4421.         Error_Message("CREWF",Bad_Field);
  4422.       else
  4423.         Load_Crew_Values;
  4424.       end if;
  4425.     end if;
  4426.     --
  4427.     if Card_M.Crmrd /= "  " then
  4428.       Crmrd_Value := string_to_integer(Card_M.Crmrd);
  4429.       if Crmrd_Value < 0 then
  4430.         Error_Message("CRMRD",Bad_field);
  4431.       end if;
  4432.     end if;
  4433.     --
  4434.     if Card_M.Crmrn /= "  " then
  4435.       Crmrn_Value := string_to_integer(Card_M.Crmrn);
  4436.       if Crmrn_Value < 0 then
  4437.         Error_Message("CRMRN",Bad_field);
  4438.       end if;
  4439.     end if;
  4440.     --
  4441.     if Card_M.Crmrc /= "  " then
  4442.       Crmrc_Value := string_to_integer(Card_M.Crmrc);
  4443.       if Crmrc_Value < 0 then
  4444.         Error_Message("CRMRC",Bad_field);
  4445.       end if;
  4446.     end if;
  4447.     --
  4448.     if Card_M.Crmro /= "  " then
  4449.       Crmro_Value := string_to_integer(Card_M.Crmro);
  4450.       if Crmro_Value < 0 then
  4451.         Error_Message("CRMRO",Bad_field);
  4452.       end if;
  4453.     end if;
  4454.     --
  4455.     --    if CREWF is reported, the four fields being add together below
  4456.     --    must be reported at the same time or have values already in the
  4457.     --    database.
  4458.     --
  4459.     if Crewf_Value < 0 or
  4460.        Crewf_Value < Crmrd_Value + Crmrn_Value + Crmrc_Value + Crmro_Value then
  4461.       Error_Message("CREWF",Bad_Field);
  4462.     end if;
  4463.     --
  4464.     begin
  4465.       if Card_M.Merec_1 /= "  " then
  4466.         if Card_M.Merec_1 /= "# " then
  4467.           Merec_Type  := Merec_Types'value(Card_M.Merec_1);
  4468.         end if;
  4469.       end if;
  4470.       if Card_M.Merec_2 /= "  " then
  4471.         if Card_M.Merec_2 /= "# " then
  4472.           Merec_Type  := Merec_Types'value(Card_M.Merec_2);
  4473.         end if;
  4474.       end if;
  4475.       if Card_M.Merec_3 /= "  " then
  4476.         if Card_M.Merec_3 /= "# " then
  4477.           Merec_Type  := Merec_Types'value(Card_M.Merec_3);
  4478.         end if;
  4479.       end if;
  4480.     exception
  4481.       when others  => Error_Message("MEREC",Bad_Field);
  4482.     end;
  4483.     --
  4484.     --    if card is valid, place access pointer in message list and
  4485.     --    set up new access pointer for message list
  4486.     --
  4487.     if not Bad_Message then
  4488.       Valid_Msg.access_m  := Card_M;
  4489.       Link_List;
  4490.     end if;
  4491.  
  4492.   end Process_Card_M;
  4493.  
  4494.  
  4495. --**********************************************************************
  4496. --
  4497. --      This procedure does the processing for the validation of the
  4498. --    fields of a "N  " card.
  4499. --
  4500. --**********************************************************************
  4501.  
  4502.   procedure Process_Card_N is
  4503.  
  4504.   begin
  4505.     --
  4506.     --    set up new access pointer for card N
  4507.     --
  4508.     Card_N := new Card_Type_N;
  4509.     --
  4510.     --    place strings in field components
  4511.     --
  4512.     Card_N.Pin          := Input_Msg.card(15..19);
  4513.     Card_N.Frqno        := Input_Msg.card(20..24);
  4514.     Card_N.Pleac        := Input_Msg.card(25..25);
  4515.     Card_N.Ddp          := Input_Msg.card(26..27);
  4516.     Card_N.Ddprd.YY     := Input_Msg.card(28..29);
  4517.     Card_N.Ddprd.MM     := Input_Msg.card(30..31);
  4518.     Card_N.Ddprd.DD     := Input_Msg.card(32..33);
  4519.     Card_N.Ddprd.HH     := Input_Msg.card(34..35);
  4520.     Card_N.Mdt.DDD      := Input_Msg.card(36..38);
  4521.     Card_N.Mdt.HH       := Input_Msg.card(39..40);
  4522.     Card_N.Putc         := Input_Msg.card(41..45);
  4523.     --
  4524.     --    PIN is required to be reported
  4525.     --
  4526.     if Card_N.Pin = "     " then
  4527.       Error_Message("PIN  ",Field_Required);
  4528.     else
  4529.       Validate_Pin(Card_N.Pin,"PIN  ");
  4530.     end if;
  4531.     --
  4532.     begin
  4533.       if Card_N.Pleac /= " " then
  4534.         Pleac_Type    := Pleac_Types'value(Card_N.Pleac);
  4535.       end if;
  4536.     exception
  4537.       when others  => Error_Message("PLEAC",Bad_Field);
  4538.     end;
  4539.     --
  4540.     begin
  4541.       if Card_N.Ddp /= "  " then
  4542.         if Card_N.Ddprd.YY &
  4543.            Card_N.Ddprd.MM & Card_N.Ddprd.DD = "      " then
  4544.           Error_Message("DDPRD",Field_Required);
  4545.         end if;
  4546.         if Card_N.Mdt.DDD & Card_N.Mdt.HH = "     " then
  4547.           Error_Message("MDT  ",Field_Required);
  4548.         end if;
  4549.         Ddp_Type      := Ddp_Types'value(Card_N.Ddp);
  4550.       end if;
  4551.     exception
  4552.       when others  => Error_Message("DDP  ",Bad_Field);
  4553.     end;
  4554.     --
  4555.     if Card_N.Ddprd.YY /= "  " or
  4556.        Card_N.Ddprd.MM /= "  " or
  4557.        Card_N.Ddprd.DD /= "  " or
  4558.        Card_N.Ddprd.HH /= "  " then
  4559.       if Card_N.Ddp = "  " then
  4560.         Error_Message("DDP  ",Field_Required);
  4561.       end if;
  4562.       if Card_N.Mdt.DDD & Card_N.Mdt.HH = "     " then
  4563.         Error_Message("MDT  ",Field_Required);
  4564.       end if;
  4565.       if Card_N.Ddprd.YY &
  4566.          Card_N.Ddprd.MM & Card_N.Ddprd.DD = "      " then
  4567.         Error_Message("DDPRD",Bad_Field);
  4568.       else
  4569.         Validate_YYMMDD(Card_N.Ddprd.YY,
  4570.                         Card_N.Ddprd.MM,
  4571.                         Card_N.Ddprd.DD,
  4572.                         "DDPRD");
  4573.         Valid_Value := string_to_integer(Card_N.Ddprd.HH);
  4574.         if Valid_Value not in 0..23 then
  4575.           Error_Message("DDPRD",Bad_Field);
  4576.         end if;
  4577.       end if;
  4578.     end if;
  4579.     --
  4580.     if Card_N.Mdt.DDD /= "   " or
  4581.        Card_N.Mdt.HH /= "  " then
  4582.       if Card_N.Ddprd.YY &
  4583.          Card_N.Ddprd.MM & Card_N.Ddprd.DD = "      " then
  4584.         Error_Message("DDPRD",Field_Required);
  4585.       end if;
  4586.       if Card_N.Ddp = "  " then
  4587.         Error_Message("DDP  ",Field_Required);
  4588.       end if;
  4589.       Validate_Numeric(Card_N.Mdt.DDD,"MDT  ");
  4590.       Valid_Value := string_to_integer(Card_N.Mdt.HH);
  4591.       if Valid_Value not in 0..23 then
  4592.         Error_Message("MDT  ",Bad_Field);
  4593.       end if;
  4594.     end if;
  4595.     --
  4596.     --    if PUTCV is reported it will be validated against an IDM
  4597.     --    database relation Utc database.
  4598.     --
  4599.     if Card_N.Putc = "#    " and Valid_Msg.Trtype /= CHANGE then
  4600.       Error_Message("PUTCV",Bad_Field);
  4601.     end if;
  4602.     --
  4603.     --    if card is valid, place access pointer in message list and
  4604.     --    set up new access pointer for message list
  4605.     --
  4606.     if not Bad_Message then
  4607.       Valid_Msg.access_n  := Card_N;
  4608.       Link_List;
  4609.     end if;
  4610.  
  4611.   end Process_Card_N;
  4612.  
  4613.  
  4614. --**********************************************************************
  4615. --
  4616. --      This procedure does the processing for the validation of the
  4617. --    fields of a "P  " card.
  4618. --
  4619. --**********************************************************************
  4620.  
  4621.   procedure Process_Card_P is
  4622.  
  4623.   begin
  4624.     --
  4625.     --    set up new access pointer for card P
  4626.     --
  4627.     Card_P := new Card_Type_P;
  4628.     --
  4629.     --    validate and convert ALTYP
  4630.     --
  4631.     begin
  4632.       Working_String       := "          ";
  4633.       Working_String(1..2) := Input_Msg.card(39..40);
  4634.       Card_P.Altyp         := Altyp_Types'value(Working_String);
  4635.     exception
  4636.       when others  => Error_Message("ALTYP",Bad_Field);
  4637.     end;
  4638.     --
  4639.     --    place strings in field components
  4640.     --
  4641.     Card_P.Pin          := Input_Msg.card(15..19);
  4642.     Card_P.Meqpt        := Input_Msg.card(20..32);
  4643.     Card_P.Tpgeo        := Input_Msg.card(33..38);
  4644.     Card_P.Numbr        := Input_Msg.card(41..43);
  4645.     Card_P.Numea        := Input_Msg.card(44..46);
  4646.     Card_P.Alret.HHH    := Input_Msg.card(47..49);
  4647.     Card_P.Alret.MM     := Input_Msg.card(50..51);
  4648.     --
  4649.     --    PIN is required to be reported
  4650.     --
  4651.     if Card_P.Pin = "     " then
  4652.       Error_Message("PIN  ",Field_Required);
  4653.     else
  4654.       Validate_Pin(Card_P.Pin,"PIN  ");
  4655.     end if;
  4656.     --
  4657.     --    MEQPT is required to be reported
  4658.     --
  4659.     if Card_P.Meqpt = "             " then
  4660.       Error_Message("MEQPT",Field_Required);
  4661.     else
  4662.       Validate_Meqpt(Card_P.Meqpt,"MEQPT");
  4663.     end if;
  4664.     --
  4665.     --    if TPGEO is reported it will be validated against an IDM
  4666.     --    database relation, either the Geoloc or UIC.
  4667.     --
  4668.     if Card_P.Tpgeo /= "      " then
  4669.       if Invalid_Uic(Card_P.Tpgeo) and
  4670.          Invalid_Geo(Card_P.Tpgeo) then
  4671.         Error_Message("TPGEO",Bad_Field);
  4672.       end if;
  4673.     end if;
  4674.     --
  4675.     Validate_Numeric(Card_P.Numbr,"NUMBR");
  4676.     Validate_Numeric(Card_P.Numea,"NUMEA");
  4677.     --
  4678.     if Card_P.Alret.HHH & Card_P.Alret.MM /= "     " then
  4679.       Validate_Numeric(Card_P.Alret.HHH,"ALRET");
  4680.       Valid_Value := string_to_integer(Card_P.Alret.MM);
  4681.       if Valid_Value not in 0..59 then
  4682.         Error_Message("ALRET",Bad_Field);
  4683.       end if;
  4684.     end if;
  4685.     --
  4686.     --    if card is valid, place access pointer in message list and
  4687.     --    set up new access pointer for message list
  4688.     --
  4689.     if not Bad_Message then
  4690.       Valid_Msg.access_p  := Card_P;
  4691.       Link_List;
  4692.     end if;
  4693.  
  4694.   end Process_Card_P;
  4695.  
  4696.  
  4697. --**********************************************************************
  4698. --
  4699. --      This procedure does the processing for the validation of the
  4700. --    fields of a "Q  " card.
  4701. --
  4702. --**********************************************************************
  4703.  
  4704.   procedure Process_Card_Q is
  4705.     Working_Nuseq : string(1..1);
  4706.     Working_Wpnco : string(1..2);
  4707.     Working_Rfdgs : string(1..1);
  4708.   begin
  4709.     --
  4710.     --    set up new access pointer for card Q
  4711.     --
  4712.     Card_Q := new Card_Type_Q;
  4713.     --
  4714.     --    place strings in field components
  4715.     --
  4716.     Card_Q.Pin          := Input_Msg.card(15..19);
  4717.     Card_Q.Nuseq        := Input_Msg.card(20..22);
  4718.     Card_Q.Wpnco        := Input_Msg.card(23..29);
  4719.     Card_Q.Nuqpt        := Input_Msg.card(30..39);
  4720.     Card_Q.Dsgeo        := Input_Msg.card(40..45);
  4721.     Card_Q.Altyp        := Input_Msg.card(46..47);
  4722.     Card_Q.Numwr        := Input_Msg.card(48..49);
  4723.     Card_Q.Numwb        := Input_Msg.card(50..51);
  4724.     Card_Q.Nugun        := Input_Msg.card(52..53);
  4725.     Card_Q.Rtime        := Input_Msg.card(54..58);
  4726.     Card_Q.Dssta        := Input_Msg.card(59..59);
  4727.     Card_Q.Rfdgs        := Input_Msg.card(60..64);
  4728.     Card_Q.Nusto        := Input_Msg.card(65..67);
  4729.     Card_Q.Nuecc        := Input_Msg.card(68..69);
  4730.     --
  4731.     --    PIN and ALTYP are mutually inclusive
  4732.     --
  4733.     begin
  4734.       if Card_Q.Pin /= "     " and Card_Q.Altyp =  "  " then
  4735.         Error_Message("ALTYP",Field_Required);
  4736.       elsif Card_Q.Pin  = "     " and Card_Q.Altyp /= "  " then
  4737.         Error_Message("PIN  ",Field_Required);
  4738.       else
  4739.         if Card_Q.Pin /= "     " then
  4740.           Validate_Pin(Card_Q.Pin,"PIN  ");
  4741.         end if;
  4742.         if Card_Q.Altyp /= "  " then
  4743.           if Valid_Msg.Trtype = CHANGE and Card_Q.Altyp = "# " then
  4744.             null;
  4745.           else
  4746.             Altyp_Type := Altyp_Types'value(Card_Q.Altyp);
  4747.           end if;
  4748.         end if;
  4749.       end if;
  4750.     exception
  4751.       when others  => Error_Message("ALTYP",Field_Required);
  4752.     end;
  4753.     --
  4754.     --    NUSEQ is required to be reported and must be all numeric or
  4755.     --    1st character alphabetic + 2 numeric.  "ALL" is ok when
  4756.     --    tansaction is Change or Delete.
  4757.     --
  4758.     begin
  4759.       if Card_Q.Nuseq = "   " then
  4760.         Error_Message("NUSEQ",Field_Required);
  4761.       elsif (Valid_Msg.Trtype = ADD or
  4762.              Valid_Msg.Trtype = REPLACE) and
  4763.              Card_Q.Nuseq /= "ALL" then
  4764.         Valid_Value := string_to_integer(Card_Q.Nuseq);
  4765.         if Valid_Value < 0 then
  4766.           Working_Nuseq := Card_Q.Nuseq(1..1);
  4767.           Alphabetic_Type := Alphabetic_Types'value(Working_Nuseq);
  4768.           Valid_Value := string_to_integer(Card_Q.Nuseq(2..3));
  4769.           if Valid_Value < 0 then
  4770.             Error_Message("NUSEQ",Bad_Field);
  4771.           end if;
  4772.         end if;
  4773.       end if;
  4774.     exception
  4775.       when others  => Error_Message("NUSEQ",Bad_Field);
  4776.     end;
  4777.     --
  4778.     --    if WPNCO is reported, not validated if NUSEQ = "ALL". if 1-6
  4779.     --    characters, up to 3 groups of 2-character codes from the set
  4780.     --    (CO, EL, IR, PH, RA, SG, SL, VI)  if 7 characters, perform
  4781.     --    lookup of valid codes in NUREP relation.
  4782.     --
  4783.     begin
  4784.       if Card_Q.Nuseq = "ALL" then
  4785.         null;
  4786.       elsif Card_Q.Wpnco(7) /= ' ' then
  4787.     --    find WPNCO is NUREP database
  4788.         idm_command(idmrun,"return_wpnco $1");
  4789.         idm_param(idmrun,"$1",Card_Q.Wpnco,idm_char);
  4790.         idm_execute(idmrun);
  4791.         idm_fetch(idmrun);
  4792.         idm_column(idmrun,1,Card_Q.Wpnco,Length_of_String);
  4793.       else
  4794.         if Card_Q.Wpnco /= "       " then
  4795.           Working_Wpnco := Card_Q.Wpnco(1..2);
  4796.           Wpnco_Type    := Wpnco_Types'value(Working_Wpnco);
  4797.           Working_Wpnco := Card_Q.Wpnco(3..4);
  4798.           Wpnco_Type    := Wpnco_Types'value(Working_Wpnco);
  4799.           Working_Wpnco := Card_Q.Wpnco(5..6);
  4800.           Wpnco_Type    := Wpnco_Types'value(Working_Wpnco);
  4801.         end if;
  4802.       end if;
  4803.     exception
  4804.       when others  => Error_Message("WPNCO",Bad_Field);
  4805.     end;
  4806.     --
  4807.     --    NUQPT if reported can be "SHIP      " or a code in the MEQPT
  4808.     --    database or Reconn code.  Required to be reported when
  4809.     --    transaction is Add.
  4810.     --
  4811.     if Card_Q.Nuqpt /= "          " then
  4812.       if Card_Q.Nuqpt(3..10) = "        " then
  4813.         begin
  4814.           Reconn_Type    := Reconn_Types'value(Card_Q.Nuqpt);
  4815.         exception
  4816.           when others  => Error_Message("NUQPT",Bad_Field);
  4817.         end;
  4818.       end if;
  4819.       if Card_Q.Nuqpt /= "SHIP      " then
  4820.         Validate_Meqpt(Card_Q.Nuqpt,"NUQPT");
  4821.       end if;
  4822.     elsif Valid_Msg.Trtype = ADD then
  4823.       Error_Message("NUQPT",Field_Required);
  4824.     end if;
  4825.     --
  4826.     if Valid_Msg.Trtype = CHANGE and Card_Q.Numwr /= "# " then
  4827.       Validate_Numeric(Card_Q.Numwr,"NUMWR");
  4828.     end if;
  4829.     --
  4830.     --    NUMWB and NUSTO are mutually inclusive
  4831.     --
  4832.     if Card_Q.Numwb /= "  " and Card_Q.Nusto  = "   " then
  4833.       Error_Message("NUSTO",Field_Required);
  4834.     elsif Card_Q.Numwb  = "  " and Card_Q.Nusto /= "   " then
  4835.       Error_Message("NUMWB",Field_Required);
  4836.     elsif Valid_Msg.Trtype = CHANGE and
  4837.           Card_Q.Numwb = "# " and Card_Q.Nusto /= "#  " then
  4838.       Error_Message("NUSTO",Bad_Field);
  4839.     elsif Valid_Msg.Trtype = CHANGE and
  4840.           Card_Q.Numwb /= "# " and Card_Q.Nusto = "#  " then
  4841.       Error_Message("NUMWB",Bad_Field);
  4842.     elsif Valid_Msg.Trtype /= CHANGE AND
  4843.           CARD_Q.Numwb /= "# " and Card_Q.Nusto /= "#  " then
  4844.       Validate_Numeric(Card_Q.Numwb,"NUMWB");
  4845.     end if;
  4846.     --
  4847.     if Valid_Msg.Trtype = CHANGE and Card_Q.Nugun /= "# " then
  4848.       Validate_Numeric(Card_Q.Nugun,"NUGUN");
  4849.     end if;
  4850.     --
  4851.     if Valid_Msg.Trtype /= CHANGE and Card_Q.Dssta = "#" then
  4852.       Error_Message("DSSTA",Bad_Field);
  4853.     end if;
  4854.     --
  4855.     --    if RTIME is reported, it must be all numeric
  4856.     --
  4857.     --    (NOTE: the following DSSTA codes are "degraded": D, N, E, 0)
  4858.     --
  4859.     --    if the delivery system is meeting its committment (i.e., not
  4860.     --    degraded), the RTIME field will indicate a reaction time in
  4861.     --    the format HHHMM, where HHH is in the range 000-240 and MM is
  4862.     --    in the range 00-59.  if "XXXXX" is entered in the RTIME field,
  4863.     --    store "NULL" in the database.
  4864.     --
  4865.     --    if the delivery system is not meeting its committment (i.e., is
  4866.     --    degraded), then
  4867.     --        for Air Force units
  4868.     --          this field will show julian day and hour in the format
  4869.     --          DDDHH, where DDD is in the range 000-366 and HH is in
  4870.     --          the range 00-23
  4871.     --
  4872.     --        for Army and Marine Corp units,
  4873.     --          this field will show julian date in the format DDDYY.
  4874.     --
  4875.     --        for Navy units, not applicable
  4876.     --
  4877.     --    the service (AirForce, Army, or Marines) is determined by
  4878.     --    looking at the first character of the UIC in the common data
  4879.     --    fields
  4880.     --
  4881.     if Card_Q.Rtime /= "     " then
  4882.       if Valid_Msg.Trtype = CHANGE and Card_Q.Rtime = "#     " then
  4883.         null;
  4884.       elsif Card_Q.Dssta = "D" or Card_Q.Dssta = "N" or
  4885.             Card_Q.Dssta = "E" or Card_Q.Dssta = "0" then
  4886.         if Valid_Msg.Uic(1) = 'F' then
  4887.           Valid_Value := string_to_integer(Card_Q.Rtime(1..3));
  4888.           if Valid_Value not in 0..366 then
  4889.             Error_Message("RTIME",Bad_Field);
  4890.           else
  4891.             Valid_Value := string_to_integer(Card_Q.Rtime(4..5));
  4892.             if Valid_Value not in 0..23 then
  4893.               Error_Message("RTIME",Bad_Field);
  4894.             end if;
  4895.           end if;
  4896.         elsif Valid_Msg.Uic(1) = 'W' or Valid_Msg.Uic(1) = 'M' then
  4897.           Validate_DDDYY(Card_Q.Rtime(1..3),
  4898.                          Card_Q.Rtime(4..5),
  4899.                          "RTIME");
  4900.         else
  4901.           Error_Message("RTIME",Bad_Field);
  4902.         end if;
  4903.       elsif Card_Q.Rtime /= "XXXXX" then
  4904.         Valid_Value := string_to_integer(Card_Q.Rtime(1..3));
  4905.         if Valid_Value not in 0..240 then
  4906.           Error_Message("RTIME",Bad_Field);
  4907.         else
  4908.           Valid_Value := string_to_integer(Card_Q.Rtime(4..5));
  4909.           if Valid_Value not in 0..59 then
  4910.             Error_Message("RTIME",Bad_Field);
  4911.           end if;
  4912.         end if;
  4913.       end if;
  4914.     elsif Card_Q.Dssta = "D" or Card_Q.Dssta = "N" or
  4915.           Card_Q.Dssta = "E" or Card_Q.Dssta = "0" then
  4916.       Error_Message("RTIME",Field_Required);
  4917.     end if;
  4918.     --
  4919.     --    RFDGS is required when DSSTA is "D", "N", "E" or "0" (zero) or
  4920.     --    when RTIME is "XXXXX".  1 character code (A..Z), up to five
  4921.     --    codes per field, no repeated codes allowed
  4922.     --
  4923.     begin
  4924.       if Card_Q.Rfdgs /= "     " then
  4925.         if Valid_Msg.Trtype = CHANGE and Card_Q.Rfdgs = "#    " then
  4926.           null;
  4927.         else
  4928.           Working_Rfdgs := Card_Q.Rfdgs(1..1);
  4929.           Alphabetic_Type := Alphabetic_Types'value(Working_Rfdgs);
  4930.           if Card_Q.Rfdgs(1..1) = Card_Q.Rfdgs(2..2) then
  4931.             Error_Message("RFDGS",Bad_Field);
  4932.           elsif Card_Q.Rfdgs(2..5) /= "    " then
  4933.             Working_Rfdgs := Card_Q.Rfdgs(2..2);
  4934.             Alphabetic_Type := Alphabetic_Types'value(Working_Rfdgs);
  4935.             if Card_Q.Rfdgs(1..1) = Card_Q.Rfdgs(3..3) or
  4936.                Card_Q.Rfdgs(2..2) = Card_Q.Rfdgs(3..3) then
  4937.               Error_Message("RFDGS",Bad_Field);
  4938.             elsif Card_Q.Rfdgs(3..5) /= "   " then
  4939.               Working_Rfdgs := Card_Q.Rfdgs(3..3);
  4940.               Alphabetic_Type := Alphabetic_Types'value(Working_Rfdgs);
  4941.               if Card_Q.Rfdgs(1..1) = Card_Q.Rfdgs(4..4) or
  4942.                  Card_Q.Rfdgs(2..2) = Card_Q.Rfdgs(4..4) or
  4943.                  Card_Q.Rfdgs(3..3) = Card_Q.Rfdgs(4..4) then
  4944.                 Error_Message("RFDGS",Bad_Field);
  4945.               elsif Card_Q.Rfdgs(4..5) /= "  " then
  4946.                 Working_Rfdgs := Card_Q.Rfdgs(4..4);
  4947.                Alphabetic_Type := Alphabetic_Types'value(Working_Rfdgs);
  4948.                 if Card_Q.Rfdgs(1..1) = Card_Q.Rfdgs(5..5) or
  4949.                    Card_Q.Rfdgs(2..2) = Card_Q.Rfdgs(5..5) or
  4950.                    Card_Q.Rfdgs(3..3) = Card_Q.Rfdgs(5..5) or
  4951.                    Card_Q.Rfdgs(4..4) = Card_Q.Rfdgs(5..5) then
  4952.                   Error_Message("RFDGS",Bad_Field);
  4953.                 elsif Card_Q.Rfdgs(5..5) /= " " then
  4954.                   Working_Rfdgs := Card_Q.Rfdgs(5..5);
  4955.                   Alphabetic_Type :=
  4956.                        Alphabetic_Types'value(Working_Rfdgs);
  4957.                 end if;
  4958.               end if;
  4959.             end if;
  4960.           end if;
  4961.         end if;
  4962.       elsif Card_Q.Dssta = "D" or Card_Q.Dssta = "N" or
  4963.             Card_Q.Dssta = "E" or Card_Q.Dssta = "0" or
  4964.             Card_Q.Rtime = "XXXXX" then
  4965.         Error_Message("RFDGS",Field_Required);
  4966.       end if;
  4967.     exception
  4968.       when others  => Error_Message("RFDGS",Bad_Field);
  4969.     end;
  4970.     --
  4971.     --    if NUECC is reported, it must be numeric range 00-60. if
  4972.     --    transaction is Change then it can be "# "
  4973.     --
  4974.     if Card_Q.Nuecc /= "  " then
  4975.       if Valid_Msg.Trtype = CHANGE and Card_Q.Nuecc = "# " then
  4976.         null;
  4977.       else
  4978.         Valid_Value := string_to_integer(Card_Q.Nuecc);
  4979.         if Valid_Value not in 0..60 then
  4980.           Error_Message("NUECC",Bad_Field);
  4981.         end if;
  4982.       end if;
  4983.     end if;
  4984.     --
  4985.     --    if card is valid, place access pointer in message list and
  4986.     --    set up new access pointer for message list;
  4987.     --
  4988.     if not Bad_Message then
  4989.       Valid_Msg.access_q  := Card_Q;
  4990.       Link_List;
  4991.     end if;
  4992.  
  4993.   end Process_Card_Q;
  4994.  
  4995.  
  4996. --**********************************************************************
  4997. --
  4998. --      This procedure does the processing for the validation of the
  4999. --    fields of a "T  " card.
  5000. --
  5001. --**********************************************************************
  5002.  
  5003.   procedure Process_Card_T is
  5004.  
  5005.   begin
  5006.     --
  5007.     --    set up new access pointer for card T
  5008.     --
  5009.     Card_T := new Card_Type_T;
  5010.     --
  5011.     --    place strings in field components
  5012.     --
  5013.     Card_T.Teqpt        := Input_Msg.card(15..25);
  5014.     Card_T.Mesen        := Input_Msg.card(26..29);
  5015.     Card_T.Decon        := Input_Msg.card(30..30);
  5016.     Card_T.Mecus        := Input_Msg.card(31..32);
  5017.     Card_T.Avcat        := Input_Msg.card(33..33);
  5018.     Card_T.Resnd        := Input_Msg.card(34..34);
  5019.     Card_T.Erdte.YY     := Input_Msg.card(35..36);
  5020.     Card_T.Erdte.MM     := Input_Msg.card(37..38);
  5021.     Card_T.Erdte.DD     := Input_Msg.card(39..40);
  5022.     Card_T.Exdac        := Input_Msg.card(41..41);
  5023.     Card_T.Cpgeo        := Input_Msg.card(42..45);
  5024.     Card_T.Cfgeo        := Input_Msg.card(46..49);
  5025.     Card_T.Eqdep.YY     := Input_Msg.card(50..51);
  5026.     Card_T.Eqdep.MM     := Input_Msg.card(52..53);
  5027.     Card_T.Eqdep.DD     := Input_Msg.card(54..55);
  5028.     Card_T.Eqarr.YY     := Input_Msg.card(56..57);
  5029.     Card_T.Eqarr.MM     := Input_Msg.card(58..59);
  5030.     Card_T.Eqarr.DD     := Input_Msg.card(60..61);
  5031.     Card_T.Pin          := Input_Msg.card(62..66);
  5032.     Card_T.Tleac        := Input_Msg.card(67..67);
  5033.     Card_T.Tleqe        := Input_Msg.card(68..69);
  5034.     --
  5035.     --    TEQPT is required to be reported and will be validated an
  5036.     --    IDM database relation MEQPT.
  5037.     --
  5038.     if Card_T.Teqpt = "           " then
  5039.       Error_Message("TEQPT",Field_Required);
  5040.     else
  5041.       Validate_Meqpt(Card_T.Teqpt,"TEQPT");
  5042.     end if;
  5043.     --
  5044.     --    MESEN is requried to be reported
  5045.     --
  5046.     if Card_T.Mesen = "    " then
  5047.       Error_Message("MESEN",Field_Required);
  5048.     end if;
  5049.     --
  5050.     --    if DECON is reported must be 1-9 or C D A N F M E J
  5051.     --
  5052.     begin
  5053.       if Card_T.Decon /= " " then
  5054.         Valid_Value   := string_to_integer(Card_T.Decon);
  5055.         if Valid_Value < 1 then
  5056.           Cserv_Type  := Cserv_Types'value(Card_T.Decon);
  5057.         elsif Valid_Value > 9 then
  5058.           raise constraint_error;
  5059.         end if;
  5060.       end if;
  5061.     exception
  5062.       when others  => Error_Message("DECON",Bad_Field);
  5063.     end;
  5064.     --
  5065.     begin
  5066.       if Card_T.Mecus /= "  " then
  5067.         Mecus_Type    := Mecus_Types'value(Card_T.Mecus);
  5068.       end if;
  5069.     exception
  5070.       when others  => Error_Message("MECUS",Bad_Field);
  5071.     end;
  5072.     --
  5073.     --    validate AVCAT and RESND.  RESND is reported only when AVCAT is
  5074.     --    reported and has a value of "D".  EXDAC and ERDTE are required
  5075.     --    to be reported when AVCAT has a value of "D".
  5076.     --
  5077.     begin
  5078.       begin
  5079.         if Card_T.Avcat /= " " then
  5080.           Avcat_Type    := Avcat_Types'value(Card_T.Avcat);
  5081.         end if;
  5082.       exception
  5083.         when others  => Error_Message("AVCAT",Bad_Field);
  5084.       end;
  5085.       if Avcat_Type = D then
  5086.         if Card_T.Erdte.YY &
  5087.            Card_T.Erdte.MM & Card_T.Erdte.DD = "      " then
  5088.           Error_Message("ERDTE",Field_Required);
  5089.         end if;
  5090.         if Card_T.Exdac = " " then
  5091.           Error_Message("EXDAC",Field_Required);
  5092.         end if;
  5093.         Resnd_Type    := Resnd_Types'value(Card_T.Resnd);
  5094.       elsif Card_T.Resnd /= " " then
  5095.         raise constraint_error;
  5096.       end if;
  5097.     exception
  5098.       when others  => Error_Message("RESND",Bad_Field);
  5099.     end;
  5100.     --
  5101.     Validate_YYMMDD(Card_T.Erdte.YY,
  5102.                     Card_T.Erdte.MM,
  5103.                     Card_T.Erdte.DD,
  5104.                     "ERDTE");
  5105.     --
  5106.     begin
  5107.       if Card_T.Exdac /= " " then
  5108.         Avcat_Type    := Avcat_Types'value(Card_T.Exdac);
  5109.       end if;
  5110.     exception
  5111.       when others  => Error_Message("EXDAC",Bad_Field);
  5112.     end;
  5113.     --
  5114.     --    if CPGEO is reported it will be validated against an IDM
  5115.     --    database relation Geoloc.
  5116.     --
  5117.     if Card_T.Cpgeo = "#   " and Valid_Msg.Trtype = CHANGE then
  5118.       null;
  5119.     elsif Card_T.Cpgeo /= "    " then
  5120.       Validate_Geolocation(Card_T.Cpgeo,"CPGEO");
  5121.     end if;
  5122.     --
  5123.     --    if CFGEO is reported it will be validated against an IDM
  5124.     --    database relation Geoloc. CFGEO must not be equal to CPGEO
  5125.     --
  5126.     if Card_T.Cfgeo = "#   " and Valid_Msg.Trtype = CHANGE then
  5127.       null;
  5128.     elsif Card_T.Cpgeo /= "    " and
  5129.           Card_T.Cpgeo = Card_T.Cfgeo then
  5130.       Error_Message("CFGEO",Bad_Field);
  5131.     else
  5132.       Validate_Geolocation(Card_T.Cfgeo,"CFGEO");
  5133.     end if;
  5134.     --
  5135.     if Card_T.Eqdep.YY & Card_T.Eqdep.MM & Card_T.Eqdep.DD = "#     " and
  5136.        Valid_Msg.Trtype = CHANGE then
  5137.       null;
  5138.     else
  5139.       Validate_YYMMDD(Card_T.Eqdep.YY,
  5140.                       Card_T.Eqdep.MM,
  5141.                       Card_T.Eqdep.DD,
  5142.                       "EQDEP");
  5143.     end if;
  5144.     --
  5145.     if Card_T.Eqarr.YY &
  5146.        Card_T.Eqarr.MM & Card_T.Eqarr.DD = "#     " and
  5147.        Valid_Msg.Trtype = CHANGE then
  5148.       null;
  5149.     else
  5150.       Validate_YYMMDD(Card_T.Eqarr.YY,
  5151.                       Card_T.Eqarr.MM,
  5152.                       Card_T.Eqarr.DD,
  5153.                       "EQARR");
  5154.       if Card_T.Eqarr.YY &
  5155.          Card_T.Eqarr.MM &
  5156.          Card_T.Eqarr.DD <
  5157.          Card_T.Eqdep.YY &
  5158.          Card_T.Eqdep.MM &
  5159.          Card_T.Eqdep.DD then
  5160.         Error_Message("EQARR",Bad_Field);
  5161.       end if;
  5162.     end if;
  5163.     --
  5164.     if Card_T.Pin = "#    " and Valid_Msg.Trtype = CHANGE then
  5165.       null;
  5166.     elsif Card_T.Pin /= "     " then
  5167.       Validate_Pin(Card_T.Pin,"TPIN ");
  5168.     end if;
  5169.     --
  5170.     begin
  5171.       if Card_T.Tleac /= " " then
  5172.         if Card_T.Tleac = "#" and Valid_Msg.Trtype = CHANGE then
  5173.           null;
  5174.         else
  5175.           Pleac_Type    := Pleac_Types'value(Card_T.Tleac);
  5176.         end if;
  5177.       end if;
  5178.     exception
  5179.       when others  => Error_Message("TLEAC",Bad_Field);
  5180.     end;
  5181.     --
  5182.     if Card_T.Tleqe = "# " and Valid_Msg.Trtype = CHANGE then
  5183.       null;
  5184.     else
  5185.       Validate_Numeric(Card_T.Tleqe,"TLEQE");
  5186.     end if;
  5187.     --
  5188.     --    if card is valid, place access pointer in message list and
  5189.     --    set up new access pointer for message list
  5190.     --
  5191.     if not Bad_Message then
  5192.       Valid_Msg.access_t  := Card_T;
  5193.       Link_List;
  5194.     end if;
  5195.  
  5196.   end Process_Card_T;
  5197.  
  5198.  
  5199. --**********************************************************************
  5200. --
  5201. --      This procedure does the processing for the validation of the
  5202. --    fields of a "V  " card.
  5203. --
  5204. --**********************************************************************
  5205.  
  5206.   procedure Process_Card_V is
  5207.     Working_Mdate : string(1..3);
  5208.   begin
  5209.     --
  5210.     --    set up new access pointer for card V
  5211.     --
  5212.     Card_V := new Card_Type_V;
  5213.     --
  5214.     --    place strings in field components
  5215.     --
  5216.     Card_V.Acgeo        := Input_Msg.card(15..18);
  5217.     Card_V.Acity        := Input_Msg.card(19..20);
  5218.     Card_V.Adate.YY     := Input_Msg.card(21..22);
  5219.     Card_V.Adate.MM     := Input_Msg.card(23..24);
  5220.     Card_V.Adate.DD     := Input_Msg.card(25..26);
  5221.     Card_V.Mdate        := Input_Msg.card(27..30);
  5222.     Card_V.Rdate.YY     := Input_Msg.card(31..32);
  5223.     Card_V.Rdate.MM     := Input_Msg.card(33..34);
  5224.     Card_V.Rdate.DD     := Input_Msg.card(35..36);
  5225.     --
  5226.     --    if ACGEO is reported it will be validated against an IDM
  5227.     --    database relation Geoloc.
  5228.     --
  5229.     Validate_Geolocation(Card_V.Acgeo,"ACGEO");
  5230.     --
  5231.     begin
  5232.       if Card_V.Acity /= "  " then
  5233.         if Card_V.Acity /= "IN" then
  5234.           Activ_Type  := Activ_Types'value(Card_V.Acity);
  5235.         end if;
  5236.       end if;
  5237.     exception
  5238.       when others  => Error_Message("ACTIV",Bad_Field);
  5239.     end;
  5240.     --
  5241.     if Card_V.Adate.YY &
  5242.        Card_V.Adate.MM & Card_V.Adate.DD = "#     " and
  5243.        Valid_Msg.Trtype = CHANGE then
  5244.       null;
  5245.     else
  5246.       Validate_YYMMDD(Card_V.Adate.YY,
  5247.                       Card_V.Adate.MM,
  5248.                       Card_V.Adate.DD,
  5249.                       "ADATE");
  5250.     end if;
  5251.     --
  5252.     --    if MDATE is reported, the first character must be "A" or "B",
  5253.     --    and the last 3 characters must be numeric, 001-999.
  5254.     --
  5255.     if Card_V.Mdate /= "    " then
  5256.       if Card_V.Mdate(1..1) = "A" or Card_V.Mdate(1..1) = "B" then
  5257.         Working_Mdate := Card_V.Mdate(2..4);
  5258.         Validate_Numeric(Working_Mdate,"MDATE");
  5259.       else
  5260.         Error_Message("MDATE",Bad_Field);
  5261.       end if;
  5262.     end if;
  5263.     --
  5264.     --    if RDATE is reported it must be a valid date or the string
  5265.     --  "9     ".  the string "9     " means that RDATE is undetermined
  5266.     --    and therefore NULL.
  5267.     --
  5268.     if Card_V.Rdate.YY &
  5269.        Card_V.Rdate.MM & Card_V.Rdate.DD /= "9     " then
  5270.       if Card_V.Rdate.YY &
  5271.          Card_V.Rdate.MM & Card_V.Rdate.DD = "#     " and
  5272.          Valid_Msg.Trtype = CHANGE then
  5273.         null;
  5274.       else
  5275.         Validate_YYMMDD(Card_V.Rdate.YY,
  5276.                         Card_V.Rdate.MM,
  5277.                         Card_V.Rdate.DD,
  5278.                         "RDATE");
  5279.       end if;
  5280.     end if;
  5281.     --
  5282.     --    ADATE and RDATE are mutually inclusive
  5283.     --
  5284.     if Card_V.Rdate.YY &
  5285.        Card_V.Rdate.MM & Card_V.Rdate.DD  = "      " and
  5286.        Card_V.Adate.YY &
  5287.        Card_V.Adate.MM & Card_V.Adate.DD /= "      " then
  5288.       Error_Message("RDATE",Field_Required);
  5289.     elsif Card_V.Rdate.YY &
  5290.           Card_V.Rdate.MM & Card_V.Rdate.DD /= "      " and
  5291.           Card_V.Adate.YY &
  5292.           Card_V.Adate.MM & Card_V.Adate.DD  = "      " then
  5293.       Error_Message("ADATE",Field_Required);
  5294.     end if;
  5295.     --
  5296.     --    if card is valid, place acces pointer in messsage list and
  5297.     --    set up new access pointer in message list
  5298.     --
  5299.     if not Bad_Message then
  5300.       Valid_Msg.access_v  := Card_V;
  5301.       Link_List;
  5302.     end if;
  5303.  
  5304.   end Process_Card_V;
  5305.  
  5306.  
  5307. --**********************************************************************
  5308. --
  5309. --      This procedure does the processing for the validation of the
  5310. --    fields of a "X  " card.
  5311. --
  5312. --**********************************************************************
  5313.  
  5314.   procedure Process_Card_X is
  5315.  
  5316.   begin
  5317.     --
  5318.     --    set up new access pointer for card X
  5319.     --
  5320.     Card_X := new Card_Type_X;
  5321.     --
  5322.     --    place strings in field components
  5323.     --
  5324.     Card_X.Gcmd         := Input_Msg.card(15..20);
  5325.     Card_X.Tdate.YY     := Input_Msg.card(21..22);
  5326.     Card_X.Tdate.MM     := Input_Msg.card(23..24);
  5327.     Card_X.Tdate.DD     := Input_Msg.card(25..26);
  5328.     Card_X.Trgeo        := Input_Msg.card(27..30);
  5329.     Card_X.Depdt.YY     := Input_Msg.card(31..32);
  5330.     Card_X.Depdt.MM     := Input_Msg.card(33..34);
  5331.     Card_X.Depdt.DD     := Input_Msg.card(35..36);
  5332.     Card_X.Arrdt.YY     := Input_Msg.card(37..38);
  5333.     Card_X.Arrdt.MM     := Input_Msg.card(39..40);
  5334.     Card_X.Arrdt.DD     := Input_Msg.card(41..42);
  5335.     Card_X.Rptor        := Input_Msg.card(43..48);
  5336.     Card_X.Intr1        := Input_Msg.card(49..54);
  5337.     Card_X.Intr2        := Input_Msg.card(55..60);
  5338.     Card_X.Sbrpt        := Input_Msg.card(61..66);
  5339.     --
  5340.     if Valid_Msg.Trtype = DELETE  or
  5341.        Valid_Msg.Trtype = REPLACE or
  5342.        Valid_Msg.Trtype = ADD     then
  5343.       Error_Message("TRTYP",Bad_Field);
  5344.     end if;
  5345.     --
  5346.     if Card_X.Gcmd = "#     " and Valid_Msg.Trtype = CHANGE then
  5347.       null;
  5348.     else
  5349.       Validate_Oruic(Card_X.Gcmd,"GCMD ");
  5350.     end if;
  5351.     --
  5352.     Validate_YYMMDD(Card_X.Tdate.YY,
  5353.                     Card_X.Tdate.MM,
  5354.                     Card_X.Tdate.DD,
  5355.                     "TDATE");
  5356.     --
  5357.     --    if TRGEO is reported it will be validated against an IDM
  5358.     --    database relation Geoloc.
  5359.     --
  5360.     if Card_X.Trgeo = "#   " and Valid_Msg.Trtype /= CHANGE then
  5361.       Error_Message("TRGEO",Bad_Field);
  5362.     else
  5363.       Validate_Geolocation(Card_X.Trgeo,"TRGEO");
  5364.     end if;
  5365.     --
  5366.     Validate_YYMMDD(Card_X.Depdt.YY,
  5367.                     Card_X.Depdt.MM,
  5368.                     Card_X.Depdt.DD,
  5369.                     "DEPDT");
  5370.     --
  5371.     Validate_YYMMDD(Card_X.Arrdt.YY,
  5372.                     Card_X.Arrdt.MM,
  5373.                     Card_X.Arrdt.DD,
  5374.                     "ARRDT");
  5375.     --
  5376.     --    ARRDT must be >= DEPDT
  5377.     --
  5378.     if Card_X.Arrdt.YY &
  5379.        Card_X.Arrdt.MM &
  5380.        Card_X.Arrdt.DD <
  5381.        Card_X.Depdt.YY &
  5382.        Card_X.Depdt.MM &
  5383.        Card_X.Depdt.DD then
  5384.       Error_Message("DEPDT",Bad_Field);
  5385.     end if;
  5386.     --
  5387.     Validate_Oruic(Card_X.Rptor,"RPTOR");
  5388.     --
  5389.     if Card_X.Intr1 = "#     " and Valid_Msg.Trtype = CHANGE then
  5390.       null;
  5391.     else
  5392.       Validate_Oruic(Card_X.Intr1,"INTR1");
  5393.     end if;
  5394.     --
  5395.     if Card_X.Intr2 = "#     " and Valid_Msg.Trtype = CHANGE then
  5396.       null;
  5397.     else
  5398.       Validate_Oruic(Card_X.Intr2,"INTR2");
  5399.     end if;
  5400.     --
  5401.     if Card_X.Sbrpt /= "      " then
  5402.       Validate_Uic(Card_X.Sbrpt,"SBRPT");
  5403.     end if;
  5404.     --
  5405.     --    if card is valid, place access pointer in message list and
  5406.     --    set up new access pointer for message list
  5407.     --
  5408.     if not Bad_Message then
  5409.       Valid_Msg.access_x  := Card_X;
  5410.       Link_List;
  5411.     end if;
  5412.  
  5413.   end Process_Card_X;
  5414.  
  5415.  
  5416. --**********************************************************************
  5417. --
  5418. --      This procedure does the processing for the validation of the
  5419. --    fields of a "R  " and "RM3" card.
  5420. --
  5421. --**********************************************************************
  5422.  
  5423.   procedure Process_Card_R is
  5424.  
  5425.   begin
  5426.     --
  5427.     --    set up new access pointer for card R
  5428.     --
  5429.     Card_R := new Card_Type_R;
  5430.     --
  5431.     --    validate and convert sequence number
  5432.     --
  5433.     begin
  5434.       Working_String       := "          ";
  5435.       Working_String(1..1) := Input_Msg.card(15..15);
  5436.       Card_R.Seq           := String_to_Integer(Working_String(1..1));
  5437.     exception
  5438.       when others  => Error_Message("SEQ  ",Bad_Field);
  5439.     end;
  5440.     --
  5441.     --    validate and convert total number of remark cards
  5442.     --
  5443.     begin
  5444.       Working_String       := "          ";
  5445.       Working_String(1..1) := Input_Msg.card(16..16);
  5446.       Card_R.Tot           := String_to_Integer(Working_String(1..1));
  5447.     exception
  5448.       when others  => Error_Message("TOT  ",Bad_Field);
  5449.     end;
  5450.     --
  5451.     --    place strings in field components
  5452.     --
  5453.     Card_R.Label        := Input_Msg.card(17..21);
  5454.     Card_R.Rmkid        := Input_Msg.card(22..48);
  5455.     Card_R.Remrk        := Input_Msg.card(49..69);
  5456.     --
  5457.     --    if sequence number is 1 then validate the label field
  5458.     --
  5459.     begin
  5460.       if Card_R.Seq = 1 then
  5461.         Label_Type := Label_Types'value(Card_R.Label);
  5462.       end if;
  5463.     exception
  5464.       when others  => Error_Message("LABEL",Bad_Field);
  5465.     end;
  5466.     --
  5467.     --    if card is valid, place access pointer in message list and
  5468.     --    set up new access pointer for message list
  5469.     --
  5470.     if not Bad_Message then
  5471.       Valid_Msg.access_r  := Card_R;
  5472.       Link_List;
  5473.     end if;
  5474.  
  5475.   end Process_Card_R;
  5476.  
  5477.  
  5478. --**********************************************************************
  5479. --
  5480. --      This procedure does the processing for the validation of the
  5481. --    fields of a "DM1" card.
  5482. --
  5483. --**********************************************************************
  5484.  
  5485.   procedure Process_Card_DM1 is
  5486.  
  5487.   begin
  5488.     --
  5489.     --    set up new access pointer for card DM1
  5490.     --
  5491.     Card_DM1 := new Card_Type_DM1;
  5492.     --
  5493.     --    place strings in field components
  5494.     --
  5495.     Card_DM1.Billet       := Input_Msg.card(15..17);
  5496.     Card_DM1.Cornk        := Input_Msg.card(18..22);
  5497.     Card_DM1.Conam        := Input_Msg.card(23..39);
  5498.     Card_DM1.Mmcmd        := Input_Msg.card(64..69);
  5499.     --
  5500.     --    if BILLET is reported, CORNK and CONAM are required to be
  5501.     --    reported.  BILLET, CORNK and CONAM are required to be
  5502.     --    reported when transaction is Add.
  5503.     --
  5504.     if Card_DM1.Billet /= "   " then
  5505.       begin
  5506.         Bilet_Type      := Bilet_Types'value(Card_DM1.Billet);
  5507.         if Card_DM1.Cornk = "     " then
  5508.           Error_Message("CORNK",Field_Required);
  5509.         else
  5510.           begin
  5511.             Cornk_Type := Cornk_Types'value(Card_DM1.Cornk);
  5512.           exception
  5513.             when others  => Error_Message("CORNK",Bad_Field);
  5514.           end;
  5515.         end if;
  5516.         if Card_DM1.Conam = "                 " then
  5517.           Error_Message("CONAM",Field_Required);
  5518.         end if;
  5519.       exception
  5520.         when others  => Error_Message("BILET",Bad_Field);
  5521.       end;
  5522.     elsif Valid_Msg.Trtype = ADD then
  5523.       Error_Message("BILET",Field_Required);
  5524.       if Card_DM1.Cornk = "     " then
  5525.         Error_Message("CORNK",Field_Required);
  5526.       else
  5527.         begin
  5528.           Cornk_Type := Cornk_Types'value(Card_DM1.Cornk);
  5529.         exception
  5530.           when others  => Error_Message("CORNK",Bad_Field);
  5531.         end;
  5532.       end if;
  5533.       if Card_DM1.Conam = "                 " then
  5534.         Error_Message("CONAM",Field_Required);
  5535.       end if;
  5536.     end if;
  5537.     --
  5538.     --    if card is valid, place access pointer in message list and
  5539.     --    set up new access pointer for message list
  5540.     --
  5541.     if not Bad_Message then
  5542.       Valid_Msg.access_dm1 := Card_DM1;
  5543.       Link_List;
  5544.     end if;
  5545.  
  5546.   end Process_Card_DM1;
  5547.  
  5548.  
  5549. --**********************************************************************
  5550. --
  5551. --      This procedure does the processing for the validation of the
  5552. --    fields of a "DN1" card.
  5553. --
  5554. --**********************************************************************
  5555.  
  5556.   procedure Process_Card_DN1 is
  5557.  
  5558.   begin
  5559.     --
  5560.     --    set up new access pointer for card DN1
  5561.     --
  5562.     Card_DN1 := new Card_Type_DN1;
  5563.     --
  5564.     --    place strings if field components
  5565.     --
  5566.     Card_DN1.Ntask        := Input_Msg.card(15..27);
  5567.     Card_DN1.Prgeo        := Input_Msg.card(28..31);
  5568.     Card_DN1.Point        := Input_Msg.card(32..42);
  5569.     Card_DN1.Modfg        := Input_Msg.card(43..43);
  5570.     Card_DN1.Activ        := Input_Msg.card(44..45);
  5571.     Card_DN1.Pletd.MM     := Input_Msg.card(46..47);
  5572.     Card_DN1.Pletd.DD     := Input_Msg.card(48..49);
  5573.     Card_DN1.Pletd.HH     := Input_Msg.card(50..51);
  5574.     Card_DN1.Ndest        := Input_Msg.card(52..62);
  5575.     Card_DN1.Deta.MM      := Input_Msg.card(63..64);
  5576.     Card_DN1.Deta.DD      := Input_Msg.card(65..66);
  5577.     Card_DN1.Deta.HH      := Input_Msg.card(67..68);
  5578.     Card_DN1.Cxmrs        := Input_Msg.card(69..69);
  5579.     --
  5580.     --    PRGEO is required to be reported and will be validated against
  5581.     --    an IDM database relation Geoloc.
  5582.     --
  5583.     if Card_DN1.Prgeo = "    " then
  5584.       Error_Message("PRGEO",Field_Required);
  5585.     else
  5586.       Validate_Geolocation(Card_DN1.Prgeo,"PRGEO");
  5587.     end if;
  5588.     --
  5589.     --    POINT and CXMRS are mutually exclusive
  5590.     --
  5591.     if Card_DN1.Point /= "           " then
  5592.       if Card_DN1.Cxmrs /= " " then
  5593.         Error_Message("",Mutually_Exclusive);
  5594.       end if;
  5595.       Valid_Value := string_to_integer(Card_DN1.Point(1..2));
  5596.       if Valid_Value not in 0..90 then
  5597.         Error_Message("POINT",Bad_Field);
  5598.       else
  5599.         Valid_Value := string_to_integer(Card_DN1.Point(3..4));
  5600.         if Valid_Value not in 0..59 then
  5601.           Error_Message("POINT",Bad_Field);
  5602.         else
  5603.           Valid_Value := string_to_integer(Card_DN1.Point(6..8));
  5604.           if Valid_Value not in 0..180 then
  5605.             Error_Message("POINT",Bad_Field);
  5606.           else
  5607.             Valid_Value := string_to_integer(Card_DN1.Point(9..10));
  5608.             if Valid_Value not in 0..59 then
  5609.               Error_Message("POINT",Bad_Field);
  5610.             elsif (Card_DN1.Point(5) = 'N' or
  5611.                    Card_DN1.Point(5) = 'S') then
  5612.               if (Card_DN1.Point(11) = 'E' or
  5613.                   Card_DN1.Point(11) = 'W') then
  5614.                 null;
  5615.               else
  5616.                 Error_Message("POINT",Bad_Field);
  5617.               end if;
  5618.             else
  5619.               Error_Message("POINT",Bad_Field);
  5620.             end if;
  5621.           end if;
  5622.         end if;
  5623.       end if;
  5624.     elsif Card_DN1.Cxmrs /= " " then
  5625.       begin
  5626.         Nucin_Type    := Nucin_Types'value(Card_DN1.Cxmrs);
  5627.       exception
  5628.         when others  => Error_Message("CXMRS",Bad_Field);
  5629.       end;
  5630.     end if;
  5631. --
  5632.     begin
  5633.       if Card_DN1.Modfg /= " " then
  5634.         Nucin_Type    := Nucin_Types'value(Card_DN1.Modfg);
  5635.       end if;
  5636.     exception
  5637.       when others  => Error_Message("MODFG",Bad_Field);
  5638.     end;
  5639.     --
  5640.     begin
  5641.       if Card_DN1.Activ /= "  " then
  5642.         if Card_DN1.Activ /= "IN" then
  5643.           Activ_Type  := Activ_Types'value(Card_DN1.Activ);
  5644.         end if;
  5645.       end if;
  5646.     exception
  5647.       when others  => Error_Message("ACTIV",Bad_Field);
  5648.     end;
  5649.     --
  5650.     --    if PLETD is reported it must be greater than the header date but
  5651.     --    not more than 3 months greater.
  5652.     --
  5653.     begin
  5654.       if Card_DN1.Pletd.MM /= "  " or
  5655.          Card_DN1.Pletd.DD /= "  " or
  5656.          Card_DN1.Pletd.HH /= "  " then
  5657.         Month_of_Year := string_to_integer(Card_DN1.Pletd.MM);
  5658.         if Month_of_Year not in 1..12 then
  5659.           raise constraint_error;
  5660.         end if;
  5661.         Card_DN1.Pletd.Year := Header_Year;
  5662.         if Month_of_Year /= Header_Month then
  5663.           Valid_Value := Header_Month + 3;
  5664.           if Valid_Value > 12 then
  5665.             Valid_Value := Valid_Value - 12;
  5666.             Card_DN1.Pletd.Year := Header_Year + 1;
  5667.           end if;
  5668.           if Month_of_Year < Header_Month or
  5669.              Month_of_Year > Valid_Value then
  5670.             raise constraint_error;
  5671.           end if;
  5672.         end if;
  5673.         Days_in_Month(2) := 29;
  5674.         Valid_Value := string_to_integer(Card_DN1.Pletd.DD);
  5675.         if Valid_Value not in 1..Days_in_Month(Month_of_Year) then
  5676.           raise constraint_error;
  5677.         end if;
  5678.         Valid_Value := string_to_integer(Card_DN1.Pletd.HH);
  5679.         if Valid_Value not in 0..23 then
  5680.           raise constraint_error;
  5681.         end if;
  5682.       end if;
  5683.     exception
  5684.       when others  => Error_Message("PLETD",Bad_Field);
  5685.     end;
  5686.     --  the field NDEST is a lat/lon in the format DDMMhDDDMMh
  5687.     begin
  5688.       if Card_DN1.Ndest /= "           " then
  5689.         Valid_Value := string_to_integer(Card_DN1.Ndest(1..2));
  5690.         if Valid_Value < 0 then
  5691.           Working_String := "          ";
  5692.           Working_String(1..1) := Card_DN1.Ndest(1..1);
  5693.           alphabetic_type := alphabetic_types'value(Working_String);
  5694.         elsif Valid_Value > 90 then
  5695.           raise constraint_error;
  5696.         else
  5697.           Valid_Value := string_to_integer(Card_DN1.Ndest(3..4));
  5698.           if Valid_Value not in 0..59 then
  5699.             raise constraint_error;
  5700.           end if;
  5701.           if Card_DN1.Ndest(5) = 'N' or Card_DN1.Ndest(5) = 'S' then
  5702.             null;
  5703.           else
  5704.             raise constraint_error;
  5705.           end if;
  5706.           Valid_Value := string_to_integer(Card_DN1.Ndest(6..8));
  5707.           if Valid_Value not in 0..180 then
  5708.             raise constraint_error;
  5709.           end if;
  5710.           Valid_Value := string_to_integer(Card_DN1.Ndest(9..10));
  5711.           if Valid_Value not in 0..59 then
  5712.             raise constraint_error;
  5713.           end if;
  5714.           if Card_DN1.Ndest(11) = 'E' or Card_DN1.Ndest(11) = 'W' then
  5715.             null;
  5716.           else
  5717.             raise constraint_error;
  5718.           end if;
  5719.         end if;
  5720.       end if;
  5721.     exception
  5722.       when others  => Error_Message("NDEST",Bad_Field);
  5723.     end;
  5724.     --
  5725.     --    if DETA is reported it must be greater than the header date but
  5726.     --    not more than 3 months greater.
  5727.     --
  5728.     begin
  5729.       if Card_DN1.Deta.MM /= "  " or
  5730.          Card_DN1.Deta.DD /= "  " or
  5731.          Card_DN1.Deta.HH /= "  " then
  5732.         Month_of_Year := string_to_integer(Card_DN1.Deta.MM);
  5733.         if Month_of_Year not in 1..12 then
  5734.           raise constraint_error;
  5735.         end if;
  5736.         Card_DN1.Deta.Year := Header_Year;
  5737.         if Month_of_Year /= Header_Month then
  5738.           Valid_Value := Header_Month + 3;
  5739.           if Valid_Value > 12 then
  5740.             Valid_Value := Valid_Value - 12;
  5741.             Card_DN1.Deta.Year := Header_Year + 1;
  5742.           end if;
  5743.           if Month_of_Year < Header_Month or
  5744.              Month_of_Year > Valid_Value then
  5745.             raise constraint_error;
  5746.           end if;
  5747.         end if;
  5748.         Days_in_Month(2) := 29;
  5749.         Valid_Value := string_to_integer(Card_DN1.Deta.DD);
  5750.         if Valid_Value not in 1..Days_in_Month(Month_of_Year) then
  5751.           raise constraint_error;
  5752.         end if;
  5753.         Valid_Value := string_to_integer(Card_DN1.Deta.HH);
  5754.         if Valid_Value not in 0..59 then
  5755.           raise constraint_error;
  5756.         end if;
  5757.       end if;
  5758.     exception
  5759.       when others  => Error_Message("DETA ",Bad_Field);
  5760.     end;
  5761.     --
  5762.     --    if card is valid, place access pointer in message list and
  5763.     --    set up new access pointer for message list
  5764.     --
  5765.     if not Bad_Message then
  5766.       Valid_Msg.access_dn1 := Card_DN1;
  5767.       Link_List;
  5768.     end if;
  5769.  
  5770.   end Process_Card_DN1;
  5771.  
  5772.  
  5773. --**********************************************************************
  5774. --
  5775. --      This procedure does the processing for the validation of the
  5776. --    fields of a "JM1" card.
  5777. --
  5778. --**********************************************************************
  5779.  
  5780.   procedure Process_Card_JM1 is
  5781.  
  5782.   begin
  5783.     --
  5784.     --    set up new access pointer for card JM1
  5785.     --
  5786.     Card_JM1 := new Card_Type_JM1;
  5787.     --
  5788.     --    validate and convert SCATD
  5789.     --
  5790.     begin
  5791.       Working_String       := "          ";
  5792.       Working_String(1..2) := Input_Msg.card(15..16);
  5793.       Card_JM1.Scatd       := Scatd_Types'value(Working_String);
  5794.     exception
  5795.       when others  => Error_Message("SCATD",Bad_Field);
  5796.     end;
  5797.     --
  5798.     --    place strings in field components
  5799.     --
  5800.     Card_JM1.Mgo          := Input_Msg.card(17..21);
  5801.     Card_JM1.Ago          := Input_Msg.card(22..26);
  5802.     Card_JM1.Na           := Input_Msg.card(27..31);
  5803.     Card_JM1.Nfo          := Input_Msg.card(32..36);
  5804.     Card_JM1.Menl         := Input_Msg.card(37..41);
  5805.     Card_JM1.Navo         := Input_Msg.card(42..46);
  5806.     Card_JM1.Nave         := Input_Msg.card(47..51);
  5807.     Card_JM1.Othof        := Input_Msg.card(52..56);
  5808.     Card_JM1.Othen        := Input_Msg.card(57..61);
  5809.     Card_JM1.Piaod        := Input_Msg.card(62..67);
  5810.     --
  5811.     Validate_Numeric(Card_JM1.Mgo,"MGO  ");
  5812.     Validate_Numeric(Card_JM1.Ago,"AGO  ");
  5813.     Validate_Numeric(Card_JM1.Na,"NA   ");
  5814.     Validate_Numeric(Card_JM1.Nfo,"NFO  ");
  5815.     Validate_Numeric(Card_JM1.Menl,"MENL ");
  5816.     Validate_Numeric(Card_JM1.Navo,"NAVO ");
  5817.     Validate_Numeric(Card_JM1.Nave,"NAVE ");
  5818.     Validate_Numeric(Card_JM1.Othof,"OTHOF");
  5819.     Validate_Numeric(Card_JM1.Othen,"OTHEN");
  5820.     --
  5821.     --    if card is valid, place access pointer in message list and
  5822.     --    set up new access pointer for message list
  5823.     --
  5824.     if not Bad_Message then
  5825.       Valid_Msg.access_jm1 := Card_JM1;
  5826.       Link_List;
  5827.     end if;
  5828.  
  5829.   end Process_Card_JM1;
  5830.  
  5831.  
  5832. --**********************************************************************
  5833. --
  5834. --      This procedure does the processing for the validation of the
  5835. --    fields of a "KF1" card.
  5836. --
  5837. --**********************************************************************
  5838.  
  5839.   procedure Process_Card_KF1 is
  5840.     Pertp_Value : integer;
  5841.     Pertc_Value : integer;
  5842.     Trutc_Value : integer;
  5843.     Tcrav_Value : integer;
  5844.     Tcarq_Value : integer;
  5845.     Tcras_Value : integer;
  5846.     Trsa1_Value : integer;
  5847.     Trsa2_Value : integer;
  5848.     Trsa3_Value : integer;
  5849.     Trsa4_Value : integer;
  5850.     Trsa5_Value : integer;
  5851.     Cpaur_Value : integer;
  5852.     Cpasg_Value : integer;
  5853.     Cpavl_Value : integer;
  5854.     Tpaut_Value : integer;
  5855.     Tpasg_Value : integer;
  5856.     Tpavl_Value : integer;
  5857.   begin
  5858.     --
  5859.     --    set up new access pointer for card KF1
  5860.     --
  5861.     Card_KF1 := new Card_Type_KF1;
  5862.     --
  5863.     --    place strings in field components
  5864.     --
  5865.     Card_KF1.Docnr        := Input_Msg.card(15..15);
  5866.     Card_KF1.Docid        := Input_Msg.card(16..19);
  5867.     Card_KF1.Pertp        := Input_Msg.card(20..21);
  5868.     Card_KF1.Tpaut        := Input_Msg.card(22..25);
  5869.     Card_KF1.Tpasg        := Input_Msg.card(26..29);
  5870.     Card_KF1.Tpavl        := Input_Msg.card(30..33);
  5871.     Card_KF1.Pertc        := Input_Msg.card(34..35);
  5872.     Card_KF1.Cpaur        := Input_Msg.card(36..39);
  5873.     Card_KF1.Cpasg        := Input_Msg.card(40..43);
  5874.     Card_KF1.Cpavl        := Input_Msg.card(44..47);
  5875.     Card_KF1.Trutc        := Input_Msg.card(48..49);
  5876.     Card_KF1.Tmthd        := Input_Msg.card(50..50);
  5877.     Card_KF1.Tcarq        := Input_Msg.card(51..53);
  5878.     Card_KF1.Tcras        := Input_Msg.card(54..56);
  5879.     Card_KF1.Tcrav        := Input_Msg.card(57..59);
  5880.     Card_KF1.Trsa1        := Input_Msg.card(60..61);
  5881.     Card_KF1.Trsa2        := Input_Msg.card(62..63);
  5882.     Card_KF1.Trsa3        := Input_Msg.card(64..65);
  5883.     Card_KF1.Trsa4        := Input_Msg.card(66..67);
  5884.     Card_KF1.Trsa5        := Input_Msg.card(68..69);
  5885.     --
  5886.     --    DOCNR is required to be reported
  5887.     --
  5888.     if Card_KF1.Docnr = " " then
  5889.       Error_Message("DOCNR",Field_Required);
  5890.     end if;
  5891.     --
  5892.     --    DOCID is required to be reported when transaction type is Add
  5893.     --
  5894.     begin
  5895.       if Card_KF1.Docid /= "    " then
  5896.         Docid_Type := Docid_Types'value(Card_KF1.Docid);
  5897.       elsif Valid_Msg.Trtype = ADD then
  5898.         Error_Message("DOCID",Field_Required);
  5899.       end if;
  5900.     exception
  5901.       when others  => Error_Message("DOCID",Bad_Field);
  5902.     end;
  5903.     --
  5904.     if Card_KF1.Pertp = "  " then
  5905.       if (Valid_Msg.Trtype = ADD or Valid_Msg.Trtype = CHANGE) or
  5906.          (Card_KF1.Tpavl /= "    " or Card_KF1.Tpasg /= "    " or
  5907.           Card_KF1.Tpaut /= "    ") then
  5908.         Error_Message("PERTP",Field_Required);
  5909.       end if;
  5910.     else
  5911.       Pertp_Value := string_to_integer(Card_KF1.Pertp);
  5912.       if Card_KF1.Pertp = "**" then
  5913.         Pertp_Value := 100;
  5914.       end if;
  5915.       Tpaut_Value := string_to_Integer(Card_KF1.Tpaut);
  5916.       Tpasg_Value := string_to_Integer(Card_KF1.Tpasg);
  5917.       Tpavl_Value := string_to_Integer(Card_KF1.Tpavl);
  5918.       if Tpasg_Value < 0 or
  5919.          Tpasg_Value > Tpaut_Value or
  5920.          Tpasg_Value < Tpavl_Value then
  5921.         Error_Message("TPASG",Bad_Field);
  5922.       elsif Tpaut_Value < Tpavl_Value then
  5923.         Error_Message("TPAUT",Bad_Field);
  5924.       elsif Tpavl_Value < 0 then
  5925.         Error_Message("TPAVL",Bad_Field);
  5926.       elsif Pertp_Value < 0 or
  5927.             Pertp_Value /= (Tpavl_Value * 100) / Tpaut_Value then
  5928.         Error_Message("PERTP",Bad_Field);
  5929.       end if;
  5930.     end if;
  5931.     --
  5932.     if Card_KF1.Pertc = "  " then
  5933.       if (Valid_Msg.Trtype = ADD or Valid_Msg.Trtype = CHANGE) or
  5934.          (Card_KF1.Cpavl /= "    " or Card_KF1.Cpasg /= "    " or
  5935.           Card_KF1.Cpaur /= "    ") then
  5936.         Error_Message("PERTC",Field_Required);
  5937.       end if;
  5938.     else
  5939.       Pertc_Value := string_to_integer(Card_KF1.Pertc);
  5940.       if Card_KF1.Pertc = "**" then
  5941.         Pertc_Value := 100;
  5942.       end if;
  5943.       Cpaur_Value := string_to_Integer(Card_KF1.Cpaur);
  5944.       Cpasg_Value := string_to_Integer(Card_KF1.Cpasg);
  5945.       Cpavl_Value := string_to_Integer(Card_KF1.Cpavl);
  5946.       if Cpasg_Value < 0 or
  5947.          Cpasg_Value > Cpaur_Value or
  5948.          Cpasg_Value < Cpavl_Value then
  5949.         Error_Message("CPASG",Bad_Field);
  5950.       elsif Cpaur_Value < Cpavl_Value then
  5951.         Error_Message("CPAUR",Bad_Field);
  5952.       elsif Cpavl_Value < 0 then
  5953.         Error_Message("CPAVL",Bad_Field);
  5954.       elsif Pertc_Value < 0 or
  5955.             Pertc_Value /= (Cpavl_Value * 100) / Cpaur_Value then
  5956.         Error_Message("PERTC",Bad_Field);
  5957.       end if;
  5958.     end if;
  5959.     --
  5960.     begin
  5961.       if Card_KF1.Tmthd = " " then
  5962.         if (Valid_Msg.Trtype = ADD or Valid_Msg.Trtype = CHANGE) or
  5963.             Card_KF1.Trutc /= "  " or (Card_KF1.Tcrav /= "   " or
  5964.             Card_KF1.Tcras /= "   " or Card_KF1.Tcarq /= "   ") or
  5965.            (Card_KF1.Trsa1 /= "  " or Card_KF1.Trsa2 /= "  " or
  5966.             Card_KF1.Trsa3 /= "  " or Card_KF1.Trsa4 /= "  " or
  5967.             Card_KF1.Trsa5 /= "  ") then
  5968.           Error_Message("TMTHD",Field_Required);
  5969.         end if;
  5970.         if Card_KF1.Trutc /= "  " then
  5971.           Error_Message("TMTHD",Field_Required);
  5972.         end if;
  5973.       else
  5974.         Tmthd_Type := Tmthd_Types'value(Card_KF1.Tmthd);
  5975.         case Tmthd_Type is
  5976.           when B  => if Card_KF1.Tcarq = "   " then
  5977.                        Error_Message("TCARQ",Field_Required);
  5978.                      elsif Card_KF1.Tcras = "   " then
  5979.                        Error_Message("TCRAS",Field_Required);
  5980.                      elsif Card_KF1.Tcrav = "   " then
  5981.                        Error_Message("TCRAV",Field_Required);
  5982.                      elsif Valid_Msg.Trtype = CHANGE and
  5983.                            Card_KF1.Tcarq = "#  " and
  5984.                            Card_KF1.Tcras = "#  " and
  5985.                            Card_KF1.Tcrav = "#  " then
  5986.                        null;
  5987.                      else
  5988.                        Tcarq_Value := string_to_integer(Card_KF1.Tcarq);
  5989.                        Tcras_Value := string_to_integer(Card_KF1.Tcras);
  5990.                        Tcrav_Value := string_to_integer(Card_KF1.Tcrav);
  5991.                        if Tcras_Value < 0 or
  5992.                           Tcras_Value > Tcarq_Value or
  5993.                           Tcras_Value < Tcrav_Value then
  5994.                          Error_Message("TCRAS",Bad_Field);
  5995.                        elsif Tcarq_Value < Tcrav_Value then
  5996.                          Error_Message("TCRAV",Bad_Field);
  5997.                        elsif Tcarq_Value < 0 then
  5998.                          Error_Message("TCARQ",Bad_Field);
  5999.                        else
  6000.                          Trutc_Value :=
  6001.                              string_to_integer(Card_KF1.Trutc);
  6002.                          if Card_KF1.Trutc = "**" then
  6003.                            Trutc_Value := 100;
  6004.                          end if;
  6005.                          if Trutc_Value < 0 or
  6006.                             Trutc_Value /= (Tcrav_Value * 100) /
  6007.                                Tcarq_Value then
  6008.                            Error_Message("TRUTC",Bad_Field);
  6009.                          end if;
  6010.                        end if;
  6011.                      end if;
  6012.           when C  => if Card_KF1.Trsa1 = "  " then
  6013.                        Error_Message("TRSA1",Field_Required);
  6014.                      elsif Card_KF1.Trsa2 = "  " then
  6015.                        Error_Message("TRSA2",Field_Required);
  6016.                      elsif Card_KF1.Trsa3 = "  " then
  6017.                        Error_Message("TRSA3",Field_Required);
  6018.                      elsif Card_KF1.Trsa4 = "  " then
  6019.                        Error_Message("TRSA4",Field_Required);
  6020.                      elsif Card_KF1.Trsa5 = "  " then
  6021.                        Error_Message("TRSA5",Field_Required);
  6022.                      elsif Valid_Msg.Trtype = CHANGE and
  6023.                            Card_KF1.Trsa1 = "# " and
  6024.                            Card_KF1.Trsa2 = "# " and
  6025.                            Card_KF1.Trsa3 = "# " and
  6026.                            Card_KF1.Trsa4 = "# " and
  6027.                            Card_KF1.Trsa5 = "# " then
  6028.                        null;
  6029.                      else
  6030.                        Trsa1_Value := string_to_integer(Card_KF1.Trsa1);
  6031.                        if Trsa1_Value < 0 then
  6032.                          Error_Message("TRSA1",Bad_Field);
  6033.                        end if;
  6034.                        Trsa2_Value := string_to_integer(Card_KF1.Trsa2);
  6035.                        if Trsa2_Value < 0 then
  6036.                          Error_Message("TRSA2",Bad_Field);
  6037.                        end if;
  6038.                        Trsa3_Value := string_to_integer(Card_KF1.Trsa3);
  6039.                        if Trsa3_Value < 0 then
  6040.                          Error_Message("TRSA3",Bad_Field);
  6041.                        end if;
  6042.                        Trsa4_Value := string_to_integer(Card_KF1.Trsa4);
  6043.                        if Trsa4_Value < 0 then
  6044.                          Error_Message("TRSA4",Bad_Field);
  6045.                        end if;
  6046.                        Trsa5_Value := string_to_integer(Card_KF1.Trsa5);
  6047.                        if Trsa5_Value < 0 then
  6048.                          Error_Message("TRSA5",Bad_Field);
  6049.                        end if;
  6050.                        if Trsa1_Value < 0 or Trsa2_Value < 0 or
  6051.                           Trsa3_Value < 0 or Trsa4_Value < 0 or
  6052.                           Trsa5_Value < 0 then
  6053.                          null;
  6054.                        else
  6055.                          Valid_Value := Trsa1_Value;
  6056.                          if Trsa2_Value < Valid_Value then
  6057.                            Valid_Value := Trsa2_Value;
  6058.                          end if;
  6059.                          if Trsa3_Value < Valid_Value then
  6060.                            Valid_Value := Trsa3_Value;
  6061.                          end if;
  6062.                          if Trsa4_Value < Valid_Value then
  6063.                            Valid_Value := Trsa4_Value;
  6064.                          end if;
  6065.                          if Trsa5_Value < Valid_Value then
  6066.                            Valid_Value := Trsa5_Value;
  6067.                          end if;
  6068.                          Trutc_Value := 100;
  6069.                          if Card_KF1.Trutc /= "**" then
  6070.                            Trutc_Value :=
  6071.                               string_to_integer(Card_KF1.Trutc);
  6072.                          end if;
  6073.                          if Trutc_Value < 0 or
  6074.                             Trutc_Value /= Valid_Value then
  6075.                            Error_Message("TRUTC",Bad_Field);
  6076.                          end if;
  6077.                        end if;
  6078.                      end if;
  6079.         end case;
  6080.       end if;
  6081.     exception
  6082.       when others  => Error_Message("TMTHD",Bad_Field);
  6083.     end;
  6084.     --
  6085.     --    if card is valid, place access pointer in message list and
  6086.     --    set up new access pointer for message list
  6087.     --
  6088.     if not Bad_Message then
  6089.       Valid_Msg.access_kf1 := Card_KF1;
  6090.       Link_List;
  6091.     end if;
  6092.  
  6093.   end Process_Card_KF1;
  6094.  
  6095.  
  6096. --**********************************************************************
  6097. --
  6098. --      This procedure does the processing for the validation of the
  6099. --    fields of a "KF2" card.
  6100. --
  6101. --**********************************************************************
  6102.  
  6103.   procedure Process_Card_KF2 is
  6104.     Eqsee_Value : integer;
  6105.     Mepos_Value : integer;
  6106.     Meard_Value : integer;
  6107.   begin
  6108.     --
  6109.     --    set up new access pointer for card KF2
  6110.     --
  6111.     Card_KF2 := new Card_Type_KF2;
  6112.     --
  6113.     --    place strings in field components
  6114.     --
  6115.     Card_KF2.Docnr        := Input_Msg.card(15..15);
  6116.     Card_KF2.Eqsee        := Input_Msg.card(16..17);
  6117.     Card_KF2.Eqsse        := Input_Msg.card(18..19);
  6118.     Card_KF2.Meard        := Input_Msg.card(20..22);
  6119.     Card_KF2.Measq        := Input_Msg.card(23..25);
  6120.     Card_KF2.Mepos        := Input_Msg.card(26..28);
  6121.     Card_KF2.Essa1        := Input_Msg.card(29..30);
  6122.     Card_KF2.Essa2        := Input_Msg.card(31..32);
  6123.     Card_KF2.Essa3        := Input_Msg.card(33..34);
  6124.     Card_KF2.Essa4        := Input_Msg.card(35..36);
  6125.     Card_KF2.Essa5        := Input_Msg.card(37..38);
  6126.     Card_KF2.Essa6        := Input_Msg.card(39..40);
  6127.     Card_KF2.Essa7        := Input_Msg.card(41..42);
  6128.     Card_KF2.Essa8        := Input_Msg.card(43..44);
  6129.     Card_KF2.Essa9        := Input_Msg.card(45..46);
  6130.     Card_KF2.Eqree        := Input_Msg.card(47..48);
  6131.     Card_KF2.Eqred        := Input_Msg.card(49..50);
  6132.     Card_KF2.Memra        := Input_Msg.card(51..53);
  6133.     Card_KF2.Ersa1        := Input_Msg.card(54..55);
  6134.     Card_KF2.Ersa2        := Input_Msg.card(56..57);
  6135.     Card_KF2.Ersa3        := Input_Msg.card(58..59);
  6136.     Card_KF2.Ersa4        := Input_Msg.card(60..61);
  6137.     Card_KF2.Ersa5        := Input_Msg.card(62..63);
  6138.     Card_KF2.Ersa6        := Input_Msg.card(64..65);
  6139.     Card_KF2.Ersa7        := Input_Msg.card(66..67);
  6140.     Card_KF2.Ersa8        := Input_Msg.card(68..69);
  6141.     --
  6142.     --    DOCNR is required to be reported
  6143.     --
  6144.     if Card_KF2.Docnr = " " then
  6145.       Error_Message("DOCNR",Field_Required);
  6146.     end if;
  6147.     --
  6148.     if Card_KF2.Eqsee = "  " then
  6149.       if Card_KF2.Meard /= "   " or Card_KF2.Mepos /= "   " then
  6150.         Error_Message("EQSEE",Field_Required);
  6151.       end if;
  6152.     elsif Valid_Msg.Trtype = CHANGE and Card_KF2.Eqsee = "# " and
  6153.           Card_KF2.Mepos = "#  " and Card_KF2.Meard = "#  " then
  6154.       null;
  6155.     else
  6156.       Eqsee_Value := string_to_integer(Card_KF2.Eqsee);
  6157.       if Card_KF2.Eqsee = "**" then
  6158.         Eqsee_Value := 100;
  6159.       end if;
  6160.       if Eqsee_Value < 0 then
  6161.         Error_Message("EQSEE",Bad_Field);
  6162.       else
  6163.         Mepos_Value := string_to_integer(Card_KF2.Mepos);
  6164.         if Mepos_Value < 0 then
  6165.           Error_Message("MEPOS",Bad_Field);
  6166.         end if;
  6167.         Meard_Value := string_to_integer(Card_KF2.Meard);
  6168.         if Meard_Value < 0 then
  6169.           Error_Message("MEARD",Bad_Field);
  6170.         end if;
  6171.         if Meard_Value < 0 or Mepos_Value < 0 then
  6172.           null;
  6173.         elsif Eqsee_Value /= (Mepos_Value * 100) / Meard_Value then
  6174.           Error_Message("EQSEE",Bad_Field);
  6175.         end if;
  6176.       end if;
  6177.     end if;
  6178.     --
  6179.     if Card_KF2.Eqsse /= "  " then
  6180.       if Valid_Msg.Trtype = CHANGE and Card_KF2.Eqsse = "# " then
  6181.         null;
  6182.       elsif Card_KF2.Eqsse /= "**" then
  6183.         Valid_Value := string_to_integer(Card_KF2.Eqsse);
  6184.         if Valid_Value < 0 then
  6185.           Error_Message("EQSSE",Bad_Field);
  6186.         end if;
  6187.       end if;
  6188.     end if;
  6189.     --
  6190.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Measq = "#  " then
  6191.       null;
  6192.     else
  6193.       Validate_Numeric(Card_KF2.Measq,"MEASQ");
  6194.     end if;
  6195.     --
  6196.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa1 = "# " then
  6197.       null;
  6198.     else
  6199.       Validate_Numeric(Card_KF2.Essa1,"ESSA1");
  6200.     end if;
  6201.     --
  6202.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa2 = "# " then
  6203.       null;
  6204.     else
  6205.       Validate_Numeric(Card_KF2.Essa2,"ESSA2");
  6206.     end if;
  6207.     --
  6208.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa3 = "# " then
  6209.       null;
  6210.     else
  6211.       Validate_Numeric(Card_KF2.Essa3,"ESSA3");
  6212.     end if;
  6213.     --
  6214.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa4 = "# " then
  6215.       null;
  6216.     else
  6217.       Validate_Numeric(Card_KF2.Essa4,"ESSA4");
  6218.     end if;
  6219.     --
  6220.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa5 = "# " then
  6221.       null;
  6222.     else
  6223.       Validate_Numeric(Card_KF2.Essa5,"ESSA5");
  6224.     end if;
  6225.     --
  6226.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa6 = "# " then
  6227.       null;
  6228.     else
  6229.       Validate_Numeric(Card_KF2.Essa6,"ESSA6");
  6230.     end if;
  6231.     --
  6232.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa7 = "# " then
  6233.       null;
  6234.     else
  6235.       Validate_Numeric(Card_KF2.Essa7,"ESSA7");
  6236.     end if;
  6237.     --
  6238.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa8 = "# " then
  6239.       null;
  6240.     else
  6241.       Validate_Numeric(Card_KF2.Essa8,"ESSA8");
  6242.     end if;
  6243.     --
  6244.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Essa9 = "# " then
  6245.       null;
  6246.     else
  6247.       Validate_Numeric(Card_KF2.Essa9,"ESSA9");
  6248.     end if;
  6249.     --
  6250.     if Card_KF2.Eqree /= "  " then
  6251.       if Valid_Msg.Trtype = CHANGE and Card_KF2.Eqree = "# " then
  6252.         null;
  6253.       elsif Card_KF2.Eqree /= "**" then
  6254.         Valid_Value := string_to_integer(Card_KF2.Eqree);
  6255.         if Valid_Value < 0 then
  6256.           Error_Message("EQREE",Bad_Field);
  6257.         end if;
  6258.       end if;
  6259.     end if;
  6260.     --
  6261.     if Card_KF2.Eqred /= "  " then
  6262.       if Valid_Msg.Trtype = CHANGE and Card_KF2.Eqred = "# " then
  6263.         null;
  6264.       elsif Card_KF2.Eqred /= "**" then
  6265.         Valid_Value := string_to_integer(Card_KF2.Eqred);
  6266.         if Valid_Value < 0 then
  6267.           Error_Message("EQRED",Bad_Field);
  6268.         end if;
  6269.       end if;
  6270.     end if;
  6271.     --
  6272.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Memra = "#  " then
  6273.       null;
  6274.     else
  6275.       Validate_Numeric(Card_KF2.Memra,"MEMRA");
  6276.     end if;
  6277.     --
  6278.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Ersa1 = "# " then
  6279.       null;
  6280.     else
  6281.       Validate_Numeric(Card_KF2.Ersa1,"Ersa1");
  6282.     end if;
  6283.     --
  6284.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Ersa2 = "# " then
  6285.       null;
  6286.     else
  6287.       Validate_Numeric(Card_KF2.Ersa2,"Ersa2");
  6288.     end if;
  6289.     --
  6290.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Ersa3 = "# " then
  6291.       null;
  6292.     else
  6293.       Validate_Numeric(Card_KF2.Ersa3,"Ersa3");
  6294.     end if;
  6295.     --
  6296.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Ersa4 = "# " then
  6297.       null;
  6298.     else
  6299.       Validate_Numeric(Card_KF2.Ersa4,"Ersa4");
  6300.     end if;
  6301.     --
  6302.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Ersa5 = "# " then
  6303.       null;
  6304.     else
  6305.       Validate_Numeric(Card_KF2.Ersa5,"Ersa5");
  6306.     end if;
  6307.     --
  6308.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Ersa6 = "# " then
  6309.       null;
  6310.     else
  6311.       Validate_Numeric(Card_KF2.Ersa6,"Ersa6");
  6312.     end if;
  6313.     --
  6314.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Ersa7 = "# " then
  6315.       null;
  6316.     else
  6317.       Validate_Numeric(Card_KF2.Ersa7,"Ersa7");
  6318.     end if;
  6319.     --
  6320.     if Valid_Msg.Trtype = CHANGE and Card_KF2.Ersa8 = "# " then
  6321.       null;
  6322.     else
  6323.       Validate_Numeric(Card_KF2.Ersa8,"Ersa8");
  6324.     end if;
  6325.     --
  6326.     --    if card is valid, place access pointer in mErsage list and
  6327.     --    set up new access pointer for message list
  6328.     --
  6329.     if not Bad_Message then
  6330.       Valid_Msg.access_kf2 := Card_KF2;
  6331.       Link_List;
  6332.     end if;
  6333.  
  6334.   end Process_Card_KF2;
  6335.  
  6336.  
  6337. --**********************************************************************
  6338. --
  6339. --      This procedure does the processing for the validation of the
  6340. --    fields of a "KF3" card.
  6341. --
  6342. --**********************************************************************
  6343.  
  6344.   procedure Process_Card_KF3 is
  6345.     Readf_Value : integer;
  6346.     Prraf_Value : integer;
  6347.     Esraf_Value : integer;
  6348.     Erraf_Value : integer;
  6349.     Trraf_Value : integer;
  6350.   begin
  6351.     --
  6352.     --    initialize variables
  6353.     --
  6354.     Readf_Value := 0;
  6355.     Prraf_Value := 0;
  6356.     Esraf_Value := 0;
  6357.     Erraf_Value := 0;
  6358.     Trraf_Value := 0;
  6359.     --
  6360.     --    set up new access pointer for card KF3
  6361.     --
  6362.     Card_KF3 := new Card_Type_KF3;
  6363.     --
  6364.     --    place strings in field components
  6365.     --
  6366.     Card_KF3.Docnr        := Input_Msg.card(15..15);
  6367.     Card_KF3.Sdoc         := Input_Msg.card(16..19);
  6368.     Card_KF3.Readf        := Input_Msg.card(20..20);
  6369.     Card_KF3.Reasf        := Input_Msg.card(21..21);
  6370.     Card_KF3.Prraf        := Input_Msg.card(22..22);
  6371.     Card_KF3.Prref        := Input_Msg.card(23..25);
  6372.     Card_KF3.Esraf        := Input_Msg.card(26..26);
  6373.     Card_KF3.Esref        := Input_Msg.card(27..29);
  6374.     Card_KF3.Erraf        := Input_Msg.card(30..30);
  6375.     Card_KF3.Erref        := Input_Msg.card(31..33);
  6376.     Card_KF3.Trraf        := Input_Msg.card(34..34);
  6377.     Card_KF3.Trref        := Input_Msg.card(35..37);
  6378.     Card_KF3.Secrf        := Input_Msg.card(38..40);
  6379.     Card_KF3.Terrf        := Input_Msg.card(41..43);
  6380.     Card_KF3.Caraf        := Input_Msg.card(44..44);
  6381.     Card_KF3.Cadaf.YY     := Input_Msg.card(45..46);
  6382.     Card_KF3.Cadaf.MM     := Input_Msg.card(47..48);
  6383.     Card_KF3.Cadaf.DD     := Input_Msg.card(49..50);
  6384.     Card_KF3.Limf         := Input_Msg.card(51..51);
  6385.     Card_KF3.Rlimf        := Input_Msg.card(52..52);
  6386.     Card_KF3.Ricdf.YY     := Input_Msg.card(53..54);
  6387.     Card_KF3.Ricdf.MM     := Input_Msg.card(55..56);
  6388.     Card_KF3.Ricdf.DD     := Input_Msg.card(57..58);
  6389.     Card_KF3.Respf        := Input_Msg.card(59..63);
  6390.     --
  6391.     --    DOCNR is required to be reported
  6392.     --
  6393.     if Card_KF3.Docnr = " " then
  6394.       Error_Message("DOCNR",Field_Required);
  6395.     end if;
  6396.     --
  6397.     --    SDOC is required to be reported when transaction is Add
  6398.     --
  6399.     begin
  6400.       if Card_KF3.Sdoc /= "    " then
  6401.         Docid_Type := Docid_Types'value(Card_KF3.Sdoc);
  6402.       elsif Valid_Msg.Trtype = ADD then
  6403.         Error_Message("SDOC ",Field_Required);
  6404.       end if;
  6405.     exception
  6406.       when others  => Error_Message("SDOC ",Bad_Field);
  6407.     end;
  6408.     --
  6409.     if Card_KF3.Readf /= " " then
  6410.       Readf_Value := string_to_integer(Card_KF3.Readf);
  6411.       if Readf_Value not in 1..5 then
  6412.         Error_Message("READF",Bad_Field);
  6413.       end if;
  6414.     end if;
  6415.     --
  6416.     if Card_KF3.Prraf /= " " then
  6417.       Prraf_Value := string_to_integer(Card_KF3.Prraf);
  6418.       if Prraf_Value not in 1..6 then
  6419.         Error_Message("PRRAF",Bad_Field);
  6420.       elsif Prraf_Value /= 6 and Card_KF3.Reasf /= "X" then
  6421.         if Prraf_Value > Readf_Value then
  6422.           Error_Message("PRRAF",Bad_Field);
  6423.         end if;
  6424.       end if;
  6425.     end if;
  6426.     --
  6427.     begin
  6428.       if Card_KF3.Prref = "   " then
  6429.         if Prraf_Value in 2..4 then
  6430.           Error_Message("PRREF",Field_Required);
  6431.         end if;
  6432.       elsif Valid_Msg.Trtype = CHANGE and Card_KF3.Prref = "#  " then
  6433.         null;
  6434.       else
  6435.         Prres_Type    := Prres_Prres_Types'value(Card_KF3.Prref);
  6436.       end if;
  6437.     exception
  6438.       when others  => Error_Message("PRREF",Bad_Field);
  6439.     end;
  6440.     --
  6441.     if Card_KF3.Esraf /= " " then
  6442.       Esraf_Value := string_to_integer(Card_KF3.Esraf);
  6443.       if Esraf_Value not in 1..6 then
  6444.         Error_Message("ESRAF",Bad_Field);
  6445.       elsif Esraf_Value /= 6 and Card_KF3.Reasf /= "X" then
  6446.         if Esraf_Value > Readf_Value then
  6447.           Error_Message("ESRAF",Bad_Field);
  6448.         end if;
  6449.       end if;
  6450.     end if;
  6451.     --
  6452.     begin
  6453.       if Card_KF3.Esref = "   " then
  6454.         if Esraf_Value in 2..4 then
  6455.           Error_Message("ESREF",Field_Required);
  6456.         end if;
  6457.       elsif Valid_Msg.Trtype = CHANGE and Card_KF3.Esref = "#  " then
  6458.         null;
  6459.       else
  6460.         Esres_Type    := Esres_Prres_Types'value(Card_KF3.Esref);
  6461.       end if;
  6462.     exception
  6463.       when others  => Error_Message("ESREF",Bad_Field);
  6464.     end;
  6465.     --
  6466.     if Card_KF3.Erraf /= " " then
  6467.       Erraf_Value := string_to_integer(Card_KF3.Erraf);
  6468.       if Erraf_Value not in 1..6 then
  6469.         Error_Message("ERRAF",Bad_Field);
  6470.       elsif Erraf_Value /= 6 and Card_KF3.Reasf /= "X" then
  6471.         if Erraf_Value > Readf_Value then
  6472.           Error_Message("ERRAF",Bad_Field);
  6473.         end if;
  6474.       end if;
  6475.     end if;
  6476.     --
  6477.     begin
  6478.       if Card_KF3.Erref = "   " then
  6479.         if Erraf_Value in 2..4 then
  6480.           Error_Message("ERREF",Field_Required);
  6481.         end if;
  6482.       elsif Valid_Msg.Trtype = CHANGE and Card_KF3.Erref = "#  " then
  6483.         null;
  6484.       else
  6485.         Erres_Type    := Erres_Prres_Types'value(Card_KF3.Erref);
  6486.       end if;
  6487.     exception
  6488.       when others  => Error_Message("ERREF",Bad_Field);
  6489.     end;
  6490.     --
  6491.     if Card_KF3.Trraf /= " " then
  6492.       Trraf_Value := string_to_integer(Card_KF3.Trraf);
  6493.       if Trraf_Value not in 1..6 then
  6494.         Error_Message("TRRAF",Bad_Field);
  6495.       elsif Trraf_Value /= 6 and Card_KF3.Reasf /= "X" then
  6496.         if Trraf_Value > Readf_Value then
  6497.           Error_Message("TRRAF",Bad_Field);
  6498.         end if;
  6499.       end if;
  6500.     end if;
  6501.     --
  6502.     begin
  6503.       if Card_KF3.Trref = "   " then
  6504.         if Trraf_Value in 2..4 then
  6505.           Error_Message("TRREF",Field_Required);
  6506.         end if;
  6507.       elsif Valid_Msg.Trtype = CHANGE and Card_KF3.Trref = "#  " then
  6508.         null;
  6509.       else
  6510.         Trres_Type    := Trres_Prres_Types'value(Card_KF3.Trref);
  6511.       end if;
  6512.     exception
  6513.       when others  => Error_Message("TRREF",Bad_Field);
  6514.     end;
  6515.     --
  6516.     begin
  6517.       if Card_KF3.Reasf /= " " then
  6518.         Reasn_Type := Reasn_Types'value(Card_KF3.Reasf);
  6519.         case Reasn_Type is
  6520.           when N | M  => if Readf_Value /= 5 then
  6521.                            Error_Message("READF",Bad_Field);
  6522.                          end if;
  6523.           when X      => if Card_KF3.Readf = " " then
  6524.                            Error_Message("READF",Field_Required);
  6525.                          end if;
  6526.           when others => Valid_Value := 0;
  6527.                          if Prraf_Value /= 6 and
  6528.                             Prraf_Value > Valid_Value then
  6529.                            Valid_Value := Prraf_Value;
  6530.                          end if;
  6531.                          if Esraf_Value /= 6 and
  6532.                             Esraf_Value > Valid_Value then
  6533.                            Valid_Value := Esraf_Value;
  6534.                          end if;
  6535.                          if Erraf_Value /= 6 and
  6536.                             Erraf_Value > Valid_Value then
  6537.                            Valid_Value := Erraf_Value;
  6538.                          end if;
  6539.                          if Trraf_Value /= 6 and
  6540.                             Trraf_Value > Valid_Value then
  6541.                            Valid_Value := Trraf_Value;
  6542.                          end if;
  6543.                          if Readf_Value /= Valid_Value then
  6544.                            Error_Message("READF",Bad_Field);
  6545.                          end if;
  6546.           end case;
  6547.       end if;
  6548.     exception
  6549.       when others  => Error_Message("REASF",Bad_Field);
  6550.     end;
  6551.     --
  6552.     --    if SECRF is reported, REASF must be reported on this card or be
  6553.     --    stored already in the database.
  6554.     --
  6555.     begin
  6556.       if Card_KF3.Secrf /= "   " then
  6557.         if Valid_Msg.Trtype = ADD and Card_KF3.Reasf = " " then
  6558.           Error_Message("REASF",Field_Required);
  6559.         elsif Valid_Msg.Trtype = CHANGE and Card_KF3.Reasf = " " then
  6560.           begin
  6561.             idm_command(idmrun,"return_readiness_f_reason $1");
  6562.             idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  6563.             idm_execute(idmrun);
  6564.             idm_fetch(idmrun);
  6565.             idm_column(idmrun,1,Working_String(1..1),Length_of_String);
  6566.             if Working_String(1..1) = " " then
  6567.               Error_Message("REASF",Field_Required);
  6568.             end if;
  6569.           exception
  6570.             when others  =>
  6571.               Error_Message("TERRN",Can_Not_Validate_Correctly);
  6572.           end;
  6573.         end if;
  6574.         if Valid_Msg.Trtype = CHANGE and Card_KF3.Secrf = "#  " then
  6575.           null;
  6576.         else
  6577.           Secrn_Type := Prres_Types'value(Card_KF3.Secrf);
  6578.         end if;
  6579.       end if;
  6580.     exception
  6581.       when others  => Error_Message("SECRF",Bad_Field);
  6582.     end;
  6583.     --
  6584.     --    if TERRF is reported, REASF and SECRF must be reported on this
  6585.     --    card or be stored already in the database.  TERRF must not be
  6586.     --    equal to SECRF.
  6587.     --
  6588.     begin
  6589.       if Card_KF3.Terrf /= "   " then
  6590.         if Valid_Msg.Trtype = ADD then
  6591.           if Card_KF3.Reasf = " " then
  6592.             Error_Message("REASF",Field_Required);
  6593.           end if;
  6594.           if Card_KF3.Secrf = "   " then
  6595.             Error_Message("SECRF",Field_Required);
  6596.           end if;
  6597.         elsif Valid_Msg.Trtype = CHANGE then
  6598.           begin
  6599.             Working_String := "          ";
  6600.             if Card_KF3.Secrf = " " then
  6601.               idm_command(idmrun,"return_readiness_f_reason2 $1");
  6602.               idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  6603.               idm_execute(idmrun);
  6604.               idm_fetch(idmrun);
  6605.              idm_column(idmrun,1,Working_String(1..1),Length_of_String);
  6606.               if Working_String(1..1) = " " then
  6607.                 Error_Message("SECRF",Field_Required);
  6608.               else
  6609.                 Secrn_Type := Prres_Types'value(Working_String);
  6610.               end if;
  6611.             end if;
  6612.             if Card_KF3.Reasf = " " then
  6613.               idm_command(idmrun,"return_readiness_f_reason $1");
  6614.               idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  6615.               idm_execute(idmrun);
  6616.               idm_fetch(idmrun);
  6617.              idm_column(idmrun,1,Working_String(1..1),Length_of_String);
  6618.               if Working_String(1..1) = " " then
  6619.                 Error_Message("REASF",Field_Required);
  6620.               end if;
  6621.             end if;
  6622.           exception
  6623.             when others  =>
  6624.               Error_Message("TERRF",Can_Not_Validate_Correctly);
  6625.           end;
  6626.         end if;
  6627.         if Valid_Msg.Trtype = CHANGE and Card_KF3.Terrf = "#  " then
  6628.           null;
  6629.         else
  6630.           Terrn_Type    := Prres_Types'value(Card_KF3.Terrf);
  6631.           if Terrn_Type = Secrn_Type then
  6632.             Error_Message("TERRF",Bad_Field);
  6633.           end if;
  6634.         end if;
  6635.       end if;
  6636.     exception
  6637.       when others  => Error_Message("TERRF",Bad_Field);
  6638.     end;
  6639.     --
  6640.     --
  6641.     --    CARAF and CADAF are mutually inclusive. these fields can be
  6642.     --    "#" when transaction is Change
  6643.     --
  6644.     if (Card_KF3.Caraf = " " and Card_KF3.Cadaf.YY &
  6645.         Card_KF3.Cadaf.MM & Card_KF3.Cadaf.DD = "      ") or
  6646.        (Valid_Msg.Trtype = CHANGE and
  6647.         Card_KF3.Caraf = "#" and Card_KF3.Cadaf.YY &
  6648.         Card_KF3.Cadaf.MM & Card_KF3.Cadaf.DD = "#     ") then
  6649.       null;
  6650.     elsif Card_KF3.Caraf = " " then
  6651.       Error_Message("CARAF",Field_Required);
  6652.     elsif Card_KF3.Cadaf.YY &
  6653.           Card_KF3.Cadaf.MM & Card_KF3.Cadaf.DD = "      " then
  6654.       Error_Message("CADAF",Field_Required);
  6655.     else
  6656.     --
  6657.     --    if CARAF is reported, must equal 1 2 3 4 5 6 and not be equal to
  6658.     --    READF
  6659.     --
  6660.       Valid_Value := string_to_integer(Card_KF3.Caraf);
  6661.       if Valid_Value not in 1..6 or Card_KF3.Caraf = Card_KF3.Readf then
  6662.         Error_Message("CARAF",Bad_Field);
  6663.       end if;
  6664.     --
  6665.     --    if CADAF is reported, it must be > the header date
  6666.     --
  6667.       if Card_KF3.Cadaf.YY &
  6668.          Card_KF3.Cadaf.MM & Card_KF3.Cadaf.DD <= Header_Date then
  6669.         Error_Message("CADAF",Bad_Field);
  6670.       else
  6671.         Validate_YYMMDD(Card_KF3.Cadaf.YY,
  6672.                         Card_KF3.Cadaf.MM,
  6673.                         Card_KF3.Cadaf.DD,
  6674.                         "CADAF");
  6675.       end if;
  6676.     end if;
  6677.     --
  6678.     if Card_KF3.Limf /= " " then
  6679.       if Valid_Msg.Trtype = CHANGE and Card_KF3.Limf = "#" then
  6680.         null;
  6681.       else
  6682.         Valid_Value := string_to_integer(Card_KF3.Limf);
  6683.         if Valid_Value not in 1..6 or
  6684.            Card_KF3.Limf = Card_KF3.Readf then
  6685.           Error_Message("LIMF ",Bad_Field);
  6686.         end if;
  6687.       end if;
  6688.     end if;
  6689.     --
  6690.     begin
  6691.       if Card_KF3.Rlimf /= " " then
  6692.         if Valid_Msg.Trtype = CHANGE and Card_KF3.Rlimf = "#" then
  6693.           null;
  6694.         else
  6695.           Rlim_Type := Rlim_Types'value(Card_KF3.Rlimf);
  6696.         end if;
  6697.       end if;
  6698.     exception
  6699.       when others  => Error_Message("RLIMF",Bad_Field);
  6700.     end;
  6701.     --
  6702.     Validate_YYMMDD(Card_KF3.Ricdf.YY,
  6703.                     Card_KF3.Ricdf.MM,
  6704.                     Card_KF3.Ricdf.DD,
  6705.                     "RICDF");
  6706.     --
  6707.     --    if RESPF is reported it is validated the same as TREAD of 
  6708.     --    card type K except POMCS is not a valid code.
  6709.     --
  6710.     begin
  6711.       if Card_KF3.Respf /= "     " then
  6712.         if Valid_Msg.Trtype = CHANGE and Card_KF3.Respf = "#    " then
  6713.           null;
  6714.         elsif Card_KF3.Respf(3..5) = "HRS" then
  6715.           Valid_Value := string_to_integer(Card_KF3.Respf(1..2));
  6716.           if Valid_Value not in 1..72 then
  6717.             raise constraint_error;
  6718.           end if;
  6719.         else
  6720.           Tread_Type  := Tread_Types'value(Card_KF3.Respf);
  6721.           if Tread_Type = POMCS then
  6722.             raise constraint_error;
  6723.           end if;
  6724.         end if;
  6725.       end if;
  6726.     exception
  6727.       when others  => Error_Message("RESPF",Bad_Field);
  6728.     end;
  6729.     --
  6730.     --    if card is valid, place access pointer in message list and
  6731.     --    set up new access pointer for message list
  6732.     --
  6733.     if not Bad_Message then
  6734.       Valid_Msg.access_kf3 := Card_KF3;
  6735.       Link_List;
  6736.     end if;
  6737.  
  6738.   end Process_Card_KF3;
  6739.  
  6740.  
  6741. --**********************************************************************
  6742. --
  6743. --      This procedure does the processing for the validation of the
  6744. --    fields of a "KF4" card.
  6745. --
  6746. --**********************************************************************
  6747.  
  6748.   procedure Process_Card_KF4 is
  6749.  
  6750.   begin
  6751.     --
  6752.     --    set up new access pointer for card KF4
  6753.     --
  6754.     Card_KF4 := new Card_Type_KF4;
  6755.     --
  6756.     --    place strings in field components
  6757.     --
  6758.     Card_KF4.Smcc1        := Input_Msg.card(15..16);
  6759.     Card_KF4.Smra1        := Input_Msg.card(17..18);
  6760.     Card_KF4.Smaa1        := Input_Msg.card(19..20);
  6761.     Card_KF4.Smrc1        := Input_Msg.card(21..22);
  6762.     Card_KF4.Smac1        := Input_Msg.card(23..24);
  6763.     Card_KF4.Smcc2        := Input_Msg.card(25..26);
  6764.     Card_KF4.Smra2        := Input_Msg.card(27..28);
  6765.     Card_KF4.Smaa2        := Input_Msg.card(29..30);
  6766.     Card_KF4.Smrc2        := Input_Msg.card(31..32);
  6767.     Card_KF4.Smac2        := Input_Msg.card(33..34);
  6768.     Card_KF4.Smcc3        := Input_Msg.card(35..36);
  6769.     Card_KF4.Smra3        := Input_Msg.card(37..38);
  6770.     Card_KF4.Smaa3        := Input_Msg.card(39..40);
  6771.     Card_KF4.Smrc3        := Input_Msg.card(41..42);
  6772.     Card_KF4.Smac3        := Input_Msg.card(43..44);
  6773.     Card_KF4.Smcc4        := Input_Msg.card(45..46);
  6774.     Card_KF4.Smra4        := Input_Msg.card(47..48);
  6775.     Card_KF4.Smaa4        := Input_Msg.card(49..50);
  6776.     Card_KF4.Smrc4        := Input_Msg.card(51..52);
  6777.     Card_KF4.Smac4        := Input_Msg.card(53..54);
  6778.     Card_KF4.Gccla        := Input_Msg.card(55..56);
  6779.     Card_KF4.Gcclb        := Input_Msg.card(57..58);
  6780.     Card_KF4.Gcclc        := Input_Msg.card(59..60);
  6781.     Card_KF4.Spclu        := Input_Msg.card(61..69);
  6782.     --
  6783.     --    if SMCC1 is reported, all others fields of the group must be
  6784.     --    reported
  6785.     --
  6786.     if Card_KF4.Smcc1 /= "  " then
  6787.       Valid_Value := string_to_integer(Card_KF4.Smcc1);
  6788.       if Valid_Value not in 1..37 then
  6789.         Error_Message("SMCC1",Bad_Field);
  6790.       end if;
  6791.       Validate_Numeric(Card_KF4.Smra1,"SMRA1");
  6792.       Validate_Numeric(Card_KF4.Smaa1,"SMAA1");
  6793.       Validate_Numeric(Card_KF4.Smrc1,"SMRC1");
  6794.       Validate_Numeric(Card_KF4.Smac1,"SMAC1");
  6795.     else
  6796.       if Card_KF4.Smra1 /= "  " or Card_KF4.Smaa1 /= "  " or
  6797.          Card_KF4.Smrc1 /= "  " or Card_KF4.Smac1 /= "  " then
  6798.         Error_Message("SMCC1",Field_Required);
  6799.       end if;
  6800.     end if;
  6801.     --
  6802.     --    if SMCC2 is reported, all others fields of the group must be
  6803.     --    reported unless SMCC2 is "# " and transaction is Change.
  6804.     --
  6805.     if Card_KF4.Smcc2 /= "  " then
  6806.       if Valid_Msg.Trtype = CHANGE and Card_KF4.Smcc2 = "# " then
  6807.         null;
  6808.       else
  6809.         Valid_Value := string_to_integer(Card_KF4.Smcc2);
  6810.         if Valid_Value not in 1..37 then
  6811.           Error_Message("SMCC2",Bad_Field);
  6812.         end if;
  6813.         Validate_Numeric(Card_KF4.Smra2,"SMRA2");
  6814.         Validate_Numeric(Card_KF4.Smaa2,"SMAA2");
  6815.         Validate_Numeric(Card_KF4.Smrc2,"SMRC2");
  6816.         Validate_Numeric(Card_KF4.Smac2,"SMAC2");
  6817.       end if;
  6818.     else
  6819.       if Card_KF4.Smra2 /= "  " or Card_KF4.Smaa2 /= "  " or
  6820.          Card_KF4.Smrc2 /= "  " or Card_KF4.Smac2 /= "  " then
  6821.         Error_Message("SMCC2",Field_Required);
  6822.       end if;
  6823.     end if;
  6824.     --
  6825.     --    if SMCC3 is reported, all others fields of the group must be
  6826.     --    reported unless SMCC3 is "# " and transaction is Change.
  6827.     --
  6828.     if Card_KF4.Smcc3 /= "  " then
  6829.       if Valid_Msg.Trtype = CHANGE and Card_KF4.Smcc3 = "# " then
  6830.         null;
  6831.       else
  6832.         Valid_Value := string_to_integer(Card_KF4.Smcc3);
  6833.         if Valid_Value not in 1..37 then
  6834.           Error_Message("SMCC3",Bad_Field);
  6835.         end if;
  6836.         Validate_Numeric(Card_KF4.Smra3,"SMRA3");
  6837.         Validate_Numeric(Card_KF4.Smaa3,"SMAA3");
  6838.         Validate_Numeric(Card_KF4.Smrc3,"SMRC3");
  6839.         Validate_Numeric(Card_KF4.Smac3,"SMAC3");
  6840.       end if;
  6841.     else
  6842.       if Card_KF4.Smra3 /= "  " or Card_KF4.Smaa3 /= "  " or
  6843.          Card_KF4.Smrc3 /= "  " or Card_KF4.Smac3 /= "  " then
  6844.         Error_Message("SMCC3",Field_Required);
  6845.       end if;
  6846.     end if;
  6847.     --
  6848.     --    if SMCC4 is reported, all others fields of the group must be
  6849.     --    reported unless SMCC4 is "# " and transaction is Change.
  6850.     --
  6851.     if Card_KF4.Smcc4 /= "  " then
  6852.       if Valid_Msg.Trtype = CHANGE and Card_KF4.Smcc4 = "# " then
  6853.         null;
  6854.       else
  6855.         Valid_Value := string_to_integer(Card_KF4.Smcc4);
  6856.         if Valid_Value not in 1..37 then
  6857.           Error_Message("SMCC4",Bad_Field);
  6858.         end if;
  6859.         Validate_Numeric(Card_KF4.Smra4,"SMRA4");
  6860.         Validate_Numeric(Card_KF4.Smaa4,"SMAA4");
  6861.         Validate_Numeric(Card_KF4.Smrc4,"SMRC4");
  6862.         Validate_Numeric(Card_KF4.Smac4,"SMAC4");
  6863.       end if;
  6864.     else
  6865.       if Card_KF4.Smra4 /= "  " or Card_KF4.Smaa4 /= "  " or
  6866.          Card_KF4.Smrc4 /= "  " or Card_KF4.Smac4 /= "  " then
  6867.         Error_Message("SMCC4",Field_Required);
  6868.       end if;
  6869.     end if;
  6870.     --
  6871.     --    the fields for Graduated Combat Capability Levels must be
  6872.     --    reported successively: GCCLA before GCCLB, and both GCCLA
  6873.     --    and GCCLB before GCCLC.
  6874.     --
  6875.     if Card_KF4.Gccla = "  " then
  6876.       if Card_KF4.Gcclb /= "  " then
  6877.         Error_Message("GCCLB",Bad_Field);
  6878.       end if;
  6879.       if Card_KF4.Gcclc /= "  " then
  6880.         Error_Message("GCCLC",Bad_Field);
  6881.       end if;
  6882.     elsif Card_KF4.Gccla = "# " and Valid_Msg.Trtype /= CHANGE then
  6883.       Error_Message("GCCLA",Bad_Field);
  6884.     else
  6885.       if Card_KF4.Gccla /= "# " then
  6886.         Validate_Numeric(Card_KF4.Gccla,"GCCLA");
  6887.       end if;
  6888.       if Card_KF4.Gcclb = "  " then
  6889.         if Card_KF4.Gcclc /= "  " then
  6890.           Error_Message("GCCLC",Bad_Field);
  6891.         end if;
  6892.       elsif Card_KF4.Gcclb = "# " and Valid_Msg.Trtype /= CHANGE then
  6893.         Error_Message("GCCLB",Bad_Field);
  6894.       else
  6895.         if Card_KF4.Gcclb /= "# " then
  6896.           Validate_Numeric(Card_KF4.Gcclb,"GCCLB");
  6897.         end if;
  6898.         if Card_KF4.Gcclc = "  " then
  6899.           null;
  6900.         elsif Card_KF4.Gcclc = "# " and Valid_Msg.Trtype /= CHANGE then
  6901.           Error_Message("GCCLC",Bad_Field);
  6902.         else
  6903.           if Card_KF4.Gcclc /= "# " then
  6904.             Validate_Numeric(Card_KF4.Gcclc,"GCCLC");
  6905.           end if;
  6906.         end if;
  6907.       end if;
  6908.     end if;
  6909.     --
  6910.     if Valid_Msg.Trtype /= CHANGE and Card_KF4.Spclu = "#        " then
  6911.       Error_Message("SPCLU",Bad_Field);
  6912.     end if;
  6913.     --
  6914.     --    if card is valid, place access pointer in message list and
  6915.     --    set up new access pointer for message list
  6916.     --
  6917.     if not Bad_Message then
  6918.       Valid_Msg.access_kf4 := Card_KF4;
  6919.       Link_List;
  6920.     end if;
  6921.  
  6922.   end Process_Card_KF4;
  6923.  
  6924.  
  6925. --**********************************************************************
  6926. --
  6927. --      This procedure does the processing for the validation of the
  6928. --    fields of a "KN1" card.
  6929. --
  6930. --**********************************************************************
  6931.  
  6932.   procedure Process_Card_KN1 is
  6933.  
  6934.   begin
  6935.     --
  6936.     --    set up new access pointer for card KN1
  6937.     --
  6938.     Card_KN1 := new Card_Type_KN1;
  6939.     --
  6940.     --    validate and convert PRMA
  6941.     --
  6942.     begin
  6943.       Working_String       := "          ";
  6944.       Working_String(1..5) := Input_Msg.card(15..19);
  6945.       Card_KN1.Prma        := Prma_Types'value(Working_String);
  6946.     exception
  6947.       when others  => Error_Message("PRMA ",Bad_Field);
  6948.     end;
  6949.     --
  6950.     --    place strings in field components
  6951.     --
  6952.     Card_KN1.Marat        := Input_Msg.card(20..20);
  6953.     Card_KN1.Marea        := Input_Msg.card(21..23);
  6954.     Card_KN1.Chdat.YY     := Input_Msg.card(24..25);
  6955.     Card_KN1.Chdat.MM     := Input_Msg.card(26..27);
  6956.     Card_KN1.Chdat.DD     := Input_Msg.card(28..29);
  6957.     Card_KN1.Fmart        := Input_Msg.card(30..30);
  6958.     Card_KN1.Fcdat.YY     := Input_Msg.card(31..32);
  6959.     Card_KN1.Fcdat.MM     := Input_Msg.card(33..34);
  6960.     Card_KN1.Fcdat.DD     := Input_Msg.card(35..36);
  6961.     --
  6962.     --    if MARAT is reported, it must be 1 2 3 4 5 6. MAREA is required
  6963.     --    to be reported when MARAT is 2 3 4 and must be blank when MARAT
  6964.     --    is 1 5 6.
  6965.     --
  6966.     begin
  6967.       if Card_KN1.Marat /= " " then
  6968.         Valid_Value := string_to_integer(Card_KN1.Marat);
  6969.         if Valid_Value not in 1..6 then
  6970.           Error_Message("MARAT",Bad_Field);
  6971.         end if;
  6972.         if Valid_Value in 2..4 then
  6973.           Marea_Type   := Prres_Types'value(Card_KN1.Marea);
  6974.         elsif Card_KN1.Marea /= "   " then
  6975.           raise constraint_error;
  6976.         end if;
  6977.       end if;
  6978.     exception
  6979.       when others  => Error_Message("MAREA",Bad_Field);
  6980.     end;
  6981.     --
  6982.     --    if CHDAT is not reported, use the system date
  6983.     --
  6984.     if Card_KN1.Chdat.YY = "  " and
  6985.        Card_KN1.Chdat.MM = "  " and
  6986.        Card_KN1.Chdat.DD = "  " then
  6987.       Card_KN1.Chdat.DD := "00";
  6988.       if System_Day < 10 then
  6989.         Working_String(1..2)    := integer'image(System_Day);
  6990.         Card_KN1.Chdat.DD(2..2) := Working_String(2..2);
  6991.       else
  6992.         Working_String(1..3) := integer'image(System_Day);
  6993.         Card_KN1.Chdat.DD    := Working_String(2..3);
  6994.       end if;
  6995.       Card_KN1.Chdat.MM := "00";
  6996.       if System_Month < 10 then
  6997.         Working_String(1..2)    := integer'image(System_Month);
  6998.         Card_KN1.Chdat.MM(2..2) := Working_String(2..2);
  6999.       else
  7000.         Working_String(1..3) := integer'image(System_Month);
  7001.         Card_KN1.Chdat.MM    := Working_String(2..3);
  7002.       end if;
  7003.       Working_String(1..5) := integer'image(System_Year);
  7004.       Card_KN1.Chdat.YY    := Working_String(4..5);
  7005.     else
  7006.       Validate_YYMMDD(Card_KN1.Chdat.YY,
  7007.                       Card_KN1.Chdat.MM,
  7008.                       Card_KN1.Chdat.DD,
  7009.                       "CHDAT");
  7010.     end if;
  7011.     --
  7012.     --    FCDAT and FMART are mutually inclusive.  FMART must not be equal
  7013.     --    to MARAT.  FCDAT must be > Header date.
  7014.     --
  7015.     if Valid_Msg.Trtype = CHANGE and Card_KN1.Fmart = "#" and
  7016.        Card_KN1.Fcdat.YY &
  7017.        Card_KN1.Fcdat.MM & Card_KN1.Fcdat.DD = "#     " then
  7018.       null;
  7019.     elsif Card_KN1.Fmart /= " " or
  7020.           Card_KN1.Fcdat.YY /= "  " or
  7021.           Card_KN1.Fcdat.MM /= "  " or
  7022.           Card_KN1.Fcdat.DD /= "  " then
  7023.          Valid_Value := string_to_integer(Card_KN1.Fmart);
  7024.          if Valid_Value not in 1..6 or
  7025.             Card_KN1.Fmart = Card_KN1.Marat then
  7026.            Error_Message("FMART",Bad_Field);
  7027.          end if;
  7028.          if Card_KN1.Fcdat.YY = "  " and
  7029.             Card_KN1.Fcdat.MM = "  " and
  7030.             Card_KN1.Fcdat.DD = "  " then
  7031.            Error_Message("FCDAT",Bad_Field);
  7032.          end if;
  7033.          Validate_YYMMDD(Card_KN1.Fcdat.YY,
  7034.                          Card_KN1.Fcdat.MM,
  7035.                          Card_KN1.Fcdat.DD,
  7036.                          "FCDAT");
  7037.          if Card_KN1.Fcdat.YY &
  7038.             Card_KN1.Fcdat.MM & Card_KN1.Fcdat.DD < Header_Date then
  7039.            Error_Message("FCDAT",Bad_Field);
  7040.          end if;
  7041.        end if;
  7042.     --
  7043.     --    if card is valid, place access pointer in message list and
  7044.     --    set up new access pointer for message list
  7045.     --
  7046.     if not Bad_Message then
  7047.       Valid_Msg.access_kn1 := Card_KN1;
  7048.       Link_List;
  7049.     end if;
  7050.  
  7051.   end Process_Card_KN1;
  7052.  
  7053.  
  7054. --**********************************************************************
  7055. --
  7056. --      This procedure does the processing for the validation of the
  7057. --    fields of a "TF1" card.
  7058. --
  7059. --**********************************************************************
  7060.  
  7061.   procedure Process_Card_TF1 is
  7062.  
  7063.   begin
  7064.     --
  7065.     --    set up new access pointer for card TF1
  7066.     --
  7067.     Card_TF1 := new Card_Type_TF1;
  7068.     --
  7069.     --    place strings in field components
  7070.     --
  7071.     Card_TF1.Ueqpt        := Input_Msg.card(15..25);
  7072.     Card_TF1.Mesen        := Input_Msg.card(26..29);
  7073.     Card_TF1.Meqs         := Input_Msg.card(30..30);
  7074.     Card_TF1.Sedy         := Input_Msg.card(31..31);
  7075.     Card_TF1.Tedy         := Input_Msg.card(32..32);
  7076.     Card_TF1.Erddy.YY     := Input_Msg.card(33..34);
  7077.     Card_TF1.Erddy.MM     := Input_Msg.card(35..36);
  7078.     Card_TF1.Erddy.DD     := Input_Msg.card(37..38);
  7079.     Card_TF1.Avail        := Input_Msg.card(39..39);
  7080.     Card_TF1.Dcndy        := Input_Msg.card(40..44);
  7081.     Card_TF1.Eqret.YY     := Input_Msg.card(45..46);
  7082.     Card_TF1.Eqret.MM     := Input_Msg.card(47..48);
  7083.     Card_TF1.Eqret.DD     := Input_Msg.card(49..50);
  7084.     Card_TF1.Geogr        := Input_Msg.card(51..54);
  7085.     Card_TF1.Operl.YY     := Input_Msg.card(55..56);
  7086.     Card_TF1.Operl.MM     := Input_Msg.card(57..58);
  7087.     Card_TF1.Operl.DD     := Input_Msg.card(59..60);
  7088.     Card_TF1.Dafld        := Input_Msg.card(63..66);
  7089.     --
  7090.     --    UEQPT is required to be reported and will be validated against an
  7091.     --    IDM database relation MEQPT.
  7092.     --
  7093.     if Card_TF1.Ueqpt = "           " then
  7094.       Error_Message("UEQPT",Field_Required);
  7095.     else
  7096.       Validate_Meqpt(Card_TF1.Ueqpt,"UEQPT");
  7097.     end if;
  7098.     --
  7099.     --    MESEN is required to be reported
  7100.     --
  7101.     if Card_TF1.Mesen = "    " then
  7102.       Error_Message("MESEN",Field_Required);
  7103.     end if;
  7104.     --
  7105.     --    if MEQS is reported validate against the meqs table and
  7106.     --    if MEQS is not equal to "X" or "Z" then OPERL must be reported
  7107.     --
  7108.     begin
  7109.       if Card_TF1.Meqs /= " " then
  7110.         Meqs_Type    := Meqs_Types'value(Card_TF1.Meqs);
  7111.         case Meqs_Type is
  7112.           when X | Z  => null;
  7113.           when others => if Card_TF1.Operl.YY &
  7114.                             Card_TF1.Operl.MM &
  7115.                             Card_TF1.Operl.DD = "      " then
  7116.                            Error_Message("OPERL",Field_Required);
  7117.                          end if;
  7118.         end case;
  7119.       end if;
  7120.     exception
  7121.       when others  => Error_Message("MEQS ",Bad_Field);
  7122.     end;
  7123.     --
  7124.     --    SEDY, when reported, must be 0 5 7 9 A B C F I J M N R V W Y Z X
  7125.     --
  7126.     begin
  7127.       if Card_TF1.Sedy /= " " then
  7128.         Valid_Value := string_to_integer(Card_TF1.Sedy);
  7129.         if Valid_Value = 0 or Valid_Value = 5 or
  7130.            Valid_Value = 7 or Valid_Value = 9 then
  7131.           null;
  7132.         else
  7133.           Sedy_Type  := Sedy_Types'value(Card_TF1.Sedy);
  7134.         end if;
  7135.       end if;
  7136.     exception
  7137.       when others  => Error_Message("SEDY ",Bad_Field);
  7138.     end;
  7139.     --
  7140.     --    if TEDY is reported, validate against the table
  7141.     --    if TEDY is not equal to "X" or "Z" then ERDDY must be reported
  7142.     --
  7143.     begin
  7144.       if Card_TF1.Tedy /= " " then
  7145.         Tedy_Type    := Tedy_Types'value(Card_TF1.Tedy);
  7146.         case Tedy_Type is
  7147.           when X | Z  => null;
  7148.           when others => if Card_TF1.Erddy.YY &
  7149.                             Card_TF1.Erddy.MM &
  7150.                             Card_TF1.Erddy.DD = "      " then
  7151.                            Error_Message("ERDDY",Field_Required);
  7152.                          end if;
  7153.         end case;
  7154.       end if;
  7155.     exception
  7156.       when others  => Error_Message("TEDY ",Bad_Field);
  7157.     end;
  7158.     --
  7159.     Validate_YYMMDD(Card_TF1.Erddy.YY,
  7160.                     Card_TF1.Erddy.MM,
  7161.                     Card_TF1.Erddy.DD,
  7162.                     "ERDDY");
  7163.     --
  7164.     --    if AVAIL is reported, validate against AVAIL table.  if reported
  7165.     --    as "C" or "D" then DCNDY must be reported.
  7166.     --
  7167.     begin
  7168.       if Card_TF1.Avail /= " " then
  7169.         Avail_Type   := Avail_Types'value(Card_TF1.Avail);
  7170.         if (Avail_Type = C or
  7171.             Avail_Type = D) and Card_TF1.Dcndy = "     " then
  7172.           Error_Message("DCNDY",Field_Required);
  7173.         end if;
  7174.       end if;
  7175.     exception
  7176.       when others  => Error_Message("AVAIL",Bad_Field);
  7177.     end;
  7178.     --
  7179.     if Card_TF1.Eqret.YY &
  7180.        Card_TF1.Eqret.MM & Card_TF1.Eqret.DD = "#     " and
  7181.        Valid_Msg.Trtype = CHANGE then
  7182.       null;
  7183.     else
  7184.       Validate_YYMMDD(Card_TF1.Eqret.YY,
  7185.                       Card_TF1.Eqret.MM,
  7186.                       Card_TF1.Eqret.DD,
  7187.                       "EQRET");
  7188.     end if;
  7189.     --
  7190.     --    if GEOGR is reported, it will be validated against an IDM
  7191.     --    database relation Geolocation database.
  7192.     --
  7193.     if Card_TF1.Geogr = "#   " and Valid_Msg.Trtype /= CHANGE then
  7194.       Error_Message("GEOGR",Bad_Field);
  7195.     else
  7196.       Validate_Geolocation(Card_TF1.Geogr,"GEOGR");
  7197.     end if;
  7198.     --
  7199.     --    if OPERL is reported it must be >= the header date
  7200.     --
  7201.     if Card_TF1.Operl.YY &
  7202.        Card_TF1.Operl.MM & Card_TF1.Operl.DD /= "      " then
  7203.       if Card_TF1.Operl.YY &
  7204.          Card_TF1.Operl.MM & Card_TF1.Operl.DD < Header_Date then
  7205.         Error_Message("OPERL",Bad_Field);
  7206.       else
  7207.         Validate_YYMMDD(Card_TF1.Operl.YY,
  7208.                         Card_TF1.Operl.MM,
  7209.                         Card_TF1.Operl.DD,
  7210.                         "OPERL");
  7211.       end if;
  7212.     end if;
  7213.     --
  7214.     if Card_TF1.Dafld = "#   " and Valid_Msg.Trtype /= CHANGE then
  7215.       Error_Message("DALFD",Bad_Field);
  7216.     end if;
  7217.     --
  7218.     --    if card is valid, place access pointer in message list and
  7219.     --    set up new access pointer for message list
  7220.     --
  7221.     if not Bad_Message then
  7222.       Valid_Msg.access_tf1 := Card_TF1;
  7223.       Link_List;
  7224.     end if;
  7225.  
  7226.   end Process_Card_TF1;
  7227.  
  7228.  
  7229. --**********************************************************************
  7230. --
  7231. --      This procedure does the processing for the validation of the
  7232. --    fields of a "E  " card.
  7233. --
  7234. --**********************************************************************
  7235.  
  7236.   procedure Process_Card_E is
  7237.  
  7238.   begin
  7239.     --
  7240.     --    set up new access pointer for card E
  7241.     --
  7242.     Card_E := new Card_Type_E;
  7243.     --
  7244.     --    place card sequence number in card number field
  7245.     --
  7246.     Valid_Msg.Card_Number := Seq_Number;
  7247.     --
  7248.     --    validate and convert security classification
  7249.     --
  7250.     begin
  7251.       Working_String          := "          ";
  7252.       Working_String(1..1)    := Input_Msg.card(4..4);
  7253.       Valid_Msg.Secur         := Secur_Types'value(Working_String);
  7254.     exception
  7255.       when others  => Error_Message("SECUR",Bad_Field);
  7256.     end;
  7257.     --
  7258.     --    if card is valid place access pointer in message list and
  7259.     --    set access pointer for message list to null and queue message
  7260.     --    to DBB module
  7261.     --
  7262.     if not Bad_Message then
  7263.       Valid_Msg.access_e  := Card_E;
  7264.       Valid_Msg.next      := null;
  7265.       Valid_Message;
  7266.     end if;
  7267.  
  7268.   end Process_Card_E;
  7269.  
  7270.  
  7271. --**********************************************************************
  7272. --
  7273. --      This procedure will notify the MMI of invalid
  7274. --    UNITREP messages
  7275. --
  7276. --**********************************************************************
  7277.   procedure Invalid_Unitrep_Message is
  7278.  
  7279.   begin
  7280.  
  7281.    tpsend(mv_id,mmi_id,invalid_message,First_Input_Msg,tp2,tp3,tp4,tp5);
  7282.    tpsend(mv_id,mmi_id,invalid_message,First_Error_Msg,tp2,tp3,tp4,tp5);
  7283.  
  7284.     if Terminate_Module_Flag and Last_Message = -1 then
  7285.       tpsend(mv_id,dbb_id,validated_data,tp1,Last_Message_String,tp3,
  7286.              tp4,tp5);
  7287.       tpsend(mv_id,mmi_id,module_terminated,tp1,tp2,tp3,tp4,tp5);
  7288.       task_initialized := false;
  7289.     end if;
  7290.  
  7291.     Nbr_of_Invalid_Messages := Nbr_of_Invalid_Messages + 1;
  7292.  
  7293.   end Invalid_Unitrep_Message;
  7294.  
  7295.  
  7296. --**********************************************************************
  7297. --
  7298. --      This procedure will queue validated messages to DBB
  7299. --
  7300. --**********************************************************************
  7301.  
  7302.   procedure Valid_Message is
  7303.  
  7304.   begin
  7305.  
  7306.     if Terminate_Module_Flag and Last_Message = -1 then
  7307.       tpsend(mv_id,dbb_id,validated_data,tp1,Last_Message_String,tp3,
  7308.              tp4,First_Valid_Msg.Next);
  7309.       tpsend(mv_id,mmi_id,module_terminated,tp1,tp2,tp3,tp4,tp5);
  7310.       task_initialized := false;
  7311.     else
  7312.       tpsend(mv_id,dbb_id,validated_data,tp1,tp2,tp3,tp4,
  7313.              First_Valid_Msg.Next);
  7314.     end if;
  7315.  
  7316.     Nbr_of_Valid_Messages := Nbr_of_Valid_Messages + 1;
  7317.  
  7318.   end Valid_Message;
  7319.  
  7320.  
  7321. --**********************************************************************
  7322. --
  7323. --      This procedure processes the "send statistics" request by
  7324. --    sending two packets to the MMI.  The first one sends Invalid
  7325. --    Message count; the second sends Valid Message count.
  7326. --
  7327. --**********************************************************************
  7328.  
  7329.   procedure Send_Stats is
  7330.  
  7331.   begin
  7332.  
  7333.     Tmp_Text_Type(1..34) := "Number of Invalid UNITREP Messages";
  7334.     tpsend(mv_id,mmi_id,statistics,tp1,Tmp_Text_Type,
  7335.            Nbr_of_Invalid_Messages,tp4,tp5);
  7336.  
  7337.     Tmp_Text_Type(1..34) := "Number of Valid UNITREP Messages  ";
  7338.     tpsend(mv_id,mmi_id,statistics,tp1,Tmp_Text_Type,
  7339.            Nbr_of_Valid_Messages,tp4,tp5);
  7340.  
  7341.   end Send_Stats;
  7342.  
  7343.  
  7344. --**********************************************************************
  7345. --
  7346. --      This procedure gets and stores the system date using functions
  7347. --    of the predefined package CALENDAR.
  7348. --
  7349. --**********************************************************************
  7350.  
  7351.   procedure Get_and_Store_System_Date is
  7352.  
  7353.   begin
  7354.     System_Time  := clock;
  7355.     System_Year  := year(System_Time);
  7356.     System_Month := month(System_Time);
  7357.     System_Day   :=calendar.day(System_Time);
  7358.  
  7359.   end Get_and_Store_System_Date;
  7360.  
  7361.  
  7362. --**********************************************************************
  7363. --
  7364. --      This procedure updates the recursive access pointer list of
  7365. --    valid messages.
  7366. --
  7367. --**********************************************************************
  7368.  
  7369.   procedure Link_List is
  7370.  
  7371.   begin
  7372.     Valid_Msg.next := new Msg_List;
  7373.     Valid_Msg      := Valid_Msg.next;
  7374.  
  7375.   end Link_List;
  7376.  
  7377.  
  7378. --**********************************************************************
  7379. --
  7380. --      This procedure writes error messages into a buffer for display
  7381. --    to the operator.
  7382. --
  7383. --**********************************************************************
  7384.  
  7385.  
  7386.   procedure Error_Message(s : in string;
  7387.                           e : in Error_Msg_Types) is
  7388.  
  7389.   begin
  7390.     Bad_Message := true;
  7391.     case e is
  7392.       when Bad_Field          =>
  7393.         Error_Msg_Text(Bad_Field)(5..9)        := s;
  7394.         Error_Msg_Text(Bad_Field)(41..43)      :=
  7395.               integer_to_string(Seq_Number);
  7396.         Error_Msg.card                         :=
  7397.               Error_Msg_Text(Bad_Field);
  7398.       when Bad_Sequence       =>
  7399.         Error_Msg.card                         :=
  7400.               Error_Msg_Text(Bad_Sequence);
  7401.       when No_Header          =>
  7402.         Error_Msg.card                         :=
  7403.               Error_Msg_Text(No_Header);
  7404.       when No_End             =>
  7405.         Error_Msg.card                         :=
  7406.               Error_Msg_Text(No_End);
  7407.       when Field_Required     =>
  7408.         Error_Msg_Text(Field_Required)(1..5)   := s;
  7409.         Error_Msg_Text(Field_Required)(46..48) :=
  7410.               integer_to_string(Seq_Number);
  7411.         Error_Msg.card                         :=
  7412.               Error_Msg_Text(Field_Required);
  7413.       when Bad_Card_Type      =>
  7414.         Error_Msg_Text(Bad_Card_Type)(36..38)  :=
  7415.               integer_to_string(Seq_Number);
  7416.         Error_Msg.card                         :=
  7417.               Error_Msg_Text(Bad_Card_Type);
  7418.       when Mutually_Exclusive =>
  7419.         Error_Msg_Text(Mutually_Exclusive)(57..59) :=
  7420.               integer_to_string(Seq_Number);
  7421.         Error_Msg.card                     :=
  7422.               Error_Msg_Text(Mutually_Exclusive);
  7423.       when Can_Not_Validate_Correctly =>
  7424.         Error_Msg_Text(Can_Not_Validate_Correctly)(18..22) := s;
  7425.         Error_Msg_Text(Can_Not_Validate_Correctly)(64..66) :=
  7426.               integer_to_string(Seq_Number);
  7427.     end case;
  7428.  
  7429.     Error_Msg.next := new Msg_Card_List;
  7430.     Error_Msg      := Error_Msg.next;
  7431.  
  7432.   end Error_Message;
  7433.  
  7434.  
  7435. --**********************************************************************
  7436. --
  7437. --      This procedure validates the UIC.
  7438. --
  7439. --**********************************************************************
  7440.  
  7441.  
  7442.   procedure Validate_Uic(Uic : in string ;
  7443.                          Field_Name : in string) is
  7444.     Department : string(1..1);
  7445.     Nbr        : string(1..5);
  7446.     work_nbr   : string(1..1);
  7447.   begin
  7448.     Department := Uic(1..1);
  7449.     Nbr        := Uic(2..6);
  7450.     if Department = "D" then
  7451.       work_nbr             := Nbr(1..1);
  7452.       Uic2_Department_Type := Uic2_Department_Types'value(work_nbr);
  7453.       if Nbr(2..5) = "    " then
  7454.         raise constraint_error;
  7455.       else
  7456.         Validate_Numeric(Nbr(2..5),Field_Name);
  7457.       end if;
  7458.     else
  7459.       Department_Type := Department_Types'value(Department);
  7460.       if Nbr = "     " then
  7461.         raise constraint_error;
  7462.       else
  7463.         Validate_Numeric(Nbr,Field_Name);
  7464.       end if;
  7465.     end if;
  7466.  
  7467.     if Valid_Msg.Card_Type /= A and Invalid_Uic(Uic) then
  7468.       raise constraint_error;
  7469.     end if;
  7470.  
  7471.   exception
  7472.     when others  => Error_Message(Field_Name,Bad_Field);
  7473.   end Validate_Uic;
  7474.  
  7475.  
  7476. --**********************************************************************
  7477. --
  7478. --      This procedure validates a date in the format YYMMDD.
  7479. --
  7480. --**********************************************************************
  7481.  
  7482.  
  7483.   procedure Validate_YYMMDD(YY : in string ;
  7484.                             MM : in string ;
  7485.                             DD : in string ;
  7486.                             Field_Name : in string) is
  7487.  
  7488.   begin
  7489.     if YY /= "  " or
  7490.        MM /= "  " or
  7491.        DD /= "  " then
  7492.       Valid_Value := string_to_integer(YY);
  7493.       if Valid_Value < 0 then
  7494.         raise constraint_error;
  7495.       end if;
  7496.       Leap_Year := Valid_Value / 4;
  7497.       Leap_Year := Valid_Value - (Leap_Year * 4);
  7498.       if Leap_Year = 0 then
  7499.         Days_in_Month(2) := 29;
  7500.       else
  7501.         Days_in_Month(2) := 28;
  7502.       end if;
  7503.       Month_of_Year := string_to_integer(MM);
  7504.       if Month_of_Year not in 1..12 then
  7505.         raise constraint_error;
  7506.       end if;
  7507.       Valid_Value := string_to_integer(DD);
  7508.       if Valid_Value not in 1..Days_in_Month(Month_of_Year) then
  7509.         raise constraint_error;
  7510.       end if;
  7511.     end if;
  7512.  
  7513.   exception
  7514.     when others  => Error_Message(Field_Name,Bad_Field);
  7515.   end Validate_YYMMDD;
  7516.  
  7517.  
  7518. --**********************************************************************
  7519. --
  7520. --      This procedure validates a date in the format DDDYY.
  7521. --
  7522. --**********************************************************************
  7523.  
  7524.  
  7525.   procedure Validate_DDDYY(DDD : in string ;
  7526.                            YY  : in string ;
  7527.                            Field_Name : in string) is
  7528.  
  7529.   begin
  7530.     if DDD /= "   " or
  7531.        YY /= "  " then
  7532.       Valid_Value := string_to_integer(YY);
  7533.       if Valid_Value < 1 then
  7534.         raise constraint_error;
  7535.       end if;
  7536.       Leap_Year := Valid_Value / 4;
  7537.       Leap_Year := Valid_Value - (Leap_Year * 4);
  7538.       if Leap_Year = 0 then
  7539.         Days_in_Year := 366;
  7540.       else
  7541.         Days_in_Year := 365;
  7542.       end if;
  7543.       Valid_Value := string_to_integer(DDD);
  7544.       if Valid_Value not in 1..Days_in_Year then
  7545.         raise constraint_error;
  7546.       end if;
  7547.     end if;
  7548.  
  7549.   exception
  7550.     when others  => Error_Message(Field_Name,Bad_Field);
  7551.   end Validate_DDDYY;
  7552.  
  7553.  
  7554. --**********************************************************************
  7555. --
  7556. --      This procedure validates fields using the ORUIC table.
  7557. --
  7558. --**********************************************************************
  7559.  
  7560.  
  7561.   procedure Validate_Oruic(Oruic : in string ;
  7562.                            Field_Name : in string) is
  7563.  
  7564.   begin
  7565.     if Oruic /= "      " then
  7566.       Oruic_Type      := Oruic_Types'value(Oruic);
  7567.     end if;
  7568.  
  7569.   exception
  7570.     when others  => Error_Message(Field_Name,Bad_Field);
  7571.   end Validate_Oruic;
  7572.  
  7573.  
  7574. --**********************************************************************
  7575. --
  7576. --      This procedure validates fields that use the Unit Description Code.
  7577. --
  7578. --**********************************************************************
  7579.  
  7580.  
  7581.   procedure Validate_Udc(Udc : in string ;
  7582.                          Field_Name : in string) is
  7583.  
  7584.   begin
  7585.     Udc_Valid := true;
  7586.     if Udc /= " " then
  7587.       Valid_Value := string_to_integer(Udc);
  7588.       if Valid_Value < 0 then
  7589.         Udc_Type := Udc_Types'value(Udc);
  7590.       elsif Valid_Value > 9 then
  7591.         raise constraint_error;
  7592.       end if;
  7593.     end if;
  7594.  
  7595.   exception
  7596.     when others  => Error_Message(Field_Name,Bad_Field);
  7597.                     Udc_Valid := false;
  7598.   end Validate_Udc;
  7599.  
  7600.  
  7601. --**********************************************************************
  7602. --
  7603. --      This procedure validates fields that use the Unit Level Code.
  7604. --
  7605. --**********************************************************************
  7606.  
  7607.  
  7608.   procedure Validate_Ulc(Ulc : in string ;
  7609.                          Field_Name : in string) is
  7610.  
  7611.   begin
  7612.     if Ulc /= "   " then
  7613.       if Ulc /= "FOR" then
  7614.         Ulc_Type    := Ulc_Types'value(Ulc);
  7615.       end if;
  7616.     end if;
  7617.  
  7618.   exception
  7619.     when others  => Error_Message(Field_Name,Bad_Field);
  7620.   end Validate_Ulc;
  7621.  
  7622.  
  7623. --**********************************************************************
  7624. --
  7625. --      This procedure validates that a field is all numeric.
  7626. --
  7627. --**********************************************************************
  7628.  
  7629.  
  7630.   procedure Validate_Numeric(num : in string ;
  7631.                              Field_Name : in string) is
  7632.  
  7633.   begin
  7634.     working_string := "          ";
  7635.     if num(num'first..num'last) /=
  7636.        working_string(1..num'last-num'first+1) then
  7637.       for j in num'range
  7638.       loop
  7639.         if num(j) not in '0'..'9' then
  7640.           Error_Message(Field_Name,Bad_Field);
  7641.           exit;
  7642.         end if;
  7643.       end loop;
  7644.     end if;
  7645.  
  7646.   exception
  7647.     when others  => put_line("problem in validate numeric");
  7648.   end Validate_Numeric;
  7649.  
  7650.  
  7651. --**********************************************************************
  7652. --
  7653. --      This procedure validates a PIN field.
  7654. --
  7655. --      the field PIN (Plan Identification Number) in card types N,P,
  7656. --    Q, and T should be validated an follows:
  7657. --
  7658. --    (a) The first character MUST be one of the following:
  7659. --
  7660. --        0,1,2,3,4,5,6,7,8,9,A,B,D,E,F,G,H,K,L,M,N,P,R,S
  7661. --
  7662. --    (b) If the first character is numeric
  7663. --        -- the 2nd, 3rd, & 4th character must be numeric
  7664. --        -- the 5th character must not be numeric
  7665. --
  7666. --    (c) The first four characters may not be 0000  (because numeric
  7667. --        plan numbers are assigned beginning with plan 0001)
  7668. --
  7669. --    (d) The field may not contain embedded blanks.
  7670. --    (e) The field may not contain non-alphabetic characters such
  7671. --        as / # * "  etc.
  7672. --    (f) The field may not be blank (i.e., all spaces).
  7673. --
  7674. --**********************************************************************
  7675.  
  7676.  
  7677.   procedure Validate_Pin(Valid_Pin : in string ;
  7678.                          Field_Name : in string) is
  7679.  
  7680.   begin
  7681.     Valid_Value := string_to_integer(Valid_Pin(1..4));
  7682.     if Valid_Value = -1 then
  7683.       Pin_Type := Pin_Types'value(Valid_Pin(1..1));
  7684.       Valid_Value := string_to_integer(Valid_Pin(2..4));
  7685.       if Valid_Value < 1 then
  7686.         raise constraint_error;
  7687.       end if;
  7688.     elsif Valid_Value = 0 then
  7689.       raise constraint_error;
  7690.     elsif Valid_Pin(5) /= ' ' then
  7691.       Pin_Type := Pin_Types'value(Valid_Pin(5..5));
  7692.     end if;
  7693.  
  7694.   exception
  7695.     when others  => Error_Message(Field_Name,Bad_Field);
  7696.   end Validate_Pin;
  7697.  
  7698.  
  7699. --**********************************************************************
  7700. --
  7701. --      This procedure validates the MEQPT field by doing a look-up
  7702. --    against an IDM database relation MEQPT.
  7703. --
  7704. --**********************************************************************
  7705.  
  7706.  
  7707. procedure Validate_Meqpt(Meqpt : in string ;
  7708.                          Field_Name : in string) is
  7709.   Tcom : string(1..2);
  7710. begin
  7711.   -- tell interface which stored command we will be using
  7712.   idm_command(idmrun,"return_meqpt $1");
  7713.   -- load the parameter(s) for that stored command
  7714.   idm_param(idmrun,"$1",Meqpt,idm_char);
  7715.   -- execute stored command and get data if any
  7716.   idm_execute(idmrun);
  7717.   idm_fetch(idmrun);
  7718.   -- read the column(s) returned by the stored command
  7719.   idm_column(idmrun,1,Tcom,Length_of_String);
  7720.  
  7721.   -- if field is a Telecommunication Equipment field check
  7722.   -- Telecommunication Equipment flag to by sure equipment
  7723.   -- is telecommunication.
  7724.   if Field_Name = "TEQPT" and Tcom = "  " then
  7725.     Error_Message(Field_Name,Bad_Field);
  7726.   end if;
  7727.  
  7728. exception
  7729.   when done_error  => Error_Message(Field_Name,Bad_Field);
  7730.   when others      => put_line("problems with meqpt validation");
  7731. end Validate_Meqpt;
  7732.  
  7733.  
  7734. --**********************************************************************
  7735. --
  7736. --      This procedure validates the GEOLOCATION fields by doing a
  7737. --    look up against an IDM database relation GEOLOC.
  7738. --
  7739. --**********************************************************************
  7740.  
  7741.  
  7742. procedure Validate_Geolocation(Geolocation : in string ;
  7743.                                Field_Name  : in string) is
  7744.   Geoloc : string(1..4);
  7745. begin
  7746.   -- tell interface which stored command we will be using
  7747.   idm_command(idmrun,"return_geolocation $1");
  7748.   -- load the parameter(s) to be used by command
  7749.   idm_param(idmrun,"$1",Geolocation,idm_char);
  7750.   -- execute stored command and get data if any
  7751.   idm_execute(idmrun);
  7752.   idm_fetch(idmrun);
  7753.   -- read in data returned by stored command
  7754.   idm_column(idmrun,1,Geoloc,Length_of_String);
  7755.  
  7756. exception
  7757.   when done_error  => Error_Message(Field_Name,Bad_Field);
  7758.   when others      => put_line("problem with geolocation validation");
  7759. end Validate_Geolocation;
  7760.  
  7761.  
  7762. --**********************************************************************
  7763. --
  7764. --      This procedure loads values extracted from the EQUIP relation
  7765. --    on the IDM. The values will be related to MEPSD.
  7766. --
  7767. --**********************************************************************
  7768.  
  7769.  
  7770. procedure Load_Meq_Values is
  7771.  
  7772. begin
  7773.   idm_command(idmrun,"return_meq_fields $1");
  7774.   idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  7775.   idm_execute(idmrun);
  7776.   idm_fetch(idmrun);
  7777.   idm_column(idmrun,1,Meord_Value);
  7778.   idm_column(idmrun,2,Meorn_Value);
  7779.   idm_column(idmrun,3,Meorc_Value);
  7780.   idm_column(idmrun,4,Meoro_Value);
  7781. exception
  7782.   when others  => Error_Message("MEPSD",Can_Not_Validate_Correctly);
  7783. end Load_Meq_Values;
  7784.  
  7785.  
  7786. --**********************************************************************
  7787. --
  7788. --      This procedure loads values extracted from the EQUIP relation
  7789. --    on the IDM. The values will be related to CREWF.
  7790. --
  7791. --**********************************************************************
  7792.  
  7793.  
  7794. procedure Load_Crew_Values is
  7795.  
  7796. begin
  7797.   idm_command(idmrun,"return_crew_fields $1");
  7798.   idm_param(idmrun,"$1",Valid_Msg.Uic,idm_char);
  7799.   idm_execute(idmrun);
  7800.   idm_fetch(idmrun);
  7801.   idm_column(idmrun,1,Crmrd_Value);
  7802.   idm_column(idmrun,2,Crmrn_Value);
  7803.   idm_column(idmrun,3,Crmrc_Value);
  7804.   idm_column(idmrun,4,Crmro_Value);
  7805. exception
  7806.   when others  => Error_Message("MEPSD",Can_Not_Validate_Correctly);
  7807. end Load_Crew_Values;
  7808.  
  7809.  
  7810. --**********************************************************************
  7811. --
  7812. --      This function returns "true" if a field is not a valid UIC.
  7813. --
  7814. --**********************************************************************
  7815.  
  7816.  
  7817.   function Invalid_Uic(Uic : in string) return boolean is
  7818.     Working_Uic : string(1..6);
  7819.   begin
  7820.     if Uic(5..6) = "  " then
  7821.       return true;
  7822.     else
  7823.     --
  7824.     --    see if a bide relation exists for this UIC on the IDM
  7825.     --
  7826.       idm_command(idmrun,"return_uic $1");
  7827.       idm_param(idmrun,"$1",Uic,idm_char);
  7828.       idm_execute(idmrun);
  7829.       idm_fetch(idmrun);
  7830.       Working_Uic := Uic;
  7831.       idm_column(idmrun,1,Working_Uic,Length_of_String);
  7832.       return false;
  7833.     end if;
  7834.  
  7835.     exception
  7836.       when others   => return true;
  7837.   end Invalid_Uic;
  7838.  
  7839.  
  7840. --**********************************************************************
  7841. --
  7842. --      This function returns "true" if a field is not a valid
  7843. --    Geolocation.  Performs a look-up on the Geoloc relation
  7844. --    on the IDM.
  7845. --
  7846. --**********************************************************************
  7847.  
  7848.  
  7849.   function Invalid_Geo(Geo : in string) return boolean is
  7850.     Working_Geo : string(1..4);
  7851.   begin
  7852.     idm_command(idmrun,"return_geolocation $1");
  7853.     idm_param(idmrun,"$1",Geo,idm_char);
  7854.     idm_execute(idmrun);
  7855.     idm_fetch(idmrun);
  7856.     Working_Geo := Geo(1..4);
  7857.     idm_column(idmrun,1,Working_Geo,Length_of_String);
  7858.  
  7859.     return false;
  7860.  
  7861.     exception
  7862.       when others   => return true;
  7863.   end Invalid_Geo;
  7864.  
  7865.  
  7866. begin
  7867.   null;
  7868.   exception
  7869.     when others     => put_line("message validation module dead");
  7870. end Message_Validation_Module;
  7871. --::::::::::
  7872. --dbb.src
  7873. --::::::::::
  7874. with System_Utilities;
  7875. use  System_Utilities;
  7876. with text_io;
  7877. use  text_io;
  7878. with MSG_Types;
  7879. use  MSG_Types;
  7880. with IDM_DEFS;
  7881. use  IDM_DEFS;
  7882. with IDM_IO;
  7883. use  IDM_IO;
  7884. with calendar;
  7885. use  calendar;
  7886.  
  7887. package Database_Build is
  7888.  
  7889.   task Database_Build_Task is
  7890.     entry rendezvous_point(in_packet : in Packet_Access);
  7891.   end Database_Build_Task;
  7892.  
  7893. end Database_Build;
  7894.  
  7895. package body Database_Build is
  7896.  
  7897.   working_string    : string(1..5) := "     ";
  7898.   message_counter   : integer;
  7899.   last_message      : constant string := "LAST MESSAGE";
  7900.   terminate_task    : boolean;
  7901.   last_msg_received : boolean;
  7902.   type task_state_type is (not_initialized,
  7903.                            active,
  7904.                            termination_requested);
  7905.   task_state        : task_state_type;
  7906.   report_as_of_time : string(1..8);
  7907.   list_item         : Access_Msg_List;
  7908.   idmrun            : idmrun_type;
  7909.   save_secur        : string(1..1);
  7910.   working_secur     : string(1..1);
  7911.   save_date         : string(1..8);
  7912.   system_time       : time;
  7913.   system_year       : integer;
  7914.   system_month      : integer;
  7915.   system_day        : integer;
  7916.   system_date       : string(1..8);
  7917.   length_of_string  : integer;
  7918.   stats_text        : string(1..60) :=
  7919.        "                                                            ";
  7920. --      123456789 123456789 123456789 123456789 123456789 123456789 
  7921.  
  7922.   access_h   : Access_Card_Type_H;
  7923.   access_e   : Access_Card_Type_E;
  7924.   access_a   : Access_Card_Type_A;
  7925.   access_b   : Access_Card_Type_B;
  7926.   access_c   : Access_Card_Type_C;
  7927.   access_d   : Access_Card_Type_D;
  7928.   access_g   : Access_Card_Type_G;
  7929.   access_j   : Access_Card_Type_J;
  7930.   access_k   : Access_Card_Type_K;
  7931.   access_l   : Access_Card_Type_L;
  7932.   access_m   : Access_Card_Type_M;
  7933.   access_n   : Access_Card_Type_N;
  7934.   access_p   : Access_Card_Type_P;
  7935.   access_q   : Access_Card_Type_Q;
  7936.   access_t   : Access_Card_Type_T;
  7937.   access_v   : Access_Card_Type_V;
  7938.   access_x   : Access_Card_Type_X;
  7939.   access_r   : Access_Card_Type_R;
  7940.   access_dm1 : Access_Card_Type_DM1;
  7941.   access_dn1 : Access_Card_Type_DN1;
  7942.   access_jm1 : Access_Card_Type_JM1;
  7943.   access_kf1 : Access_Card_Type_KF1;
  7944.   access_kf2 : Access_Card_Type_KF2;
  7945.   access_kf3 : Access_Card_Type_KF3;
  7946.   access_kf4 : Access_Card_Type_KF4;
  7947.   access_kn1 : Access_Card_Type_KN1;
  7948.   access_tf1 : Access_Card_Type_TF1;
  7949.  
  7950.   procedure process_message;
  7951.   procedure process_card_h;
  7952.   procedure process_card_a;
  7953.   procedure process_card_b;
  7954.   procedure process_card_c;
  7955.   procedure process_card_d;
  7956.   procedure process_card_g;
  7957.   procedure process_card_j;
  7958.   procedure process_card_k;
  7959.   procedure process_card_l;
  7960.   procedure process_card_m;
  7961.   procedure process_card_n;
  7962.   procedure process_card_p;
  7963.   procedure process_card_q;
  7964.   procedure process_card_r;
  7965.   procedure process_card_t;
  7966.   procedure process_card_v;
  7967.   procedure process_card_x;
  7968.   procedure process_card_dm1;
  7969.   procedure process_card_dn1;
  7970.   procedure process_card_jm1;
  7971.   procedure process_card_kf1;
  7972.   procedure process_card_kf2;
  7973.   procedure process_card_kf3;
  7974.   procedure process_card_kf4;
  7975.   procedure process_card_kn1;
  7976.   procedure process_card_tf1;
  7977.   procedure get_and_store_system_date;
  7978.  
  7979. --*********************************************************************
  7980. --*
  7981. --*     DATABASE_BUILD_TASK
  7982. --*
  7983. --*    This task is the main process controlling the database build
  7984. --*    module.  The task will process operator commands received from
  7985. --*    the Man/Machine Interface (MMI) module, will construct the
  7986. --*    database commands to be send to the database machine from
  7987. --*    the validated UNITREP message buffers received from the 
  7988. --*    Message Validation (MV) module, and will maintain message
  7989. --*    throughput statistics.
  7990. --*
  7991. --*********************************************************************
  7992.  
  7993. task body Database_Build_Task is
  7994.  
  7995. begin
  7996.  
  7997.   -- loop until the terminate system operator request is 
  7998.   -- received from the MV module and the last message is 
  7999.   -- processed
  8000.   terminate_task    := FALSE;
  8001.   while not terminate_task
  8002.   loop
  8003.  
  8004.     -- accept and process task packet as function of function code
  8005.     -- contained in packet
  8006.     accept rendezvous_point(in_packet : in Packet_Access) do
  8007.  
  8008.       if task_state = not_initialized then
  8009.         if in_packet.FTN = Coldstart_Module or in_packet.FTN = Restart_Module then
  8010.           if in_packet.FTN = Coldstart_Module then
  8011.             message_counter := 0;
  8012.           end if;
  8013.           tpsend(dbb_id,mmi_id,Module_Initialized,tp1,tp2,tp3,tp4,tp5);
  8014.           task_state := active;
  8015.         else
  8016.           tpsend(dbb_id,mmi_id,Fixed_Alert,tp1,tp2,tp3,Invalid_Ftn_Code,tp5);
  8017.         end if;
  8018.       else
  8019.         case in_packet.FTN is
  8020.           when Send_Statistics  => stats_text(1..34) := "Number of records processed       ";
  8021.                                    tpsend(dbb_id,mmi_id,Statistics,tp1,stats_text,Message_counter,tp4,tp5);
  8022.  
  8023.           when Terminate_Module => task_state := termination_requested;
  8024.  
  8025.           when Validated_Data   => list_item := in_packet.MSG_PTR;
  8026.                                    if list_item /= null then
  8027.                                      process_message;
  8028.                                      message_counter := message_counter + 1;
  8029.                                    else
  8030.                                      tpsend(dbb_id,mmi_id,Fixed_Alert,tp1,tp2,tp3,Invalid_Ftn_Code,tp5);
  8031.                                    end if;
  8032.  
  8033.           when others           => tpsend(dbb_id,mmi_id,Fixed_Alert,tp1,tp2,tp3,Invalid_Ftn_Code,tp5);
  8034.         end case;
  8035.  
  8036.       end if;
  8037.  
  8038.       if in_packet.var_string(1 .. last_message'length) = last_message then
  8039.         last_msg_received := TRUE;
  8040.       end if;
  8041.  
  8042.       if last_msg_received or task_state = termination_requested then
  8043. --        terminate_task := TRUE;
  8044.         last_msg_received := FALSE;
  8045.         task_state        := not_initialized;
  8046.         tpsend(dbb_id,mmi_id,Module_Terminated,tp1,tp2,tp3,tp4,tp5);
  8047.       end if;
  8048.  
  8049.     end rendezvous_point;
  8050.  
  8051.   end loop;
  8052.  
  8053. exception
  8054.   when others => put_line("Database Build task dead");
  8055. end Database_Build_Task;
  8056.  
  8057.  
  8058. --*********************************************************************
  8059. --*
  8060. --*    PROCESS_MESSAGE
  8061. --*
  8062. --*    This procedure will process the validated UNITREP message
  8063. --*    received from the MV module.  Each item in the received
  8064. --*    linked list is processed as a function of the card type until
  8065. --*    the item containing the End card is detected.
  8066. --*
  8067. --*********************************************************************
  8068.  
  8069. procedure process_message is
  8070.  
  8071. begin
  8072.  
  8073.   idm_initrun(true);
  8074.   idm_openrun(idmrun,"sys_idm");
  8075.   idm_opendb(idmrun,"unitrep");
  8076.  
  8077.   loop
  8078.     case list_item.card_type is
  8079.       when A         => process_card_a;
  8080.       when B         => process_card_b;
  8081.       when C         => process_card_c;
  8082.       when D         => process_card_d;
  8083.       when G         => process_card_g;
  8084.       when J         => process_card_j;
  8085.       when K         => process_card_k;
  8086.       when L         => process_card_l;
  8087.       when M         => process_card_m;
  8088.       when N         => process_card_n;
  8089.       when P         => process_card_p;
  8090.       when Q         => process_card_q;
  8091.       when R | RM3   => process_card_r;
  8092.       when T         => process_card_t;
  8093.       when V         => process_card_v;
  8094.       when X         => process_card_x;
  8095.       when DM1       => process_card_dm1;
  8096.       when DN1       => process_card_dn1;
  8097.       when JM1       => process_card_jm1;
  8098.       when KF1       => process_card_kf1;
  8099.       when KF2       => process_card_kf2;
  8100.       when KF3       => process_card_kf3;
  8101.       when KF4       => process_card_kf4;
  8102.       when KN1       => process_card_kn1;
  8103.       when TF1       => process_card_tf1;
  8104.       when H         => process_card_h;
  8105.       when E         => exit;
  8106.     end case;
  8107.  
  8108.     list_item := list_item.next;
  8109.   end loop;
  8110.  
  8111. end process_message;
  8112.  
  8113.  
  8114. --*********************************************************************
  8115. --*
  8116. --*    PROCESS_CARD_H
  8117. --*
  8118. --*    This procedure will process the message header card.
  8119. --*    The report "as of" time is retrieved from the card.
  8120. --*
  8121. --*********************************************************************
  8122.  
  8123. procedure process_card_h is
  8124.  
  8125. begin
  8126.  
  8127.   access_h := list_item.access_h;
  8128.  
  8129.   report_as_of_time(1..2) := "19";
  8130.   working_string(1..3)    := integer'image(access_h.year);
  8131.   report_as_of_time(3..4) := working_string(2..3);
  8132.   report_as_of_time(5..8) := "0000";
  8133.   if access_h.day < 10 then
  8134.     working_string(1..2)    := integer'image(access_h.day);
  8135.     report_as_of_time(6..6) := working_string(2..2);
  8136.   else
  8137.     working_string(1..3)    := integer'image(access_h.day);
  8138.     report_as_of_time(5..6) := working_string(2..3);
  8139.   end if;
  8140.   if access_h.month in JAN..SEP then
  8141.     working_string(1..2)    :=
  8142.           integer'image(Month_Types'pos(access_h.month)+1);
  8143.     report_as_of_time(8..8) := working_string(2..2);
  8144.   else
  8145.     working_string(1..3)    := 
  8146.           integer'image(Month_Types'pos(access_h.month)+1);
  8147.     report_as_of_time(7..8) := working_string(2..3);
  8148.   end if;
  8149.  
  8150. end process_card_h;
  8151.  
  8152.  
  8153. --*********************************************************************
  8154. --*
  8155. --*    PROCESS_CARD_A
  8156. --*
  8157. --*    This procedure will process the message cards of type 'A'.
  8158. --*    The record containing the card data is retrieved from the list,
  8159. --*    and the card is processed as a function of the transaction 
  8160. --*    code.
  8161. --*
  8162. --*********************************************************************
  8163.  
  8164. procedure process_card_a is
  8165.   save_aname : string(1..30);
  8166.   save_utc   : string(1..5);
  8167.   save_ulc   : string(1..3);
  8168.   save_udc   : string(1..1);
  8169.   save_reval : string(1..1);
  8170.   save_mjcom : string(1..6);
  8171.   save_major : string(1..1);
  8172.   save_tpsn  : string(1..7);
  8173.   save_sclas : string(1..1);
  8174. begin
  8175.  
  8176.   access_a := list_item.access_a;
  8177.  
  8178.   if list_item.Trtype = CHANGE then
  8179.     idm_command(idmrun,"return_card_a $1");
  8180.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8181.     idm_execute(idmrun);
  8182.     idm_fetch(idmrun);
  8183.     idm_column(idmrun,1,save_secur,length_of_string);
  8184.     idm_column(idmrun,2,save_date,length_of_string);
  8185.     idm_column(idmrun,3,save_aname,length_of_string);
  8186.     idm_column(idmrun,4,save_utc,length_of_string);
  8187.     idm_column(idmrun,5,save_ulc,length_of_string);
  8188.     idm_column(idmrun,6,save_udc,length_of_string);
  8189.     idm_column(idmrun,7,save_reval,length_of_string);
  8190.     idm_column(idmrun,8,save_mjcom,length_of_string);
  8191.     idm_column(idmrun,9,save_major,length_of_string);
  8192.     idm_column(idmrun,10,save_tpsn,length_of_string);
  8193.     idm_column(idmrun,11,save_sclas,length_of_string);
  8194.   end if;
  8195.  
  8196.   if list_item.Trtype /= ADD then
  8197.     idm_command(idmrun,"delete_card_a $1");
  8198.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8199.     idm_execute(idmrun);
  8200.     idm_fetch(idmrun);
  8201.   end if;
  8202.  
  8203.   if list_item.Trtype /= DELETE then
  8204.     idm_command(idmrun,"add_card_a $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  8205.                        "$11 $12 $13");
  8206.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8207.     idm_param(idmrun,"$4",system_date,idm_char);
  8208.     working_secur := secur_types'image(list_item.secur);
  8209.     if list_item.Trtype /= CHANGE then
  8210.       idm_param(idmrun,"$2",working_secur,idm_char);
  8211.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  8212.       idm_param(idmrun,"$5",access_a.aname,idm_char);
  8213.       idm_param(idmrun,"$6",access_a.utc,idm_char);
  8214.       idm_param(idmrun,"$7",access_a.ulc,idm_char);
  8215.       idm_param(idmrun,"$8",access_a.udc,idm_char);
  8216.       idm_param(idmrun,"$9",access_a.reval,idm_char);
  8217.       idm_param(idmrun,"$10",access_a.mjcom,idm_char);
  8218.       idm_param(idmrun,"$11",access_a.major,idm_char);
  8219.       idm_param(idmrun,"$12",access_a.tpsn,idm_char);
  8220.       idm_param(idmrun,"$13",access_a.sclas,idm_char);
  8221.     else
  8222.       if working_secur /= save_secur then
  8223.         idm_param(idmrun,"$2",working_secur,idm_char);
  8224.       else
  8225.         idm_param(idmrun,"$2",save_secur,idm_char);
  8226.       end if;
  8227.       if report_as_of_time /= save_date then
  8228.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  8229.       else
  8230.         idm_param(idmrun,"$3",save_date,idm_char);
  8231.       end if;
  8232.       if access_a.aname /= save_aname and
  8233.          access_a.aname /= "                              " then
  8234.         idm_param(idmrun,"$5",access_a.aname,idm_char);
  8235.       else
  8236.         idm_param(idmrun,"$5",save_aname,idm_char);
  8237.       end if;
  8238.       if access_a.utc /= save_utc and access_a.utc /= "     " then
  8239.         idm_param(idmrun,"$6",access_a.utc,idm_char);
  8240.       else
  8241.         idm_param(idmrun,"$6",save_utc,idm_char);
  8242.       end if;
  8243.       if access_a.ulc /= save_ulc and access_a.ulc /= "   " then
  8244.         idm_param(idmrun,"$7",access_a.ulc,idm_char);
  8245.       else
  8246.         idm_param(idmrun,"$7",save_ulc,idm_char);
  8247.       end if;
  8248.       if access_a.udc /= save_udc and access_a.udc /= " " then
  8249.         idm_param(idmrun,"$8",access_a.udc,idm_char);
  8250.       else
  8251.         idm_param(idmrun,"$8",save_udc,idm_char);
  8252.       end if;
  8253.       if access_a.reval /= save_reval and access_a.reval /= " " then
  8254.         idm_param(idmrun,"$9",access_a.reval,idm_char);
  8255.       else
  8256.         idm_param(idmrun,"$9",save_reval,idm_char);
  8257.       end if;
  8258.       if access_a.mjcom /= save_mjcom and
  8259.          access_a.mjcom /= "      " then
  8260.         idm_param(idmrun,"$10",access_a.mjcom,idm_char);
  8261.       else
  8262.         idm_param(idmrun,"$10",save_mjcom,idm_char);
  8263.       end if;
  8264.       if access_a.major = "#" then
  8265.         idm_param(idmrun,"$11"," ",idm_char);
  8266.       elsif access_a.major /= save_major and access_a.major /= " " then
  8267.         idm_param(idmrun,"$11",access_a.major,idm_char);
  8268.       else
  8269.         idm_param(idmrun,"$11",save_major,idm_char);
  8270.       end if;
  8271.       if access_a.tpsn /= save_tpsn and access_a.tpsn /= "       " then
  8272.         idm_param(idmrun,"$12",access_a.tpsn,idm_char);
  8273.       else
  8274.         idm_param(idmrun,"$12",save_tpsn,idm_char);
  8275.       end if;
  8276.       if access_a.sclas /= save_sclas and access_a.sclas /= " " then
  8277.         idm_param(idmrun,"$13",access_a.sclas,idm_char);
  8278.       else
  8279.         idm_param(idmrun,"$13",save_sclas,idm_char);
  8280.       end if;
  8281.     end if;
  8282.     idm_execute(idmrun);
  8283.     idm_fetch(idmrun);
  8284.   end if;
  8285.  
  8286. end process_card_a;
  8287.  
  8288. --*********************************************************************
  8289. --*
  8290. --*    PROCESS_CARD_B
  8291. --*
  8292. --*    This procedure will process the message cards of type 'B'.
  8293. --*    The record containing the card data is retrieved from the list,
  8294. --*    and the card is processed as a function of the transaction 
  8295. --*    code.
  8296. --*
  8297. --*********************************************************************
  8298.  
  8299. procedure process_card_b is
  8300.   save_lname : string(1..55);
  8301. begin
  8302.  
  8303.   access_b := list_item.access_b;
  8304.  
  8305.   if list_item.Trtype = CHANGE then
  8306.     idm_command(idmrun,"return_card_b $1");
  8307.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8308.     idm_execute(idmrun);
  8309.     idm_fetch(idmrun);
  8310.     idm_column(idmrun,1,save_secur,length_of_string);
  8311.     idm_column(idmrun,2,save_lname,length_of_string);
  8312.   end if;
  8313.  
  8314.   if list_item.Trtype /= ADD then
  8315.     idm_command(idmrun,"delete_card_b $1");
  8316.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8317.     idm_execute(idmrun);
  8318.     idm_fetch(idmrun);
  8319.   end if;
  8320.  
  8321.   if list_item.Trtype /= DELETE then
  8322.     idm_command(idmrun,"add_card_b $1 $2 $3 $4");
  8323.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8324.     idm_param(idmrun,"$3",system_date,idm_char);
  8325.     working_secur := secur_types'image(list_item.secur);
  8326.     if list_item.Trtype /= CHANGE then
  8327.       idm_param(idmrun,"$2",working_secur,idm_char);
  8328.       idm_param(idmrun,"$4",access_b.lname,idm_char);
  8329.     else
  8330.       if working_secur /= save_secur then
  8331.         idm_param(idmrun,"$2",working_secur,idm_char);
  8332.       else
  8333.         idm_param(idmrun,"$2",save_secur,idm_char);
  8334.       end if;
  8335.       if access_b.lname /= save_lname and
  8336.          access_b.lname /= "                                                       " then
  8337.         idm_param(idmrun,"$4",access_b.lname,idm_char);
  8338.       else
  8339.         idm_param(idmrun,"$4",save_lname,idm_char);
  8340.       end if;
  8341.     end if;
  8342.     idm_execute(idmrun);
  8343.     idm_fetch(idmrun);
  8344.   end if;
  8345.  
  8346. end process_card_b;
  8347.  
  8348.  
  8349. --*********************************************************************
  8350. --*
  8351. --*    PROCESS_CARD_C
  8352. --*
  8353. --*    This procedure will process the message cards of type 'C'.
  8354. --*    The record containing the card data is retrieved from the list,
  8355. --*    and the card is processed as a function of the transaction 
  8356. --*    code.
  8357. --*
  8358. --*********************************************************************
  8359.  
  8360. procedure process_card_c is
  8361.   save_aname : string(1..30);
  8362.   save_utc   : string(1..5);
  8363.   save_ulc   : string(1..3);
  8364.   save_udc   : string(1..1);
  8365.   save_coaff : string(1..2);
  8366.   save_monor : string(1..6);
  8367.   save_sclas : string(1..1);
  8368. begin
  8369.  
  8370.   access_c := list_item.access_c;
  8371.  
  8372.   if list_item.Trtype = CHANGE then
  8373.     idm_command(idmrun,"return_card_c $1");
  8374.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8375.     idm_execute(idmrun);
  8376.     idm_fetch(idmrun);
  8377.     idm_column(idmrun,1,save_secur,length_of_string);
  8378.     idm_column(idmrun,2,save_aname,length_of_string);
  8379.     idm_column(idmrun,3,save_utc,length_of_string);
  8380.     idm_column(idmrun,4,save_ulc,length_of_string);
  8381.     idm_column(idmrun,5,save_udc,length_of_string);
  8382.     idm_column(idmrun,6,save_coaff,length_of_string);
  8383.     idm_column(idmrun,7,save_monor,length_of_string);
  8384.     idm_column(idmrun,8,save_sclas,length_of_string);
  8385.   end if;
  8386.  
  8387.   if list_item.Trtype /= ADD then
  8388.     idm_command(idmrun,"delete_card_c $1");
  8389.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8390.     idm_execute(idmrun);
  8391.     idm_fetch(idmrun);
  8392.   end if;
  8393.  
  8394.   if list_item.Trtype /= DELETE then
  8395.     idm_command(idmrun,"add_card_c $1 $2 $3 $4 $5 $6 $7 $8 $9 $10");
  8396.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8397.     idm_param(idmrun,"$3",system_date,idm_char);
  8398.     working_secur := secur_types'image(list_item.secur);
  8399.     if list_item.Trtype /= CHANGE then
  8400.       idm_param(idmrun,"$2",working_secur,idm_char);
  8401.       idm_param(idmrun,"$4",access_c.aname,idm_char);
  8402.       idm_param(idmrun,"$5",access_c.utc,idm_char);
  8403.       idm_param(idmrun,"$6",access_c.ulc,idm_char);
  8404.       idm_param(idmrun,"$7",access_c.udc,idm_char);
  8405.       idm_param(idmrun,"$8",access_c.coaff,idm_char);
  8406.       idm_param(idmrun,"$9",access_c.monor,idm_char);
  8407.       idm_param(idmrun,"$10",access_c.sclas,idm_char);
  8408.     else
  8409.       if working_secur /= save_secur then
  8410.         idm_param(idmrun,"$2",working_secur,idm_char);
  8411.       else
  8412.         idm_param(idmrun,"$2",save_secur,idm_char);
  8413.       end if;
  8414.       if access_c.aname /= save_aname and
  8415.          access_c.aname /= "                              " then
  8416.         idm_param(idmrun,"$4",access_c.aname,idm_char);
  8417.       else
  8418.         idm_param(idmrun,"$4",save_aname,idm_char);
  8419.       end if;
  8420.       if access_c.utc /= save_utc and access_c.utc /= "     " then
  8421.         idm_param(idmrun,"$5",access_c.utc,idm_char);
  8422.       else
  8423.         idm_param(idmrun,"$5",save_utc,idm_char);
  8424.       end if;
  8425.       if access_c.ulc /= save_ulc and access_c.ulc /= "   " then
  8426.         idm_param(idmrun,"$6",access_c.ulc,idm_char);
  8427.       else
  8428.         idm_param(idmrun,"$6",save_ulc,idm_char);
  8429.       end if;
  8430.       if access_c.udc /= save_udc and access_c.udc /= " " then
  8431.         idm_param(idmrun,"$7",access_c.udc,idm_char);
  8432.       else
  8433.         idm_param(idmrun,"$7",save_udc,idm_char);
  8434.       end if;
  8435.       if access_c.coaff /= save_coaff and access_c.coaff /= " " then
  8436.         idm_param(idmrun,"$8",access_c.coaff,idm_char);
  8437.       else
  8438.         idm_param(idmrun,"$8",save_coaff,idm_char);
  8439.       end if;
  8440.       if access_c.monor /= save_monor and
  8441.          access_c.monor /= "      " then
  8442.         idm_param(idmrun,"$9",access_c.monor,idm_char);
  8443.       else
  8444.         idm_param(idmrun,"$9",save_monor,idm_char);
  8445.       end if;
  8446.       if access_c.sclas /= save_sclas and access_c.sclas /= " " then
  8447.         idm_param(idmrun,"$10",access_c.sclas,idm_char);
  8448.       else
  8449.         idm_param(idmrun,"$10",save_sclas,idm_char);
  8450.       end if;
  8451.     end if;
  8452.     idm_execute(idmrun);
  8453.     idm_fetch(idmrun);
  8454.   end if;
  8455.  
  8456. end process_card_c;
  8457.  
  8458. --*********************************************************************
  8459. --*
  8460. --*    PROCESS_CARD_D
  8461. --*
  8462. --*    This procedure will process the message cards of type 'D'.
  8463. --*    The record containing the card data is retrieved from the list,
  8464. --*    and the card is processed as a function of the transaction 
  8465. --*    code.
  8466. --*
  8467. --*********************************************************************
  8468.  
  8469. procedure process_card_d is
  8470.   save_opcon : string(1..6);
  8471.   save_adcon : string(1..6);
  8472.   save_cserv : string(1..1);
  8473.   save_hogeo : string(1..4);
  8474.   save_prgeo : string(1..4);
  8475.   save_point : string(1..15);
  8476.   save_embrk : string(1..6);
  8477.   save_activ : string(1..2);
  8478.   save_flag  : string(1..1);
  8479.   save_puic  : string(1..6);
  8480.   save_cbcom : string(1..1);
  8481.   save_dfcon : string(1..1);
  8482.   save_pctef : string(1..1);
  8483.   save_nucin : string(1..1);
  8484. begin
  8485.  
  8486.   access_d := list_item.access_d;
  8487.  
  8488.   if list_item.Trtype = CHANGE then
  8489.     idm_command(idmrun,"return_card_d $1");
  8490.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8491.     idm_execute(idmrun);
  8492.     idm_fetch(idmrun);
  8493.     idm_column(idmrun,1,save_secur,length_of_string);
  8494.     idm_column(idmrun,2,save_date,length_of_string);
  8495.     idm_column(idmrun,3,save_opcon,length_of_string);
  8496.     idm_column(idmrun,4,save_adcon,length_of_string);
  8497.     idm_column(idmrun,5,save_cserv,length_of_string);
  8498.     idm_column(idmrun,6,save_hogeo,length_of_string);
  8499.     idm_column(idmrun,7,save_prgeo,length_of_string);
  8500.     idm_column(idmrun,8,save_point,length_of_string);
  8501.     idm_column(idmrun,9,save_embrk,length_of_string);
  8502.     idm_column(idmrun,10,save_activ,length_of_string);
  8503.     idm_column(idmrun,11,save_flag,length_of_string);
  8504.     idm_column(idmrun,12,save_puic,length_of_string);
  8505.     idm_column(idmrun,13,save_cbcom,length_of_string);
  8506.     idm_column(idmrun,14,save_dfcon,length_of_string);
  8507.     idm_column(idmrun,15,save_pctef,length_of_string);
  8508.     idm_column(idmrun,16,save_nucin,length_of_string);
  8509.   end if;
  8510.  
  8511.   if list_item.Trtype /= ADD then
  8512.     idm_command(idmrun,"delete_card_d $1");
  8513.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8514.     idm_execute(idmrun);
  8515.     idm_fetch(idmrun);
  8516.   end if;
  8517.  
  8518.   if list_item.Trtype /= DELETE then
  8519.     idm_command(idmrun,"add_card_d $1 $2 $3 $4 $5 $6 $7 $8 $9 " &
  8520.                        "$10 $11 $12 $13 $14 $15 $16 $17 $18");
  8521.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8522.     idm_param(idmrun,"$4",system_date,idm_char);
  8523.     working_secur := secur_types'image(list_item.secur);
  8524.     if list_item.Trtype /= CHANGE then
  8525.       idm_param(idmrun,"$2",working_secur,idm_char);
  8526.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  8527.       idm_param(idmrun,"$5",access_d.opcon,idm_char);
  8528.       idm_param(idmrun,"$6",access_d.adcon,idm_char);
  8529.       idm_param(idmrun,"$7",access_d.cserv,idm_char);
  8530.       idm_param(idmrun,"$8",access_d.hogeo,idm_char);
  8531.       idm_param(idmrun,"$9",access_d.prgeo,idm_char);
  8532.       idm_param(idmrun,"$10",access_d.point,idm_char);
  8533.       idm_param(idmrun,"$11",access_d.embrk,idm_char);
  8534.       idm_param(idmrun,"$12",access_d.activ,idm_char);
  8535.       idm_param(idmrun,"$13",access_d.flag,idm_char);
  8536.       idm_param(idmrun,"$14",access_d.puic,idm_char);
  8537.       idm_param(idmrun,"$15",access_d.cbcom,idm_char);
  8538.       idm_param(idmrun,"$16",access_d.dfcon,idm_char);
  8539.       idm_param(idmrun,"$17",access_d.pctef,idm_char);
  8540.       idm_param(idmrun,"$18",access_d.nucin,idm_char);
  8541.     else
  8542.       if working_secur /= save_secur then
  8543.         idm_param(idmrun,"$2",working_secur,idm_char);
  8544.       else
  8545.         idm_param(idmrun,"$2",save_secur,idm_char);
  8546.       end if;
  8547.       if report_as_of_time /= save_date then
  8548.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  8549.       else
  8550.         idm_param(idmrun,"$3",save_date,idm_char);
  8551.       end if;
  8552.       if access_d.opcon /= save_opcon and
  8553.          access_d.opcon /= "      " then
  8554.         idm_param(idmrun,"$5",access_d.opcon,idm_char);
  8555.       else
  8556.         idm_param(idmrun,"$5",save_opcon,idm_char);
  8557.       end if;
  8558.       if access_d.adcon /= save_adcon and
  8559.          access_d.adcon /= "      " then
  8560.         idm_param(idmrun,"$6",access_d.adcon,idm_char);
  8561.       else
  8562.         idm_param(idmrun,"$6",save_adcon,idm_char);
  8563.       end if;
  8564.       if access_d.cserv /= save_cserv and access_d.cserv /= " " then
  8565.         idm_param(idmrun,"$7",access_d.cserv,idm_char);
  8566.       else
  8567.         idm_param(idmrun,"$7",save_cserv,idm_char);
  8568.       end if;
  8569.       if access_d.hogeo /= save_hogeo and access_d.hogeo /= "    " then
  8570.         idm_param(idmrun,"$8",access_d.hogeo,idm_char);
  8571.       else
  8572.         idm_param(idmrun,"$8",save_hogeo,idm_char);
  8573.       end if;
  8574.       if access_d.prgeo /= save_prgeo and access_d.prgeo /= "    " then
  8575.         idm_param(idmrun,"$9",access_d.prgeo,idm_char);
  8576.       else
  8577.         idm_param(idmrun,"$9",save_prgeo,idm_char);
  8578.       end if;
  8579.       if access_d.point /= save_point and
  8580.          access_d.point /= "               " then
  8581.         idm_param(idmrun,"$10",access_d.point,idm_char);
  8582.       else
  8583.         idm_param(idmrun,"$10",save_point,idm_char);
  8584.       end if;
  8585.       if access_d.embrk /= save_embrk and access_d.embrk /= "     " then
  8586.         idm_param(idmrun,"$11",access_d.embrk,idm_char);
  8587.       else
  8588.         idm_param(idmrun,"$11",save_embrk,idm_char);
  8589.       end if;
  8590.       if access_d.activ /= save_activ and access_d.activ /= "  " then
  8591.         idm_param(idmrun,"$12",access_d.activ,idm_char);
  8592.       else
  8593.         idm_param(idmrun,"$12",save_activ,idm_char);
  8594.       end if;
  8595.       if access_d.flag = "#" then
  8596.         idm_param(idmrun,"$13"," ");
  8597.       elsif access_d.flag /= save_flag and access_d.flag /= " " then
  8598.         idm_param(idmrun,"$13",access_d.flag,idm_char);
  8599.       else
  8600.         idm_param(idmrun,"$13",save_flag,idm_char);
  8601.       end if;
  8602.       if access_d.puic = "#     " then
  8603.         idm_param(idmrun,"$14","      ");
  8604.       elsif access_d.puic /= save_puic and
  8605.             access_d.puic /= "      " then
  8606.         idm_param(idmrun,"$14",access_d.puic,idm_char);
  8607.       else
  8608.         idm_param(idmrun,"$14",save_puic,idm_char);
  8609.       end if;
  8610.       if access_d.cbcom = "#" then
  8611.         idm_param(idmrun,"$15"," ");
  8612.       elsif access_d.cbcom /= save_cbcom and access_d.cbcom /= " " then
  8613.         idm_param(idmrun,"$15",access_d.cbcom,idm_char);
  8614.       else
  8615.         idm_param(idmrun,"$15",save_cbcom,idm_char);
  8616.       end if;
  8617.       if access_d.dfcon /= save_dfcon and access_d.dfcon /= " " then
  8618.         idm_param(idmrun,"$16",access_d.dfcon,idm_char);
  8619.       else
  8620.         idm_param(idmrun,"$16",save_dfcon,idm_char);
  8621.       end if;
  8622.       if access_d.pctef = "#" then
  8623.         idm_param(idmrun,"$17"," ");
  8624.       elsif access_d.pctef /= save_pctef and access_d.pctef /= " " then
  8625.         idm_param(idmrun,"$17",access_d.pctef,idm_char);
  8626.       else
  8627.         idm_param(idmrun,"$17",save_pctef,idm_char);
  8628.       end if;
  8629.       if access_d.nucin = "#" then
  8630.         idm_param(idmrun,"$18"," ");
  8631.       elsif access_d.nucin /= save_nucin and
  8632.             access_d.nucin /= "      " then
  8633.         idm_param(idmrun,"$18",access_d.nucin,idm_char);
  8634.       else
  8635.         idm_param(idmrun,"$18",save_nucin,idm_char);
  8636.       end if;
  8637.     end if;
  8638.     idm_execute(idmrun);
  8639.     idm_fetch(idmrun);
  8640.   end if;
  8641.  
  8642. end process_card_d;
  8643.  
  8644. --*********************************************************************
  8645. --*
  8646. --*    PROCESS_CARD_G
  8647. --*
  8648. --*    This procedure will process the message cards of type 'G'.
  8649. --*    The record containing the card data is retrieved from the list,
  8650. --*    and the card is processed as a function of the transaction 
  8651. --*    code.
  8652. --*
  8653. --*********************************************************************
  8654.  
  8655. procedure process_card_g is
  8656.   save_tcaa  : string(1..29);
  8657.   save_tadc  : string(1..1);
  8658.   save_media : string(1..1);
  8659.   save_route : string(1..7);
  8660.   save_rwdte : integer;
  8661.   save_xrte  : string(1..7);
  8662.   save_xdate : integer;
  8663.   working_rwdte : integer;
  8664.   working_xdate : integer;
  8665. begin
  8666.  
  8667.   access_g := list_item.access_g;
  8668.  
  8669.   if list_item.Trtype = CHANGE then
  8670.     idm_command(idmrun,"return_card_g $1");
  8671.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8672.     idm_execute(idmrun);
  8673.     idm_fetch(idmrun);
  8674.     idm_column(idmrun,1,save_secur,length_of_string);
  8675.     idm_column(idmrun,2,save_date,length_of_string);
  8676.     idm_column(idmrun,3,save_tcaa,length_of_string);
  8677.     idm_column(idmrun,4,save_tadc,length_of_string);
  8678.     idm_column(idmrun,5,save_media,length_of_string);
  8679.     idm_column(idmrun,6,save_route,length_of_string);
  8680.     idm_column(idmrun,7,save_rwdte);
  8681.     idm_column(idmrun,8,save_xrte,length_of_string);
  8682.     idm_column(idmrun,9,save_xdate);
  8683.   end if;
  8684.  
  8685.   if list_item.Trtype /= ADD then
  8686.     idm_command(idmrun,"delete_card_g $1");
  8687.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8688.     idm_execute(idmrun);
  8689.     idm_fetch(idmrun);
  8690.   end if;
  8691.  
  8692.   if list_item.Trtype /= DELETE then
  8693.     idm_command(idmrun,"add_card_g $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11");
  8694.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8695.     idm_param(idmrun,"$4",system_date,idm_char);
  8696.     working_rwdte := string_to_integer(access_g.rwdte.ddd &
  8697.                                        access_g.rwdte.yy);
  8698.     working_xdate := string_to_integer(access_g.xdate.ddd &
  8699.                                        access_g.xdate.yy);
  8700.     working_secur := secur_types'image(list_item.secur);
  8701.     if list_item.Trtype /= CHANGE then
  8702.       idm_param(idmrun,"$2",working_secur,idm_char);
  8703.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  8704.       idm_param(idmrun,"$5",access_g.tcaa,idm_char);
  8705.       idm_param(idmrun,"$6",access_g.tadc,idm_char);
  8706.       idm_param(idmrun,"$7",access_g.media,idm_char);
  8707.       idm_param(idmrun,"$8",access_g.route,idm_char);
  8708.       idm_param(idmrun,"$9",working_rwdte,idm_int1);
  8709.       idm_param(idmrun,"$10",access_g.xrte,idm_char);
  8710.       idm_param(idmrun,"$11",working_xdate,idm_int1);
  8711.     else
  8712.       if working_secur /= save_secur then
  8713.         idm_param(idmrun,"$2",working_secur,idm_char);
  8714.       else
  8715.         idm_param(idmrun,"$2",save_secur,idm_char);
  8716.       end if;
  8717.       if report_as_of_time /= save_date then
  8718.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  8719.       else
  8720.         idm_param(idmrun,"$3",save_date,idm_char);
  8721.       end if;
  8722.       if access_g.tcaa = "                             " then
  8723.         idm_param(idmrun,"$5","                             ",idm_char);
  8724.       elsif access_g.tcaa /= save_tcaa and
  8725.             access_g.tcaa /= "                             " then
  8726.         idm_param(idmrun,"$5",access_g.tcaa,idm_char);
  8727.       else
  8728.         idm_param(idmrun,"$5",save_tcaa,idm_char);
  8729.       end if;
  8730.       if access_g.tadc = " " then
  8731.         idm_param(idmrun,"$6"," ",idm_char);
  8732.       elsif access_g.tadc /= save_tadc and access_g.tadc /= " " then
  8733.         idm_param(idmrun,"$6",access_g.tadc,idm_char);
  8734.       else
  8735.         idm_param(idmrun,"$6",save_tadc,idm_char);
  8736.       end if;
  8737.       if access_g.media /= save_media and access_g.media /= " " then
  8738.         idm_param(idmrun,"$7",access_g.media,idm_char);
  8739.       else
  8740.         idm_param(idmrun,"$7",save_media,idm_char);
  8741.       end if;
  8742.       if access_g.route = "       " then
  8743.         idm_param(idmrun,"$8","       ",idm_char);
  8744.       elsif access_g.route /= save_route and
  8745.             access_g.route /= "       " then
  8746.         idm_param(idmrun,"$8",access_g.route,idm_char);
  8747.       else
  8748.         idm_param(idmrun,"$8",save_route,idm_char);
  8749.       end if;
  8750.       if working_rwdte /= save_rwdte and
  8751.          access_g.rwdte.ddd & access_g.rwdte.yy  /= "     " then
  8752.         idm_param(idmrun,"$9",working_rwdte,idm_int1);
  8753.       else
  8754.         idm_param(idmrun,"$9",save_rwdte,idm_int1);
  8755.       end if;
  8756.       if access_g.xrte = "       " then
  8757.         idm_param(idmrun,"$10","       ",idm_char);
  8758.       elsif access_g.xrte /= save_xrte and
  8759.             access_g.xrte /= "       " then
  8760.         idm_param(idmrun,"$10",access_g.xrte,idm_char);
  8761.       else
  8762.         idm_param(idmrun,"$10",save_xrte,idm_char);
  8763.       end if;
  8764.       if working_xdate /= save_xdate and
  8765.          access_g.xdate.ddd & access_g.xdate.yy  /= "     " then
  8766.         idm_param(idmrun,"$11",working_xdate,idm_int1);
  8767.       else
  8768.         idm_param(idmrun,"$11",save_xdate,idm_int1);
  8769.       end if;
  8770.     end if;
  8771.     idm_execute(idmrun);
  8772.     idm_fetch(idmrun);
  8773.   end if;
  8774.  
  8775. end process_card_g;
  8776.  
  8777.  
  8778. --*********************************************************************
  8779. --*
  8780. --*    PROCESS_CARD_J
  8781. --*
  8782. --*    This procedure will process the message cards of type 'J'.
  8783. --*    The record containing the card data is retrieved from the list,
  8784. --*    and the card is processed as a function of the transaction 
  8785. --*    code.
  8786. --*
  8787. --*********************************************************************
  8788.  
  8789. procedure process_card_j is
  8790.   save_struc : integer;
  8791.   save_auth  : integer;
  8792.   save_asgd  : integer;
  8793.   save_postr : integer;
  8794.   save_deps  : integer;
  8795.   save_tdeps : integer;
  8796.   save_picda : string(1..8);
  8797.   save_caspw : integer;
  8798.   save_ccasp : integer;
  8799.   working_struc : integer;
  8800.   working_auth  : integer;
  8801.   working_asgd  : integer;
  8802.   working_postr : integer;
  8803.   working_deps  : integer;
  8804.   working_tdeps : integer;
  8805.   working_caspw : integer;
  8806.   working_ccasp : integer;
  8807.   working_picda : string(1..8);
  8808. begin
  8809.  
  8810.   access_j := list_item.access_j;
  8811.  
  8812.   if list_item.Trtype = CHANGE then
  8813.     idm_command(idmrun,"return_card_j $1 $2 $3 $4");
  8814.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8815.     idm_param(idmrun,"$2",access_j.tpers,idm_char);
  8816.     if access_j.pegeo(5..6) = "  " then
  8817.       idm_param(idmrun,"$3",access_j.pegeo(1..4),idm_char);
  8818.       idm_param(idmrun,"$4","      ",idm_char);
  8819.     else
  8820.       idm_param(idmrun,"$3","    ",idm_char);
  8821.       idm_param(idmrun,"$4",access_j.pegeo,idm_char);
  8822.     end if;
  8823.     idm_execute(idmrun);
  8824.     idm_fetch(idmrun);
  8825.     idm_column(idmrun,1,save_secur,length_of_string);
  8826.     idm_column(idmrun,2,save_date,length_of_string);
  8827.     idm_column(idmrun,3,save_struc);
  8828.     idm_column(idmrun,4,save_auth);
  8829.     idm_column(idmrun,5,save_asgd);
  8830.     idm_column(idmrun,6,save_postr);
  8831.     idm_column(idmrun,7,save_deps);
  8832.     idm_column(idmrun,8,save_tdeps);
  8833.     idm_column(idmrun,9,save_picda,length_of_string);
  8834.     idm_column(idmrun,10,save_caspw);
  8835.     idm_column(idmrun,11,save_ccasp);
  8836.   end if;
  8837.  
  8838.   if list_item.Trtype /= ADD then
  8839.     idm_command(idmrun,"delete_card_j $1 $2 $3 $4");
  8840.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8841.     idm_param(idmrun,"$2",access_j.tpers,idm_char);
  8842.     if access_j.pegeo(5..6) = "  " then
  8843.       idm_param(idmrun,"$3",access_j.pegeo(1..4),idm_char);
  8844.       idm_param(idmrun,"$4","      ",idm_char);
  8845.     else
  8846.       idm_param(idmrun,"$3","    ",idm_char);
  8847.       idm_param(idmrun,"$4",access_j.pegeo,idm_char);
  8848.     end if;
  8849.     idm_execute(idmrun);
  8850.     idm_fetch(idmrun);
  8851.   end if;
  8852.  
  8853.   if list_item.Trtype /= DELETE then
  8854.     idm_command(idmrun,"add_card_j $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  8855.                        "$11 $12 $13 $14 $15 $16");
  8856.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  8857.     idm_param(idmrun,"$4",system_date,idm_char);
  8858.     idm_param(idmrun,"$5",access_j.tpers,idm_char);
  8859.     if access_j.pegeo(5..6) = "  " then
  8860.       idm_param(idmrun,"$6",access_j.pegeo(1..4),idm_char);
  8861.       idm_param(idmrun,"$7","      ",idm_char);
  8862.     else
  8863.       idm_param(idmrun,"$7",access_j.pegeo,idm_char);
  8864.       idm_param(idmrun,"$6","    ",idm_char);
  8865.     end if;
  8866.     working_struc := string_to_integer(access_j.struc);
  8867.     working_auth  := string_to_integer(access_j.auth);
  8868.     working_asgd  := string_to_integer(access_j.asgd);
  8869.     working_postr := string_to_integer(access_j.postr);
  8870.     working_deps  := string_to_integer(access_j.deps);
  8871.     working_tdeps := string_to_integer(access_j.tdeps);
  8872.     working_caspw := string_to_integer(access_j.caspw);
  8873.     working_ccasp := string_to_integer(access_j.ccasp);
  8874.     if access_j.picda.year = 0 then
  8875.       working_picda(1..4) := "    ";
  8876.     else
  8877.       working_string(1..5) := integer'image(access_j.picda.year);
  8878.       working_picda(1..4)  := working_string(2..5);
  8879.     end if;
  8880.     if access_j.picda.month = 0 then
  8881.       working_picda(5..6) := "  ";
  8882.     elsif access_j.picda.month < 10 then
  8883.       working_picda(5)     := '0';
  8884.       working_string(1..2) := integer'image(access_j.picda.month);
  8885.       working_picda(6..6)  := working_string(2..2);
  8886.     else
  8887.       working_string(1..3) := integer'image(access_j.picda.month);
  8888.       working_picda(5..6)  := working_string(2..3);
  8889.     end if;
  8890.     if access_j.picda.day = 0 then
  8891.       working_picda(7..8) := "  ";
  8892.     elsif access_j.picda.day < 10 then
  8893.       working_picda(7)     := '0';
  8894.       working_string(1..2) := integer'image(access_j.picda.day);
  8895.       working_picda(8..8)  := working_string(2..2);
  8896.     else
  8897.       working_string(1..3) := integer'image(access_j.picda.day);
  8898.       working_picda(7..8)  := working_string(2..3);
  8899.     end if;
  8900.     working_secur := secur_types'image(list_item.secur);
  8901.     if list_item.Trtype /= CHANGE then
  8902.       idm_param(idmrun,"$2",working_secur,idm_char);
  8903.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  8904.       idm_param(idmrun,"$8",working_struc,idm_int1);
  8905.       idm_param(idmrun,"$9",working_auth,idm_int1);
  8906.       idm_param(idmrun,"$10",working_asgd,idm_int1);
  8907.       idm_param(idmrun,"$11",working_postr,idm_int1);
  8908.       idm_param(idmrun,"$11",working_deps,idm_int1);
  8909.       idm_param(idmrun,"$13",working_tdeps,idm_int1);
  8910.       idm_param(idmrun,"$14",working_picda,idm_char);
  8911.       idm_param(idmrun,"$15",working_caspw,idm_int1);
  8912.       idm_param(idmrun,"$16",working_ccasp,idm_int1);
  8913.     else
  8914.       if working_secur /= save_secur then
  8915.         idm_param(idmrun,"$2",working_secur,idm_char);
  8916.       else
  8917.         idm_param(idmrun,"$2",save_secur,idm_char);
  8918.       end if;
  8919.       if report_as_of_time /= save_date then
  8920.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  8921.       else
  8922.         idm_param(idmrun,"$3",save_date,idm_char);
  8923.       end if;
  8924.       if working_struc /= save_struc and access_j.struc /= "     " then
  8925.         idm_param(idmrun,"$8",working_struc,idm_int1);
  8926.       else
  8927.         idm_param(idmrun,"$8",save_struc,idm_int1);
  8928.       end if;
  8929.       if working_auth /= save_auth and access_j.auth /= "     " then
  8930.         idm_param(idmrun,"$9",working_auth,idm_int1);
  8931.       else
  8932.         idm_param(idmrun,"$9",save_auth,idm_int1);
  8933.       end if;
  8934.       if working_asgd /= save_asgd and access_j.asgd /= "     " then
  8935.         idm_param(idmrun,"$10",working_asgd,idm_int1);
  8936.       else
  8937.         idm_param(idmrun,"$10",save_asgd,idm_int1);
  8938.       end if;
  8939.       if access_j.postr = "#    " then
  8940.         idm_param(idmrun,"$11",0,idm_int1);
  8941.       elsif working_postr /= save_postr and
  8942.             access_j.postr /= "     " then
  8943.         idm_param(idmrun,"$11",working_postr,idm_int1);
  8944.       else
  8945.         idm_param(idmrun,"$11",save_postr,idm_int1);
  8946.       end if;
  8947.       if access_j.deps = "#    " then
  8948.         idm_param(idmrun,"$12",0,idm_int1);
  8949.       elsif working_deps /= save_deps and access_j.deps /= "     " then
  8950.         idm_param(idmrun,"$12",working_deps,idm_int1);
  8951.       else
  8952.         idm_param(idmrun,"$12",save_deps,idm_int1);
  8953.       end if;
  8954.       if access_j.tdeps = "#    " then
  8955.         idm_param(idmrun,"$13",0,idm_int1);
  8956.       elsif working_tdeps /= save_tdeps and
  8957.             access_j.tdeps /= "     " then
  8958.         idm_param(idmrun,"$13",working_tdeps,idm_int1);
  8959.       else
  8960.         idm_param(idmrun,"$13",save_tdeps,idm_int1);
  8961.       end if;
  8962.       if working_picda /= save_picda then
  8963.         idm_param(idmrun,"$14",working_picda,idm_char);
  8964.       else
  8965.         idm_param(idmrun,"$14",save_picda,idm_char);
  8966.       end if;
  8967.       if working_caspw /= save_caspw and access_j.caspw /= "     " then
  8968.         idm_param(idmrun,"$15",working_caspw,idm_int1);
  8969.       else
  8970.         idm_param(idmrun,"$15",save_caspw,idm_int1);
  8971.       end if;
  8972.       if working_ccasp /= save_ccasp and access_j.ccasp /= "     " then
  8973.         idm_param(idmrun,"$16",working_ccasp,idm_int1);
  8974.       else
  8975.         idm_param(idmrun,"$16",save_ccasp,idm_int1);
  8976.       end if;
  8977.     end if;
  8978.     idm_execute(idmrun);
  8979.     idm_fetch(idmrun);
  8980.   end if;
  8981.  
  8982. end process_card_j;
  8983.  
  8984. --*********************************************************************
  8985. --*
  8986. --*    PROCESS_CARD_K
  8987. --*
  8988. --*    This procedure will process the message cards of type 'K'.
  8989. --*    The record containing the card data is retrieved from the list,
  8990. --*    and the card is processed as a function of the transaction 
  8991. --*    code.
  8992. --*
  8993. --*********************************************************************
  8994.  
  8995. procedure process_card_k is
  8996.   save_tread : string(1..5);
  8997.   save_ready : integer;
  8998.   save_reasn : string(1..1);
  8999.   save_prrat : integer;
  9000.   save_prres : string(1..3);
  9001.   save_esrat : integer;
  9002.   save_esres : string(1..3);
  9003.   save_errat : integer;
  9004.   save_erres : string(1..3);
  9005.   save_trrat : integer;
  9006.   save_trres : string(1..3);
  9007.   save_secrn : string(1..3);
  9008.   save_terrn : string(1..3);
  9009.   save_carat : integer;
  9010.   save_cadat : string(1..8);
  9011.   save_lim   : integer;
  9012.   save_rlim  : string(1..1);
  9013.   save_ricda : string(1..8);
  9014.   working_ready : integer;
  9015.   working_prrat : integer;
  9016.   working_esrat : integer;
  9017.   working_errat : integer;
  9018.   working_trrat : integer;
  9019.   working_carat : integer;
  9020.   working_cadat : string(1..8) := "19000000";
  9021.   working_lim   : integer;
  9022.   working_ricda : string(1..8) := "19000000";
  9023. begin
  9024.  
  9025.   access_k := list_item.access_k;
  9026.  
  9027.   if list_item.Trtype = CHANGE then
  9028.     idm_command(idmrun,"return_card_k $1");
  9029.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9030.     idm_execute(idmrun);
  9031.     idm_fetch(idmrun);
  9032.     idm_column(idmrun,1,save_secur,length_of_string);
  9033.     idm_column(idmrun,2,save_date,length_of_string);
  9034.     idm_column(idmrun,3,save_tread,length_of_string);
  9035.     idm_column(idmrun,4,save_ready);
  9036.     idm_column(idmrun,5,save_reasn,length_of_string);
  9037.     idm_column(idmrun,6,save_prrat);
  9038.     idm_column(idmrun,7,save_prres,length_of_string);
  9039.     idm_column(idmrun,8,save_esrat);
  9040.     idm_column(idmrun,9,save_esres,length_of_string);
  9041.     idm_column(idmrun,10,save_errat);
  9042.     idm_column(idmrun,11,save_erres,length_of_string);
  9043.     idm_column(idmrun,12,save_trrat);
  9044.     idm_column(idmrun,13,save_trres,length_of_string);
  9045.     idm_column(idmrun,14,save_secrn,length_of_string);
  9046.     idm_column(idmrun,15,save_terrn,length_of_string);
  9047.     idm_column(idmrun,16,save_carat);
  9048.     idm_column(idmrun,17,save_cadat,length_of_string);
  9049.     idm_column(idmrun,18,save_lim);
  9050.     idm_column(idmrun,19,save_rlim,length_of_string);
  9051.     idm_column(idmrun,20,save_ricda,length_of_string);
  9052.   end if;
  9053.  
  9054.   if list_item.Trtype /= ADD then
  9055.     idm_command(idmrun,"delete_card_k $1");
  9056.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9057.     idm_execute(idmrun);
  9058.     idm_fetch(idmrun);
  9059.   end if;
  9060.  
  9061.   if list_item.Trtype /= DELETE then
  9062.     idm_command(idmrun,"add_card_k $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  9063.                        "$11 $12 $13 $14 $15 $16 $17 $18 $19 $20 " &
  9064.                        "$21 $22");
  9065.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9066.     idm_param(idmrun,"$4",system_date,idm_char);
  9067.     working_ready := string_to_integer(access_k.ready);
  9068.     working_prrat := string_to_integer(access_k.prrat);
  9069.     working_esrat := string_to_integer(access_k.esrat);
  9070.     working_errat := string_to_integer(access_k.errat);
  9071.     working_trrat := string_to_integer(access_k.trrat);
  9072.     working_carat := string_to_integer(access_k.carat);
  9073.     working_lim   := string_to_integer(access_k.lim);
  9074.     working_cadat(3..8) := access_k.cadat.yy & access_k.cadat.mm & access_k.cadat.dd;
  9075.     working_ricda(3..8) := access_k.ricda.yy & access_k.ricda.mm & access_k.ricda.dd;
  9076.     working_secur := secur_types'image(list_item.secur);
  9077.     if list_item.Trtype /= CHANGE then
  9078.       idm_param(idmrun,"$2",working_secur,idm_char);
  9079.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9080.       idm_param(idmrun,"$5",access_k.tread,idm_char);
  9081.       idm_param(idmrun,"$6",working_ready,idm_int1);
  9082.       idm_param(idmrun,"$7",access_k.reasn,idm_char);
  9083.       idm_param(idmrun,"$8",working_prrat,idm_int1);
  9084.       idm_param(idmrun,"$9",access_k.prres,idm_char);
  9085.       idm_param(idmrun,"$10",working_esrat,idm_int1);
  9086.       idm_param(idmrun,"$11",access_k.esres,idm_char);
  9087.       idm_param(idmrun,"$12",working_errat,idm_int1);
  9088.       idm_param(idmrun,"$13",access_k.erres,idm_char);
  9089.       idm_param(idmrun,"$14",working_trrat,idm_int1);
  9090.       idm_param(idmrun,"$15",access_k.trres,idm_char);
  9091.       idm_param(idmrun,"$16",access_k.secrn,idm_char);
  9092.       idm_param(idmrun,"$17",access_k.terrn,idm_char);
  9093.       idm_param(idmrun,"$18",working_carat,idm_int1);
  9094.       idm_param(idmrun,"$19",working_cadat,idm_char);
  9095.       idm_param(idmrun,"$20",working_lim,idm_int1);
  9096.       idm_param(idmrun,"$21",access_k.rlim,idm_char);
  9097.       idm_param(idmrun,"$22",working_ricda,idm_char);
  9098.     else
  9099.       if working_secur /= save_secur then
  9100.         idm_param(idmrun,"$2",working_secur,idm_char);
  9101.       else
  9102.         idm_param(idmrun,"$2",save_secur,idm_char);
  9103.       end if;
  9104.       if report_as_of_time /= save_date then
  9105.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9106.       else
  9107.         idm_param(idmrun,"$3",save_date,idm_char);
  9108.       end if;
  9109.       if access_k.tread /= save_tread and access_k.tread /= "     " then
  9110.         idm_param(idmrun,"$5",access_k.tread,idm_char);
  9111.       else
  9112.         idm_param(idmrun,"$5",save_tread,idm_char);
  9113.       end if;
  9114.       if working_ready /= save_ready and access_k.ready /= " " then
  9115.         idm_param(idmrun,"$6",working_ready,idm_int1);
  9116.       else
  9117.         idm_param(idmrun,"$6",save_ready,idm_int1);
  9118.       end if;
  9119.       if access_k.reasn /= save_reasn and access_k.reasn /= " " then
  9120.         idm_param(idmrun,"$7",access_k.reasn,idm_char);
  9121.       else
  9122.         idm_param(idmrun,"$7",save_reasn,idm_char);
  9123.       end if;
  9124.       if working_prrat /= save_prrat and access_k.prrat /= " " then
  9125.         idm_param(idmrun,"$8",working_prrat,idm_int1);
  9126.       else
  9127.         idm_param(idmrun,"$8",save_prrat,idm_int1);
  9128.       end if;
  9129.       if access_k.prres /= save_prres and access_k.prres /= "   " then
  9130.         idm_param(idmrun,"$9",access_k.prres,idm_char);
  9131.       else
  9132.         idm_param(idmrun,"$9",save_prres,idm_char);
  9133.       end if;
  9134.       if working_esrat /= save_esrat and access_k.esrat /= " " then
  9135.         idm_param(idmrun,"$10",working_esrat,idm_int1);
  9136.       else
  9137.         idm_param(idmrun,"$10",save_esrat,idm_int1);
  9138.       end if;
  9139.       if access_k.esres /= save_esres and access_k.esres /= "   " then
  9140.         idm_param(idmrun,"$11",access_k.esres,idm_char);
  9141.       else
  9142.         idm_param(idmrun,"$11",save_esres,idm_char);
  9143.       end if;
  9144.       if working_errat /= save_errat and access_k.errat /= " " then
  9145.         idm_param(idmrun,"$12",working_errat,idm_int1);
  9146.       else
  9147.         idm_param(idmrun,"$12",save_errat,idm_int1);
  9148.       end if;
  9149.       if access_k.erres /= save_erres and access_k.erres /= "   " then
  9150.         idm_param(idmrun,"$13",access_k.erres,idm_char);
  9151.       else
  9152.         idm_param(idmrun,"$13",save_erres,idm_char);
  9153.       end if;
  9154.       if working_trrat /= save_trrat and access_k.trrat /= " " then
  9155.         idm_param(idmrun,"$14",working_trrat,idm_int1);
  9156.       else
  9157.         idm_param(idmrun,"$14",save_trrat,idm_int1);
  9158.       end if;
  9159.       if access_k.trres /= save_trres and access_k.trres /= "   " then
  9160.         idm_param(idmrun,"$15",access_k.trres,idm_char);
  9161.       else
  9162.         idm_param(idmrun,"$15",save_trres,idm_char);
  9163.       end if;
  9164.       if access_k.secrn = "#  " then
  9165.         idm_param(idmrun,"$16","   ",idm_char);
  9166.       elsif access_k.secrn /= save_secrn and
  9167.             access_k.secrn /= "   " then
  9168.         idm_param(idmrun,"$16",access_k.secrn,idm_char);
  9169.       else
  9170.         idm_param(idmrun,"$16",save_secrn,idm_char);
  9171.       end if;
  9172.       if access_k.terrn = "#  " or access_k.secrn = "#  " then
  9173.         idm_param(idmrun,"$17","   ",idm_char);
  9174.       elsif access_k.terrn /= save_terrn and
  9175.             access_k.terrn /= "   " then
  9176.         idm_param(idmrun,"$17",access_k.terrn,idm_char);
  9177.       else
  9178.         idm_param(idmrun,"$17",save_terrn,idm_char);
  9179.       end if;
  9180.       if access_k.carat = "#" then
  9181.         idm_param(idmrun,"$18",0,idm_int1);
  9182.       elsif working_carat /= save_carat and access_k.carat /= " " then
  9183.         idm_param(idmrun,"$18",working_carat,idm_int1);
  9184.       else
  9185.         idm_param(idmrun,"$18",save_carat,idm_int1);
  9186.       end if;
  9187.       if access_k.cadat.yy = "# " or access_k.carat = "#" then
  9188.         idm_param(idmrun,"$19","        ",idm_char);
  9189.       elsif working_cadat /= save_cadat and
  9190.             working_cadat(3..8) /= "      " then
  9191.         idm_param(idmrun,"$19",working_cadat,idm_char);
  9192.       else
  9193.         idm_param(idmrun,"$19",save_cadat,idm_char);
  9194.       end if;
  9195.       if access_k.lim = "#" then
  9196.         idm_param(idmrun,"$20",0,idm_int1);
  9197.       elsif working_lim /= save_lim and access_k.lim /= " " then
  9198.         idm_param(idmrun,"$20",working_lim,idm_int1);
  9199.       else
  9200.         idm_param(idmrun,"$20",save_lim,idm_int1);
  9201.       end if;
  9202.       if access_k.rlim = "#" then
  9203.         idm_param(idmrun,"$21"," ",idm_char);
  9204.       elsif access_k.rlim /= save_rlim and access_k.rlim /= " " then
  9205.         idm_param(idmrun,"$21",access_k.rlim,idm_char);
  9206.       else
  9207.         idm_param(idmrun,"$21",save_rlim,idm_char);
  9208.       end if;
  9209.       if working_ricda /= save_ricda and
  9210.          working_ricda(3..8) /= "      " then
  9211.         idm_param(idmrun,"$22",working_ricda,idm_char);
  9212.       else
  9213.         idm_param(idmrun,"$22",save_ricda,idm_char);
  9214.       end if;
  9215.     end if;
  9216.     idm_execute(idmrun);
  9217.     idm_fetch(idmrun);
  9218.   end if;
  9219.  
  9220. end process_card_k;
  9221.  
  9222. --*********************************************************************
  9223. --*
  9224. --*    PROCESS_CARD_L
  9225. --*
  9226. --*    This procedure will process the message cards of type 'L'.
  9227. --*    The record containing the card data is retrieved from the list,
  9228. --*    and the card is processed as a function of the transaction 
  9229. --*    code.
  9230. --*
  9231. --*********************************************************************
  9232.  
  9233. procedure process_card_l is
  9234.   save_fordv : string(1..1);
  9235.   save_mepsa : integer;
  9236.   save_metal : integer;
  9237.   save_mepsd : integer;
  9238.   save_meord : integer;
  9239.   save_meorn : integer;
  9240.   save_meorc : integer;
  9241.   save_meoro : integer;
  9242.   save_crewa : integer;
  9243.   save_creal : integer;
  9244.   save_crewf : integer;
  9245.   save_crmrd : integer;
  9246.   save_crmrn : integer;
  9247.   save_crmrc : integer;
  9248.   save_crmro : integer;
  9249.   save_merec : string(1..6);
  9250.   working_merec : string(1..6);
  9251.   working_mepsa : integer;
  9252.   working_metal : integer;
  9253.   working_mepsd : integer;
  9254.   working_meord : integer;
  9255.   working_meorn : integer;
  9256.   working_meorc : integer;
  9257.   working_meoro : integer;
  9258.   working_crewa : integer;
  9259.   working_creal : integer;
  9260.   working_crewf : integer;
  9261.   working_crmrd : integer;
  9262.   working_crmrn : integer;
  9263.   working_crmrc : integer;
  9264.   working_crmro : integer;
  9265. begin
  9266.  
  9267.   access_l := list_item.access_l;
  9268.   working_merec := "      ";
  9269.  
  9270.   if list_item.Trtype = CHANGE then
  9271.     idm_command(idmrun,"return_card_l $1 $2");
  9272.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9273.     idm_param(idmrun,"$2",access_l.meqpt,idm_char);
  9274.     idm_execute(idmrun);
  9275.     idm_fetch(idmrun);
  9276.     idm_column(idmrun,1,save_secur,length_of_string);
  9277.     idm_column(idmrun,2,save_date,length_of_string);
  9278.     idm_column(idmrun,3,save_fordv,length_of_string);
  9279.     idm_column(idmrun,4,save_mepsa);
  9280.     idm_column(idmrun,5,save_metal);
  9281.     idm_column(idmrun,6,save_mepsd);
  9282.     idm_column(idmrun,7,save_meord);
  9283.     idm_column(idmrun,8,save_meorn);
  9284.     idm_column(idmrun,9,save_meorc);
  9285.     idm_column(idmrun,10,save_meoro);
  9286.     idm_column(idmrun,11,save_crewa);
  9287.     idm_column(idmrun,12,save_creal);
  9288.     idm_column(idmrun,13,save_crewf);
  9289.     idm_column(idmrun,14,save_crmrd);
  9290.     idm_column(idmrun,15,save_crmrn);
  9291.     idm_column(idmrun,16,save_crmrc);
  9292.     idm_column(idmrun,17,save_crmro);
  9293.     --
  9294.     -- retrieve for merec
  9295.     --
  9296.     idm_column(idmrun,1,save_merec,length_of_string);
  9297.   end if;
  9298.  
  9299.   if list_item.Trtype /= ADD then
  9300.     idm_command(idmrun,"delete_card_l $1 $2");
  9301.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9302.     idm_param(idmrun,"$2",access_l.meqpt,idm_char);
  9303.     idm_execute(idmrun);
  9304.     idm_fetch(idmrun);
  9305.     --
  9306.     -- delete for merec
  9307.     --
  9308.   end if;
  9309.  
  9310.   if list_item.Trtype /= DELETE then
  9311.     idm_command(idmrun,"add_card_l $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  9312.                        "$11 $12 $13 $14 $15 $16 $17 $18 $19 $20");
  9313.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9314.     idm_param(idmrun,"$4",system_date,idm_char);
  9315.     idm_param(idmrun,"$5",access_l.meqpt,idm_char);
  9316.     working_mepsa := string_to_integer(access_l.mepsa);
  9317.     working_metal := string_to_integer(access_l.metal);
  9318.     working_mepsd := string_to_integer(access_l.mepsd);
  9319.     working_meord := string_to_integer(access_l.meord);
  9320.     working_meorn := string_to_integer(access_l.meorn);
  9321.     working_meorc := string_to_integer(access_l.meorc);
  9322.     working_meoro := string_to_integer(access_l.meoro);
  9323.     working_crewa := string_to_integer(access_l.crewa);
  9324.     working_creal := string_to_integer(access_l.creal);
  9325.     working_crewf := string_to_integer(access_l.crewf);
  9326.     working_crmrd := string_to_integer(access_l.crmrd);
  9327.     working_crmrn := string_to_integer(access_l.crmrn);
  9328.     working_crmrc := string_to_integer(access_l.crmrc);
  9329.     working_crmro := string_to_integer(access_l.crmro);
  9330.     working_secur := secur_types'image(list_item.secur);
  9331.     working_merec := access_l.merec_1 &
  9332.                      access_l.merec_2 &
  9333.                      access_l.merec_3;
  9334.     if list_item.Trtype /= CHANGE then
  9335.       idm_param(idmrun,"$2",working_secur,idm_char);
  9336.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9337.       idm_param(idmrun,"$6",access_l.fordv,idm_char);
  9338.       idm_param(idmrun,"$7",working_mepsa,idm_int1);
  9339.       idm_param(idmrun,"$8",working_metal,idm_int1);
  9340.       idm_param(idmrun,"$9",working_mepsd,idm_int1);
  9341.       idm_param(idmrun,"$10",working_meord,idm_int1);
  9342.       idm_param(idmrun,"$11",working_meorn,idm_int1);
  9343.       idm_param(idmrun,"$12",working_meorc,idm_int1);
  9344.       idm_param(idmrun,"$13",working_meoro,idm_int1);
  9345.       idm_param(idmrun,"$14",working_crewa,idm_int1);
  9346.       idm_param(idmrun,"$15",working_creal,idm_int1);
  9347.       idm_param(idmrun,"$16",working_crewf,idm_int1);
  9348.       idm_param(idmrun,"$17",working_crmrd,idm_int1);
  9349.       idm_param(idmrun,"$18",working_crmrn,idm_int1);
  9350.       idm_param(idmrun,"$19",working_crmrc,idm_int1);
  9351.       idm_param(idmrun,"$20",working_crmro,idm_int1);
  9352.       --
  9353.       -- add for merec
  9354.       --
  9355.       idm_param(idmrun,"$1",working_merec,idm_char);
  9356.     else
  9357.       if working_secur /= save_secur then
  9358.         idm_param(idmrun,"$2",working_secur,idm_char);
  9359.       else
  9360.         idm_param(idmrun,"$2",save_secur,idm_char);
  9361.       end if;
  9362.       if report_as_of_time /= save_date then
  9363.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9364.       else
  9365.         idm_param(idmrun,"$3",save_date,idm_char);
  9366.       end if;
  9367.       if access_l.fordv /= save_fordv and access_l.fordv /= " " then
  9368.         idm_param(idmrun,"$6",access_l.fordv,idm_char);
  9369.       else
  9370.         idm_param(idmrun,"$6",save_fordv,idm_char);
  9371.       end if;
  9372.       if working_mepsa /= save_mepsa and access_l.mepsd /= "   " then
  9373.         idm_param(idmrun,"$7",working_mepsd,idm_int1);
  9374.       else
  9375.         idm_param(idmrun,"$7",save_mepsd,idm_int1);
  9376.       end if;
  9377.       if working_metal /= save_metal and access_l.metal /= "   " then
  9378.         idm_param(idmrun,"$8",working_metal,idm_int1);
  9379.       else
  9380.         idm_param(idmrun,"$8",save_metal,idm_int1);
  9381.       end if;
  9382.       if working_mepsd /= save_mepsd and access_l.mepsd /= "   " then
  9383.         idm_param(idmrun,"$9",working_mepsd,idm_int1);
  9384.       else
  9385.         idm_param(idmrun,"$9",save_mepsd,idm_int1);
  9386.       end if;
  9387.       if working_meord /= save_meord and access_l.meord /= "   " then
  9388.         idm_param(idmrun,"$10",working_meord,idm_int1);
  9389.       else
  9390.         idm_param(idmrun,"$10",save_meord,idm_int1);
  9391.       end if;
  9392.       if working_meorn /= save_meorn and access_l.meorn /= "   " then
  9393.         idm_param(idmrun,"$11",working_meorn,idm_int1);
  9394.       else
  9395.         idm_param(idmrun,"$11",save_meorn,idm_int1);
  9396.       end if;
  9397.       if working_meorc /= save_meorc and access_l.meorc /= "   " then
  9398.         idm_param(idmrun,"$12",working_meorc,idm_int1);
  9399.       else
  9400.         idm_param(idmrun,"$12",save_meorc,idm_int1);
  9401.       end if;
  9402.       if working_meoro /= save_meoro and access_l.meoro /= "   " then
  9403.         idm_param(idmrun,"$13",working_meoro,idm_int1);
  9404.       else
  9405.         idm_param(idmrun,"$13",save_meoro,idm_int1);
  9406.       end if;
  9407.       if working_crewa /= save_crewa and access_l.crewa /= "  " then
  9408.         idm_param(idmrun,"$14",working_crewa,idm_int1);
  9409.       else
  9410.         idm_param(idmrun,"$14",save_crewa,idm_int1);
  9411.       end if;
  9412.       if working_creal /= save_creal and access_l.creal /= "  " then
  9413.         idm_param(idmrun,"$15",working_creal,idm_int1);
  9414.       else
  9415.         idm_param(idmrun,"$15",save_creal,idm_int1);
  9416.       end if;
  9417.       if working_crewf /= save_crewf and access_l.crewf /= "  " then
  9418.         idm_param(idmrun,"$16",working_crewf,idm_int1);
  9419.       else
  9420.         idm_param(idmrun,"$16",save_crewf,idm_int1);
  9421.       end if;
  9422.       if working_crmrd /= save_crmrd and access_l.crmrd /= "  " then
  9423.         idm_param(idmrun,"$17",working_crmrd,idm_int1);
  9424.       else
  9425.         idm_param(idmrun,"$17",save_crmrd,idm_int1);
  9426.       end if;
  9427.       if working_crmrn /= save_crmrn and access_l.crmrn /= "  " then
  9428.         idm_param(idmrun,"$18",working_crmrn,idm_int1);
  9429.       else
  9430.         idm_param(idmrun,"$18",save_crmrn,idm_int1);
  9431.       end if;
  9432.       if working_crmrc /= save_crmrc and access_l.crmrc /= "  " then
  9433.         idm_param(idmrun,"$19",working_crmrc,idm_int1);
  9434.       else
  9435.         idm_param(idmrun,"$19",save_crmrc,idm_int1);
  9436.       end if;
  9437.       if working_crmro /= save_crmro and access_l.crmro /= "  " then
  9438.         idm_param(idmrun,"$20",working_crmro,idm_int1);
  9439.       else
  9440.         idm_param(idmrun,"$20",save_crmro,idm_int1);
  9441.       end if;
  9442.       --
  9443.       -- add for merec
  9444.       --
  9445.       if access_l.merec_1 = "# " then
  9446.         working_merec := "      ";
  9447.       elsif access_l.merec_1 /= save_merec(1..2) and
  9448.             access_l.merec_1 /= "  " then
  9449.         working_merec(1..2) := access_l.merec_1;
  9450.       else
  9451.         working_merec(1..2) := save_merec(1..2);
  9452.       end if;
  9453.       if access_l.merec_2 = "# " then
  9454.         working_merec(3..6) := "    ";
  9455.       elsif access_l.merec_2 /= save_merec(3..4) and
  9456.             access_l.merec_2 /= "  " then
  9457.         working_merec(3..4) := access_l.merec_2;
  9458.       else
  9459.         working_merec(3..4) := save_merec(3..4);
  9460.       end if;
  9461.       if access_l.merec_3 = "# " then
  9462.         working_merec(5..6) := "  ";
  9463.       elsif access_l.merec_3 /= save_merec(5..6) and
  9464.             access_l.merec_3 /= "  " then
  9465.         working_merec(5..6) := access_l.merec_3;
  9466.       else
  9467.         working_merec(5..6) := save_merec(5..6);
  9468.       end if;
  9469.       idm_param(idmrun,"$1",working_merec,idm_char);
  9470.     end if;
  9471.     idm_execute(idmrun);
  9472.     idm_fetch(idmrun);
  9473.   end if;
  9474.  
  9475. end process_card_l;
  9476.  
  9477.  
  9478.  
  9479. --*********************************************************************
  9480. --*
  9481. --*    PROCESS_CARD_M
  9482. --*
  9483. --*    This procedure will process the message cards of type 'M'.
  9484. --*    The record containing the card data is retrieved from the list,
  9485. --*    and the card is processed as a function of the transaction 
  9486. --*    code.
  9487. --*
  9488. --*********************************************************************
  9489.  
  9490. procedure process_card_m is
  9491.   save_mepsd : integer;
  9492.   save_meord : integer;
  9493.   save_meorn : integer;
  9494.   save_meorc : integer;
  9495.   save_meoro : integer;
  9496.   save_crewf : integer;
  9497.   save_crmrd : integer;
  9498.   save_crmrn : integer;
  9499.   save_crmrc : integer;
  9500.   save_crmro : integer;
  9501.   save_merec : string(1..6);
  9502.   working_merec : string(1..6);
  9503.   working_mepsd : integer;
  9504.   working_meord : integer;
  9505.   working_meorn : integer;
  9506.   working_meorc : integer;
  9507.   working_meoro : integer;
  9508.   working_crewf : integer;
  9509.   working_crmrd : integer;
  9510.   working_crmrn : integer;
  9511.   working_crmrc : integer;
  9512.   working_crmro : integer;
  9513. begin
  9514.  
  9515.   access_m := list_item.access_m;
  9516.   working_merec := "      ";
  9517.  
  9518.   if list_item.Trtype = CHANGE then
  9519.     idm_command(idmrun,"return_card_m $1 $2");
  9520.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9521.     idm_param(idmrun,"$2",access_m.meqpt,idm_char);
  9522.     idm_execute(idmrun);
  9523.     idm_fetch(idmrun);
  9524.     idm_column(idmrun,1,save_secur,length_of_string);
  9525.     idm_column(idmrun,2,save_date,length_of_string);
  9526.     idm_column(idmrun,3,save_mepsd);
  9527.     idm_column(idmrun,4,save_meord);
  9528.     idm_column(idmrun,5,save_meorn);
  9529.     idm_column(idmrun,6,save_meorc);
  9530.     idm_column(idmrun,7,save_meoro);
  9531.     idm_column(idmrun,8,save_crewf);
  9532.     idm_column(idmrun,9,save_crmrd);
  9533.     idm_column(idmrun,10,save_crmrn);
  9534.     idm_column(idmrun,11,save_crmrc);
  9535.     idm_column(idmrun,12,save_crmro);
  9536.     --
  9537.     -- retrieve for merec
  9538.     --
  9539.     idm_column(idmrun,1,save_merec,length_of_string);
  9540.   end if;
  9541.  
  9542.   if list_item.Trtype /= ADD then
  9543.     idm_command(idmrun,"delete_card_m $1 $2");
  9544.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9545.     idm_param(idmrun,"$2",access_m.meqpt,idm_char);
  9546.     idm_execute(idmrun);
  9547.     idm_fetch(idmrun);
  9548.     --
  9549.     -- delete for merec
  9550.     --
  9551.   end if;
  9552.  
  9553.   if list_item.Trtype /= DELETE then
  9554.     idm_command(idmrun,"add_card_m $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  9555.                        "$11 $12 $13 $14 $15 $16");
  9556.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9557.     idm_param(idmrun,"$4",system_date,idm_char);
  9558.     idm_param(idmrun,"$5",access_m.meqpt,idm_char);
  9559.     working_mepsd := string_to_integer(access_m.mepsd);
  9560.     working_meord := string_to_integer(access_m.meord);
  9561.     working_meorn := string_to_integer(access_m.meorn);
  9562.     working_meorc := string_to_integer(access_m.meorc);
  9563.     working_meoro := string_to_integer(access_m.meoro);
  9564.     working_crewf := string_to_integer(access_m.crewf);
  9565.     working_crmrd := string_to_integer(access_m.crmrd);
  9566.     working_crmrn := string_to_integer(access_m.crmrn);
  9567.     working_crmrc := string_to_integer(access_m.crmrc);
  9568.     working_crmro := string_to_integer(access_m.crmro);
  9569.     working_secur := secur_types'image(list_item.secur);
  9570.     working_merec := access_m.merec_1 &
  9571.                      access_m.merec_2 &
  9572.                      access_m.merec_3;
  9573.     if list_item.Trtype /= CHANGE then
  9574.       idm_param(idmrun,"$2",working_secur,idm_char);
  9575.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9576.       idm_param(idmrun,"$6",working_mepsd,idm_int1);
  9577.       idm_param(idmrun,"$7",working_meord,idm_int1);
  9578.       idm_param(idmrun,"$8",working_meorn,idm_int1);
  9579.       idm_param(idmrun,"$9",working_meorc,idm_int1);
  9580.       idm_param(idmrun,"$10",working_meoro,idm_int1);
  9581.       idm_param(idmrun,"$11",working_crewf,idm_int1);
  9582.       idm_param(idmrun,"$12",working_crmrd,idm_int1);
  9583.       idm_param(idmrun,"$13",working_crmrn,idm_int1);
  9584.       idm_param(idmrun,"$14",working_crmrc,idm_int1);
  9585.       idm_param(idmrun,"$15",working_crmro,idm_int1);
  9586.       --
  9587.       -- add for merec
  9588.       --
  9589.       idm_param(idmrun,"$16",working_merec,idm_char);
  9590.     else
  9591.       if working_secur /= save_secur then
  9592.         idm_param(idmrun,"$2",working_secur,idm_char);
  9593.       else
  9594.         idm_param(idmrun,"$2",save_secur,idm_char);
  9595.       end if;
  9596.       if report_as_of_time /= save_date then
  9597.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9598.       else
  9599.         idm_param(idmrun,"$3",save_date,idm_char);
  9600.       end if;
  9601.       if working_mepsd /= save_mepsd and access_m.mepsd /= "   " then
  9602.         idm_param(idmrun,"$6",working_mepsd,idm_int1);
  9603.       else
  9604.         idm_param(idmrun,"$6",save_mepsd,idm_int1);
  9605.       end if;
  9606.       if working_meord /= save_meord and access_m.meord /= "   " then
  9607.         idm_param(idmrun,"$7",working_meord,idm_int1);
  9608.       else
  9609.         idm_param(idmrun,"$7",save_meord,idm_int1);
  9610.       end if;
  9611.       if working_meorn /= save_meorn and access_m.meorn /= "   " then
  9612.         idm_param(idmrun,"$8",working_meorn,idm_int1);
  9613.       else
  9614.         idm_param(idmrun,"$8",save_meorn,idm_int1);
  9615.       end if;
  9616.       if working_meorc /= save_meorc and access_m.meorc /= "   " then
  9617.         idm_param(idmrun,"$9",working_meorc,idm_int1);
  9618.       else
  9619.         idm_param(idmrun,"$9",access_m.meorc,idm_int1);
  9620.       end if;
  9621.       if working_meoro /= save_meoro and access_m.meoro /= "   " then
  9622.         idm_param(idmrun,"$10",working_meoro,idm_int1);
  9623.       else
  9624.         idm_param(idmrun,"$10",save_meoro,idm_int1);
  9625.       end if;
  9626.       if working_crewf /= save_crewf and access_m.crewf /= "  " then
  9627.         idm_param(idmrun,"$11",working_crewf,idm_int1);
  9628.       else
  9629.         idm_param(idmrun,"$11",save_crewf,idm_int1);
  9630.       end if;
  9631.       if working_crmrd /= save_crmrd and access_m.crmrd /= "  " then
  9632.         idm_param(idmrun,"$12",working_crmrd,idm_int1);
  9633.       else
  9634.         idm_param(idmrun,"$12",save_crmrd,idm_int1);
  9635.       end if;
  9636.       if working_crmrn /= save_crmrn and access_m.crmrn /= "  " then
  9637.         idm_param(idmrun,"$13",working_crmrn,idm_int1);
  9638.       else
  9639.         idm_param(idmrun,"$13",save_crmrn,idm_int1);
  9640.       end if;
  9641.       if working_crmrc /= save_crmrc and access_m.crmrc /= "  " then
  9642.         idm_param(idmrun,"$14",working_crmrc,idm_int1);
  9643.       else
  9644.         idm_param(idmrun,"$14",save_crmrc,idm_int1);
  9645.       end if;
  9646.       if working_crmro /= save_crmro and access_m.crmro /= "  " then
  9647.         idm_param(idmrun,"$15",working_crmro,idm_int1);
  9648.       else
  9649.         idm_param(idmrun,"$15",save_crmro,idm_int1);
  9650.       end if;
  9651.       --
  9652.       -- add for merec
  9653.       --
  9654.       if access_m.merec_1 = "# " then
  9655.         working_merec := "      ";
  9656.       elsif access_m.merec_1 /= save_merec(1..2) and
  9657.             access_m.merec_1 /= "  " then
  9658.         working_merec(1..2) := access_m.merec_1;
  9659.       else
  9660.         working_merec(1..2) := save_merec(1..2);
  9661.       end if;
  9662.       if access_m.merec_2 = "# " then
  9663.         working_merec(3..6) := "    ";
  9664.       elsif access_m.merec_2 /= save_merec(3..4) and
  9665.             access_m.merec_2 /= "  " then
  9666.         working_merec(3..4) := access_m.merec_2;
  9667.       else
  9668.         working_merec(3..4) := save_merec(3..4);
  9669.       end if;
  9670.       if access_m.merec_3 = "# " then
  9671.         working_merec(5..6) := "  ";
  9672.       elsif access_m.merec_3 /= save_merec(5..6) and
  9673.             access_m.merec_3 /= "  " then
  9674.         working_merec(5..6) := access_m.merec_3;
  9675.       else
  9676.         working_merec(5..6) := save_merec(5..6);
  9677.       end if;
  9678.       idm_param(idmrun,"$16",working_merec,idm_char);
  9679.     end if;
  9680.     idm_execute(idmrun);
  9681.     idm_fetch(idmrun);
  9682.   end if;
  9683.  
  9684. end process_card_m;
  9685.  
  9686. --*********************************************************************
  9687. --*
  9688. --*    PROCESS_CARD_N
  9689. --*
  9690. --*    This procedure will process the message cards of type 'N'.
  9691. --*    The record containing the card data is retrieved from the list,
  9692. --*    and the card is processed as a function of the transaction 
  9693. --*    code.
  9694. --*
  9695. --*********************************************************************
  9696.  
  9697. procedure process_card_n is
  9698.   save_putc  : string(1..5);
  9699.   save_frqno : string(1..5);
  9700.   save_pleac : string(1..1);
  9701.   save_ddp   : string(1..2);
  9702.   save_ddp_d : string(1..8);
  9703.   save_ddp_h : integer;
  9704.   save_mdt   : integer;
  9705.   working_ddp_d : string(1..8) := "19000000";
  9706.   working_ddp_h : integer;
  9707.   working_mdt   : integer;
  9708. begin
  9709.  
  9710.   access_n := list_item.access_n;
  9711.  
  9712.   if list_item.Trtype = CHANGE then
  9713.     idm_command(idmrun,"return_card_n $1 $2");
  9714.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9715.     idm_param(idmrun,"$2",access_n.pin,idm_char);
  9716.     idm_execute(idmrun);
  9717.     idm_fetch(idmrun);
  9718.     idm_column(idmrun,1,save_secur,length_of_string);
  9719.     idm_column(idmrun,2,save_date,length_of_string);
  9720.     idm_column(idmrun,3,save_putc,length_of_string);
  9721.     idm_column(idmrun,4,save_frqno,length_of_string);
  9722.     idm_column(idmrun,5,save_pleac,length_of_string);
  9723.     idm_column(idmrun,6,save_ddp,length_of_string);
  9724.     idm_column(idmrun,7,save_ddp_d,length_of_string);
  9725.     idm_column(idmrun,8,save_ddp_h);
  9726.     idm_column(idmrun,9,save_mdt);
  9727.   end if;
  9728.  
  9729.   if list_item.Trtype /= ADD then
  9730.     idm_command(idmrun,"delete_card_n $1 $2");
  9731.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9732.     idm_param(idmrun,"$2",access_n.pin,idm_char);
  9733.     idm_execute(idmrun);
  9734.     idm_fetch(idmrun);
  9735.   end if;
  9736.  
  9737.   if list_item.Trtype /= DELETE then
  9738.     idm_command(idmrun,"add_card_n $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  9739.                        "$11 $12");
  9740.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9741.     idm_param(idmrun,"$4",system_date,idm_char);
  9742.     idm_param(idmrun,"$5",access_n.pin,idm_char);
  9743.     working_ddp_d(3..8) := access_n.ddprd.yy &
  9744.                            access_n.ddprd.mm & access_n.ddprd.dd;
  9745.     working_ddp_h := string_to_integer(access_n.ddp);
  9746.     working_mdt   := string_to_integer(access_n.mdt.DDD &
  9747.                                        access_n.mdt.HH);
  9748.     working_secur := secur_types'image(list_item.secur);
  9749.     if list_item.Trtype /= CHANGE then
  9750.       idm_param(idmrun,"$2",working_secur,idm_char);
  9751.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9752.       idm_param(idmrun,"$6",access_n.putc,idm_char);
  9753.       idm_param(idmrun,"$7",access_n.frqno,idm_char);
  9754.       idm_param(idmrun,"$8",access_n.pleac,idm_char);
  9755.       idm_param(idmrun,"$9",access_n.ddp,idm_char);
  9756.       idm_param(idmrun,"$10",working_ddp_d,idm_char);
  9757.       idm_param(idmrun,"$11",working_ddp_h,idm_int1);
  9758.       idm_param(idmrun,"$12",working_mdt,idm_int1);
  9759.     else
  9760.       if working_secur /= save_secur then
  9761.         idm_param(idmrun,"$2",working_secur,idm_char);
  9762.       else
  9763.         idm_param(idmrun,"$2",save_secur,idm_char);
  9764.       end if;
  9765.       if report_as_of_time /= save_date then
  9766.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9767.       else
  9768.         idm_param(idmrun,"$3",save_date,idm_char);
  9769.       end if;
  9770.       if access_n.putc = "#    " then
  9771.         idm_param(idmrun,"$6","     ",idm_char);
  9772.       elsif access_n.putc /= save_putc and access_n.putc /= "     " then
  9773.         idm_param(idmrun,"$6",access_n.putc,idm_char);
  9774.       else
  9775.         idm_param(idmrun,"$6",save_putc,idm_char);
  9776.       end if;
  9777.       if access_n.frqno /= save_frqno and access_n.frqno /= "     " then
  9778.         idm_param(idmrun,"$7",access_n.frqno,idm_char);
  9779.       else
  9780.         idm_param(idmrun,"$7",save_frqno,idm_char);
  9781.       end if;
  9782.       if access_n.pleac /= save_pleac and access_n.pleac /= " " then
  9783.         idm_param(idmrun,"$8",access_n.pleac,idm_char);
  9784.       else
  9785.         idm_param(idmrun,"$8",save_pleac,idm_char);
  9786.       end if;
  9787.       if access_n.ddp /= save_ddp and access_n.ddp /= "  " then
  9788.         idm_param(idmrun,"$9",access_n.ddp,idm_char);
  9789.       else
  9790.         idm_param(idmrun,"$9",save_ddp,idm_char);
  9791.       end if;
  9792.       if working_ddp_d /= save_ddp_d and
  9793.          working_ddp_d(3..8) /= "      " then
  9794.         idm_param(idmrun,"$10",working_ddp_d,idm_char);
  9795.       else
  9796.         idm_param(idmrun,"$10",save_ddp_d,idm_char);
  9797.       end if;
  9798.       if working_ddp_h /= save_ddp_h and access_n.ddprd.hh /= "  " then
  9799.         idm_param(idmrun,"$11",working_ddp_h,idm_int1);
  9800.       else
  9801.         idm_param(idmrun,"$11",save_ddp_h,idm_int1);
  9802.       end if;
  9803.       if working_mdt /= save_mdt and
  9804.          access_n.mdt.ddd & access_n.mdt.hh /= "     " then
  9805.         idm_param(idmrun,"$12",working_mdt,idm_int1);
  9806.       else
  9807.         idm_param(idmrun,"$12",save_mdt,idm_int1);
  9808.       end if;
  9809.     end if;
  9810.     idm_execute(idmrun);
  9811.     idm_fetch(idmrun);
  9812.   end if;
  9813.  
  9814. end process_card_n;
  9815.  
  9816. --*********************************************************************
  9817. --*
  9818. --*    PROCESS_CARD_P
  9819. --*
  9820. --*    This procedure will process the message cards of type 'P'.
  9821. --*    The record containing the card data is retrieved from the list,
  9822. --*    and the card is processed as a function of the transaction 
  9823. --*    code.
  9824. --*
  9825. --*********************************************************************
  9826.  
  9827. procedure process_card_p is
  9828.   save_tpgeo : string(1..4);
  9829.   save_tpuic : string(1..6);
  9830.   save_numbr : integer;
  9831.   save_numea : integer;
  9832.   save_alret : integer;
  9833.   working_numbr : integer;
  9834.   working_numea : integer;
  9835.   working_alret : integer;
  9836.   working_altyp : string(1..2);
  9837. begin
  9838.  
  9839.   access_p := list_item.access_p;
  9840.   working_altyp := altyp_types'image(access_p.altyp);
  9841.  
  9842.   if list_item.Trtype = CHANGE then
  9843.     idm_command(idmrun,"return_card_p $1 $2 $3 $4");
  9844.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9845.     idm_param(idmrun,"$2",access_p.meqpt,idm_char);
  9846.     idm_param(idmrun,"$3",access_p.pin,idm_char);
  9847.     idm_param(idmrun,"$4",working_altyp,idm_char);
  9848.     idm_execute(idmrun);
  9849.     idm_fetch(idmrun);
  9850.     idm_column(idmrun,1,save_secur,length_of_string);
  9851.     idm_column(idmrun,2,save_date,length_of_string);
  9852.     idm_column(idmrun,3,save_tpgeo,length_of_string);
  9853.     idm_column(idmrun,4,save_tpuic,length_of_string);
  9854.     idm_column(idmrun,5,save_numbr);
  9855.     idm_column(idmrun,6,save_numea);
  9856.     idm_column(idmrun,7,save_alret);
  9857.   end if;
  9858.  
  9859.   if list_item.Trtype /= ADD then
  9860.     idm_command(idmrun,"delete_card_p $1 $2 $3 $4");
  9861.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9862.     idm_param(idmrun,"$2",access_p.meqpt,idm_char);
  9863.     idm_param(idmrun,"$3",access_p.pin,idm_char);
  9864.     idm_param(idmrun,"$4",working_altyp,idm_char);
  9865.     idm_execute(idmrun);
  9866.     idm_fetch(idmrun);
  9867.   end if;
  9868.  
  9869.   if list_item.Trtype /= DELETE then
  9870.     idm_command(idmrun,"add_card_p $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  9871.                        "$11 $12");
  9872.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9873.     idm_param(idmrun,"$4",system_date,idm_char);
  9874.     idm_param(idmrun,"$5",access_p.meqpt,idm_char);
  9875.     idm_param(idmrun,"$6",access_p.pin,idm_char);
  9876.     idm_param(idmrun,"$7",working_altyp,idm_char);
  9877.     working_numbr := string_to_integer(access_p.numbr);
  9878.     working_numea := string_to_integer(access_p.numea);
  9879.     working_alret := string_to_integer(access_p.alret.hhh &
  9880.                                        access_p.alret.mm);
  9881.     working_secur := secur_types'image(list_item.secur);
  9882.     if list_item.Trtype /= CHANGE then
  9883.       idm_param(idmrun,"$2",working_secur,idm_char);
  9884.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9885.       if access_p.tpgeo(5..6) = "  " then
  9886.         idm_param(idmrun,"$8",access_p.tpgeo(1..4),idm_char);
  9887.         idm_param(idmrun,"$9","      ",idm_char);
  9888.       else
  9889.         idm_param(idmrun,"$9",access_p.tpgeo,idm_char);
  9890.         idm_param(idmrun,"$8","    ",idm_char);
  9891.       end if;
  9892.       idm_param(idmrun,"$10",working_numbr,idm_int1);
  9893.       idm_param(idmrun,"$11",working_numea,idm_int1);
  9894.       idm_param(idmrun,"$12",working_alret,idm_int1);
  9895.     else
  9896.       if working_secur /= save_secur then
  9897.         idm_param(idmrun,"$2",working_secur,idm_char);
  9898.       else
  9899.         idm_param(idmrun,"$2",save_secur,idm_char);
  9900.       end if;
  9901.       if report_as_of_time /= save_date then
  9902.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  9903.       else
  9904.         idm_param(idmrun,"$3",save_date,idm_char);
  9905.       end if;
  9906.       if access_p.tpgeo(5..6) = "  " then
  9907.         if access_p.tpgeo(1..4) /= save_tpgeo and
  9908.            access_p.tpgeo(1..4) /= "    " then
  9909.           idm_param(idmrun,"$8",access_p.tpgeo(1..4),idm_char);
  9910.         else
  9911.           idm_param(idmrun,"$8",save_tpgeo(1..4),idm_char);
  9912.         end if;
  9913.       elsif access_p.tpgeo /= save_tpuic and
  9914.             access_p.tpgeo /= "      " then
  9915.         idm_param(idmrun,"$9",access_p.tpgeo,idm_char);
  9916.       else
  9917.         idm_param(idmrun,"$9",save_tpuic,idm_char);
  9918.       end if;
  9919.       if working_numbr /= save_numbr and access_p.numbr /= "   " then
  9920.         idm_param(idmrun,"$10",working_numbr,idm_int1);
  9921.       else
  9922.         idm_param(idmrun,"$10",save_numbr,idm_int1);
  9923.       end if;
  9924.       if working_numea /= save_numea and access_p.numea /= "   " then
  9925.         idm_param(idmrun,"$11",working_numea,idm_int1);
  9926.       else
  9927.         idm_param(idmrun,"$11",save_numea,idm_int1);
  9928.       end if;
  9929.       if working_alret /= save_alret and
  9930.          access_p.alret.hhh & access_p.alret.mm /= "     " then
  9931.         idm_param(idmrun,"$12",working_alret,idm_int1);
  9932.       else
  9933.         idm_param(idmrun,"$12",save_alret,idm_int1);
  9934.       end if;
  9935.     end if;
  9936.     idm_execute(idmrun);
  9937.     idm_fetch(idmrun);
  9938.   end if;
  9939.  
  9940. end process_card_p;
  9941.  
  9942.  
  9943. --*********************************************************************
  9944. --*
  9945. --*    PROCESS_CARD_Q
  9946. --*
  9947. --*    This procedure will process the message cards of type 'Q'.
  9948. --*    The record containing the card data is retrieved from the list,
  9949. --*    and the card is processed as a function of the transaction 
  9950. --*    code.
  9951. --*
  9952. --*********************************************************************
  9953.  
  9954. procedure process_card_q is
  9955.   save_pin   : string(1..5);
  9956.   save_altyp : string(1..2);
  9957.   save_wpnco : string(1..7);
  9958.   save_nuqpt : string(1..13);
  9959.   save_numwr : integer;
  9960.   save_nugun : integer;
  9961.   save_numwb : integer;
  9962.   save_nusto : string(1..3);
  9963.   save_nuecc : integer;
  9964.   save_rtime : integer;
  9965.   save_dssta : string(1..1);
  9966.   save_dsgeo : string(1..4);
  9967.   save_dsuic : string(1..6);
  9968.   save_rfdgs : string(1..5);
  9969.   working_numwr : integer;
  9970.   working_nugun : integer;
  9971.   working_numwb : integer;
  9972.   working_nuecc : integer;
  9973.   working_rtime : integer;
  9974. begin
  9975.  
  9976.   access_q := list_item.access_q;
  9977.  
  9978.   if list_item.Trtype = CHANGE then
  9979.     idm_command(idmrun,"return_card_q $1 $2");
  9980.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  9981.     idm_param(idmrun,"$2",access_q.nuseq,idm_char);
  9982.     idm_execute(idmrun);
  9983.     idm_fetch(idmrun);
  9984.     idm_column(idmrun,1,save_secur,length_of_string);
  9985.     idm_column(idmrun,2,save_date,length_of_string);
  9986.     idm_column(idmrun,3,save_pin,length_of_string);
  9987.     idm_column(idmrun,4,save_altyp,length_of_string);
  9988.     idm_column(idmrun,5,save_wpnco,length_of_string);
  9989.     idm_column(idmrun,6,save_nuqpt,length_of_string);
  9990.     idm_column(idmrun,7,save_numwr);
  9991.     idm_column(idmrun,8,save_nugun);
  9992.     idm_column(idmrun,9,save_numwb);
  9993.     idm_column(idmrun,10,save_nusto,length_of_string);
  9994.     idm_column(idmrun,11,save_nuecc);
  9995.     idm_column(idmrun,12,save_rtime);
  9996.     idm_column(idmrun,13,save_dssta,length_of_string);
  9997.     idm_column(idmrun,14,save_dsgeo,length_of_string);
  9998.     idm_column(idmrun,15,save_dsuic,length_of_string);
  9999.     --
  10000.     -- retrieve for RFDGS
  10001.     --
  10002.     idm_column(idmrun,1,save_rfdgs,length_of_string);
  10003.   end if;
  10004.  
  10005.   if list_item.Trtype /= ADD then
  10006.     idm_command(idmrun,"delete_card_q $1 $2");
  10007.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10008.     idm_param(idmrun,"$2",access_q.nuseq,idm_char);
  10009.     idm_execute(idmrun);
  10010.     idm_fetch(idmrun);
  10011.     --
  10012.     -- delete for RFDGS
  10013.     --
  10014.   end if;
  10015.  
  10016.   if list_item.Trtype /= DELETE then
  10017.     idm_command(idmrun,"add_card_q $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  10018.                        "$11 $12 $13 $14 $15 $16 $17 $18 $19");
  10019.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10020.     idm_param(idmrun,"$4",system_date,idm_char);
  10021.     idm_param(idmrun,"$5",access_q.nuseq,idm_char);
  10022.     working_numwr := string_to_integer(access_q.numwr);
  10023.     working_nugun := string_to_integer(access_q.nugun);
  10024.     working_numwb := string_to_integer(access_q.numwb);
  10025.     working_nuecc := string_to_integer(access_q.nuecc);
  10026.     working_rtime := string_to_integer(access_q.rtime);
  10027.     working_secur := secur_types'image(list_item.secur);
  10028.     if list_item.Trtype /= CHANGE then
  10029.       idm_param(idmrun,"$2",working_secur,idm_char);
  10030.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10031.       idm_param(idmrun,"$6",access_q.pin,idm_char);
  10032.       idm_param(idmrun,"$7",access_q.altyp,idm_char);
  10033.       idm_param(idmrun,"$8",access_q.wpnco,idm_char);
  10034.       idm_param(idmrun,"$9",access_q.nuqpt,idm_char);
  10035.       idm_param(idmrun,"$10",working_numwr,idm_int1);
  10036.       idm_param(idmrun,"$11",working_nugun,idm_int1);
  10037.       idm_param(idmrun,"$12",working_numwb,idm_int1);
  10038.       idm_param(idmrun,"$13",access_q.nusto,idm_char);
  10039.       idm_param(idmrun,"$14",working_nuecc,idm_int1);
  10040.       idm_param(idmrun,"$15",working_rtime,idm_int1);
  10041.       idm_param(idmrun,"$16",access_q.dssta,idm_char);
  10042.       if access_q.dsgeo(5..6) = "  " then
  10043.         idm_param(idmrun,"$17",access_q.dsgeo(1..4),idm_char);
  10044.         idm_param(idmrun,"$18","      ",idm_char);
  10045.       else
  10046.         idm_param(idmrun,"$18",access_q.dsgeo,idm_char);
  10047.         idm_param(idmrun,"$17","    ",idm_char);
  10048.       end if;
  10049.       --
  10050.       -- add for RFDGS
  10051.       --
  10052.       idm_param(idmrun,"$19",access_q.rfdgs,idm_char);
  10053.     else
  10054.       if working_secur /= save_secur then
  10055.         idm_param(idmrun,"$2",working_secur,idm_char);
  10056.       else
  10057.         idm_param(idmrun,"$2",save_secur,idm_char);
  10058.       end if;
  10059.       if report_as_of_time /= save_date then
  10060.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10061.       else
  10062.         idm_param(idmrun,"$3",save_date,idm_char);
  10063.       end if;
  10064.       if access_q.pin /= save_pin and access_q.pin /= "     " then
  10065.         idm_param(idmrun,"$6",access_q.pin,idm_char);
  10066.       else
  10067.         idm_param(idmrun,"$6",save_pin,idm_char);
  10068.       end if;
  10069.       if access_q.altyp = "# " then
  10070.         idm_param(idmrun,"$7","  ",idm_char);
  10071.       elsif access_q.altyp /= save_altyp and access_q.altyp /= "  " then
  10072.         idm_param(idmrun,"$7",access_q.altyp,idm_char);
  10073.       else
  10074.         idm_param(idmrun,"$7",save_altyp,idm_char);
  10075.       end if;
  10076.       if access_q.wpnco /= save_wpnco and
  10077.          access_q.wpnco /= "       " then
  10078.         idm_param(idmrun,"$8",access_q.wpnco,idm_char);
  10079.       else
  10080.         idm_param(idmrun,"$8",save_wpnco,idm_char);
  10081.       end if;
  10082.       if access_q.nuqpt /= save_nuqpt(1..10) and
  10083.          access_q.nuqpt /= "          " then
  10084.         idm_param(idmrun,"$9",access_q.nuqpt,idm_char);
  10085.       else
  10086.         idm_param(idmrun,"$9",save_nuqpt,idm_char);
  10087.       end if;
  10088.       if access_q.numwr = "# " then
  10089.         idm_param(idmrun,"$10",0,idm_int1);
  10090.       elsif working_numwr /= save_numwr and access_q.numwr /= "  " then
  10091.         idm_param(idmrun,"$10",working_numwr,idm_int1);
  10092.       else
  10093.         idm_param(idmrun,"$10",save_numwr,idm_int1);
  10094.       end if;
  10095.       if access_q.nugun = "# " then
  10096.         idm_param(idmrun,"$11",0,idm_int1);
  10097.       elsif working_nugun /= save_nugun and access_q.nugun /= "  " then
  10098.         idm_param(idmrun,"$11",working_nugun,idm_int1);
  10099.       else
  10100.         idm_param(idmrun,"$11",save_nugun,idm_int1);
  10101.       end if;
  10102.       if access_q.numwb = "# " then
  10103.         idm_param(idmrun,"$12",0,idm_int1);
  10104.       elsif working_numwb /= save_numwb and access_q.numwb /= "  " then
  10105.         idm_param(idmrun,"$12",working_numwb,idm_int1);
  10106.       else
  10107.         idm_param(idmrun,"$12",save_numwb,idm_int1);
  10108.       end if;
  10109.       if access_q.nusto = "#  " then
  10110.         idm_param(idmrun,"$13","   ",idm_char);
  10111.       elsif access_q.nusto /= save_nusto and
  10112.             access_q.nusto /= "   " then
  10113.         idm_param(idmrun,"$13",access_q.nusto,idm_char);
  10114.       else
  10115.         idm_param(idmrun,"$13",save_nusto,idm_char);
  10116.       end if;
  10117.       if access_q.nuecc = "# " then
  10118.         idm_param(idmrun,"$14",0,idm_int1);
  10119.       elsif working_nuecc /= save_nuecc and access_q.nuecc /= "  " then
  10120.         idm_param(idmrun,"$14",working_nuecc,idm_int1);
  10121.       else
  10122.         idm_param(idmrun,"$14",save_nuecc,idm_int1);
  10123.       end if;
  10124.       if working_rtime /= save_rtime and access_q.rtime /= "     " then
  10125.         idm_param(idmrun,"$15",working_rtime,idm_int1);
  10126.       else
  10127.         idm_param(idmrun,"$15",save_rtime,idm_int1);
  10128.       end if;
  10129.       if access_q.dssta = "#" then
  10130.         idm_param(idmrun,"$16"," ",idm_char);
  10131.       elsif access_q.dssta /= save_dssta and access_q.dssta /= " " then
  10132.         idm_param(idmrun,"$16",access_q.dssta,idm_char);
  10133.       else
  10134.         idm_param(idmrun,"$16",save_dssta,idm_char);
  10135.       end if;
  10136.       if access_q.dsgeo(5..6) = "  " then
  10137.         if access_q.dsgeo(1..4) /= save_dsgeo and
  10138.            access_q.dsgeo(1..4) /= "    " then
  10139.           idm_param(idmrun,"$17",access_q.dsgeo(1..4),idm_char);
  10140.         else
  10141.           idm_param(idmrun,"$17",save_dsgeo,idm_char);
  10142.         end if;
  10143.       elsif access_q.dsgeo /= save_dsuic and
  10144.             access_q.dsgeo /= "      " then
  10145.         idm_param(idmrun,"$18",access_q.dsgeo,idm_char);
  10146.       else
  10147.         idm_param(idmrun,"$18",save_dsuic,idm_char);
  10148.       end if;
  10149.       --
  10150.       -- add for RFDGS
  10151.       --
  10152.       if access_q.rfdgs = "#    " then
  10153.         idm_param(idmrun,"$19","     ",idm_char);
  10154.       elsif access_q.rfdgs /= save_rfdgs and
  10155.             access_q.rfdgs /= "     " then
  10156.         idm_param(idmrun,"$19",access_q.rfdgs,idm_char);
  10157.       else
  10158.         idm_param(idmrun,"$19",save_rfdgs,idm_char);
  10159.       end if;
  10160.     end if;
  10161.     idm_execute(idmrun);
  10162.     idm_fetch(idmrun);
  10163.   end if;
  10164.  
  10165. end process_card_q;
  10166.  
  10167. --*********************************************************************
  10168. --*
  10169. --*    PROCESS_CARD_R
  10170. --*
  10171. --*    This procedure will process the message cards of type 'R'.
  10172. --*    The record containing the card data is retrieved from the list,
  10173. --*    and the card is processed as a function of the transaction 
  10174. --*    code.
  10175. --*
  10176. --*********************************************************************
  10177.  
  10178. procedure process_card_r is
  10179.   save_label   : string(1..5);
  10180.   save_remrk   : string(1..240);
  10181.   save_remrk_x : string(1..210);
  10182. begin
  10183.  
  10184.   access_r := list_item.access_r;
  10185.  
  10186.   if list_item.Trtype = CHANGE then
  10187.     idm_command(idmrun,"return_card_r $1 $2");
  10188.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10189.     idm_param(idmrun,"$2",access_r.rmkid,idm_char);
  10190.     idm_execute(idmrun);
  10191.     idm_fetch(idmrun);
  10192.     idm_column(idmrun,1,save_secur,length_of_string);
  10193.     idm_column(idmrun,2,save_date,length_of_string);
  10194.     idm_column(idmrun,3,save_label,length_of_string);
  10195.     idm_column(idmrun,4,save_remrk,length_of_string);
  10196.     idm_column(idmrun,5,save_remrk_x,length_of_string);
  10197.   end if;
  10198.  
  10199.   if list_item.Trtype /= ADD then
  10200.     idm_command(idmrun,"delete_card_r $1 $2");
  10201.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10202.     idm_param(idmrun,"$2",access_r.rmkid,idm_char);
  10203.     idm_execute(idmrun);
  10204.     idm_fetch(idmrun);
  10205.   end if;
  10206.  
  10207.   if list_item.Trtype /= DELETE then
  10208.     idm_command(idmrun,"add_card_r $1 $2 $3 $4 $5 $6 $7 $8");
  10209.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10210.     idm_param(idmrun,"$4",system_date,idm_char);
  10211.     idm_param(idmrun,"$5",access_r.rmkid,idm_char);
  10212.     working_secur := secur_types'image(list_item.secur);
  10213.     if list_item.Trtype /= CHANGE then
  10214.       idm_param(idmrun,"$2",working_secur,idm_char);
  10215.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10216.       idm_param(idmrun,"$6",access_r.label,idm_char);
  10217.       idm_param(idmrun,"$7",access_r.remrk,idm_char);
  10218.       idm_param(idmrun,"$8",save_remrk_x,idm_char);
  10219.     else
  10220.       if working_secur /= save_secur then
  10221.         idm_param(idmrun,"$2",working_secur,idm_char);
  10222.       else
  10223.         idm_param(idmrun,"$2",save_secur,idm_char);
  10224.       end if;
  10225.       if report_as_of_time /= save_date then
  10226.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10227.       else
  10228.         idm_param(idmrun,"$3",save_date,idm_char);
  10229.       end if;
  10230.       if access_r.label /= save_label and access_r.label /= "     " then
  10231.         idm_param(idmrun,"$6",access_r.label,idm_char);
  10232.       else
  10233.         idm_param(idmrun,"$6",save_label,idm_char);
  10234.       end if;
  10235.       if access_r.remrk /= save_remrk and access_r.remrk /= "   " then
  10236.         idm_param(idmrun,"$7",access_r.remrk,idm_char);
  10237.       else
  10238.         idm_param(idmrun,"$7",save_remrk,idm_char);
  10239.       end if;
  10240.       idm_param(idmrun,"$8",save_remrk_x,idm_char);
  10241.     end if;
  10242.     idm_execute(idmrun);
  10243.     idm_fetch(idmrun);
  10244.   end if;
  10245.  
  10246. end process_card_r;
  10247.  
  10248. --*********************************************************************
  10249. --*
  10250. --*    PROCESS_CARD_T
  10251. --*
  10252. --*    This procedure will process the message cards of type 'T'.
  10253. --*    The record containing the card data is retrieved from the list,
  10254. --*    and the card is processed as a function of the transaction 
  10255. --*    code.
  10256. --*
  10257. --*********************************************************************
  10258.  
  10259. procedure process_card_t is
  10260.   save_decon : string(1..1);
  10261.   save_mecus : string(1..2);
  10262.   save_avcat : string(1..1);
  10263.   save_resnd : string(1..1);
  10264.   save_erdte : string(1..8);
  10265.   save_exdac : string(1..1);
  10266.   save_cpgeo : string(1..4);
  10267.   save_cfgeo : string(1..4);
  10268.   save_eqdep : string(1..8);
  10269.   save_eqarr : string(1..8);
  10270.   save_pin   : string(1..5);
  10271.   save_tleac : string(1..1);
  10272.   save_tleqe : integer;
  10273.   working_tleqe : integer;
  10274.   working_erdte : string(1..8) := "19000000";
  10275.   working_eqdep : string(1..8) := "19000000";
  10276.   working_eqarr : string(1..8) := "19000000";
  10277. begin
  10278.  
  10279.   access_t := list_item.access_t;
  10280.  
  10281.   if list_item.Trtype = CHANGE then
  10282.     idm_command(idmrun,"return_card_t $1 $2 $3");
  10283.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10284.     idm_param(idmrun,"$2",access_t.teqpt,idm_char);
  10285.     idm_param(idmrun,"$3",access_t.mesen,idm_char);
  10286.     idm_execute(idmrun);
  10287.     idm_fetch(idmrun);
  10288.     idm_column(idmrun,1,save_secur,length_of_string);
  10289.     idm_column(idmrun,2,save_date,length_of_string);
  10290.     idm_column(idmrun,3,save_decon,length_of_string);
  10291.     idm_column(idmrun,4,save_mecus,length_of_string);
  10292.     idm_column(idmrun,5,save_avcat,length_of_string);
  10293.     idm_column(idmrun,6,save_resnd,length_of_string);
  10294.     idm_column(idmrun,7,save_erdte,length_of_string);
  10295.     idm_column(idmrun,8,save_exdac,length_of_string);
  10296.     idm_column(idmrun,9,save_cpgeo,length_of_string);
  10297.     idm_column(idmrun,10,save_cfgeo,length_of_string);
  10298.     idm_column(idmrun,11,save_eqdep,length_of_string);
  10299.     idm_column(idmrun,12,save_eqarr,length_of_string);
  10300.     idm_column(idmrun,13,save_pin,length_of_string);
  10301.     idm_column(idmrun,14,save_tleac,length_of_string);
  10302.     idm_column(idmrun,15,save_tleqe);
  10303.   end if;
  10304.  
  10305.   if list_item.Trtype /= ADD then
  10306.     idm_command(idmrun,"delete_card_t $1 $2 $3");
  10307.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10308.     idm_param(idmrun,"$2",access_t.teqpt,idm_char);
  10309.     idm_param(idmrun,"$3",access_t.mesen,idm_char);
  10310.     idm_execute(idmrun);
  10311.     idm_fetch(idmrun);
  10312.   end if;
  10313.  
  10314.   if list_item.Trtype /= DELETE then
  10315.     idm_command(idmrun,"add_card_t $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  10316.                        "$11 $12 $13 $14 $15 $16 $17 $18 $19");
  10317.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10318.     idm_param(idmrun,"$4",system_date,idm_char);
  10319.     idm_param(idmrun,"$5",access_t.teqpt,idm_char);
  10320.     idm_param(idmrun,"$6",access_t.mesen,idm_char);
  10321.     working_tleqe := string_to_integer(access_t.tleqe);
  10322.     working_secur := secur_types'image(list_item.secur);
  10323.     working_erdte(3..8) := access_t.erdte.yy &
  10324.                            access_t.erdte.mm & access_t.erdte.dd;
  10325.     working_eqdep(3..8) := access_t.eqdep.yy &
  10326.                            access_t.eqdep.mm & access_t.eqdep.dd;
  10327.     working_eqarr(3..8) := access_t.eqarr.yy &
  10328.                            access_t.eqarr.mm & access_t.eqarr.dd;
  10329.     if list_item.Trtype /= CHANGE then
  10330.       idm_param(idmrun,"$2",working_secur,idm_char);
  10331.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10332.       idm_param(idmrun,"$7",access_t.decon,idm_char);
  10333.       idm_param(idmrun,"$8",access_t.mecus,idm_char);
  10334.       idm_param(idmrun,"$9",access_t.avcat,idm_char);
  10335.       idm_param(idmrun,"$10",access_t.resnd,idm_char);
  10336.       idm_param(idmrun,"$11",working_erdte,idm_char);
  10337.       idm_param(idmrun,"$12",access_t.exdac,idm_char);
  10338.       idm_param(idmrun,"$13",access_t.cpgeo,idm_char);
  10339.       idm_param(idmrun,"$14",access_t.cfgeo,idm_char);
  10340.       idm_param(idmrun,"$15",working_eqdep,idm_char);
  10341.       idm_param(idmrun,"$16",working_eqarr,idm_char);
  10342.       idm_param(idmrun,"$17",access_t.pin,idm_char);
  10343.       idm_param(idmrun,"$18",access_t.tleac,idm_char);
  10344.       idm_param(idmrun,"$19",working_tleqe,idm_int1);
  10345.     else
  10346.       if working_secur /= save_secur then
  10347.         idm_param(idmrun,"$2",working_secur,idm_char);
  10348.       else
  10349.         idm_param(idmrun,"$2",save_secur,idm_char);
  10350.       end if;
  10351.       if report_as_of_time /= save_date then
  10352.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10353.       else
  10354.         idm_param(idmrun,"$3",save_date,idm_char);
  10355.       end if;
  10356.       if access_t.decon /= save_decon and access_t.decon /= " " then
  10357.         idm_param(idmrun,"$7",access_t.decon,idm_char);
  10358.       else
  10359.         idm_param(idmrun,"$7",save_decon,idm_char);
  10360.       end if;
  10361.       if access_t.mecus /= save_mecus and access_t.mecus /= "  " then
  10362.         idm_param(idmrun,"$8",access_t.mecus,idm_char);
  10363.       else
  10364.         idm_param(idmrun,"$8",save_mecus,idm_char);
  10365.       end if;
  10366.       if access_t.avcat /= save_avcat and access_t.avcat /= " " then
  10367.         idm_param(idmrun,"$9",access_t.avcat,idm_char);
  10368.       else
  10369.         idm_param(idmrun,"$9",save_avcat,idm_char);
  10370.       end if;
  10371.       if access_t.resnd /= save_resnd and access_t.resnd /= " " then
  10372.         idm_param(idmrun,"$10",access_t.resnd,idm_char);
  10373.       else
  10374.         idm_param(idmrun,"$10",save_resnd,idm_char);
  10375.       end if;
  10376.       if working_erdte /= save_erdte and
  10377.          working_erdte(3..8) /= "      " then
  10378.         idm_param(idmrun,"$11",working_erdte,idm_char);
  10379.       else
  10380.         idm_param(idmrun,"$11",save_erdte,idm_char);
  10381.       end if;
  10382.       if access_t.exdac /= save_exdac and access_t.exdac /= " " then
  10383.         idm_param(idmrun,"$12",access_t.exdac,idm_char);
  10384.       else
  10385.         idm_param(idmrun,"$12",save_exdac,idm_char);
  10386.       end if;
  10387.       if access_t.cpgeo = "#   " then
  10388.         idm_param(idmrun,"$13","    ",idm_char);
  10389.       elsif access_t.cpgeo /= save_cpgeo and
  10390.             access_t.cpgeo /= "    " then
  10391.         idm_param(idmrun,"$13",access_t.cpgeo,idm_char);
  10392.       else
  10393.         idm_param(idmrun,"$13",save_cpgeo,idm_char);
  10394.       end if;
  10395.       if access_t.cfgeo = "#   " then
  10396.         idm_param(idmrun,"$14","    ",idm_char);
  10397.       elsif access_t.cfgeo /= save_cfgeo and
  10398.             access_t.cfgeo /= "    " then
  10399.         idm_param(idmrun,"$14",access_t.cfgeo,idm_char);
  10400.       else
  10401.         idm_param(idmrun,"$14",save_cfgeo,idm_char);
  10402.       end if;
  10403.       if working_eqdep(3..8) = "#     " then
  10404.         idm_param(idmrun,"$15","      ",idm_char);
  10405.       elsif working_eqdep /= save_eqdep and
  10406.             working_eqdep(3..8) /= "      " then
  10407.         idm_param(idmrun,"$15",working_eqdep,idm_char);
  10408.       else
  10409.         idm_param(idmrun,"$15",save_eqdep,idm_char);
  10410.       end if;
  10411.       if working_eqarr(3..8) = "#     " then
  10412.         idm_param(idmrun,"$16","      ",idm_char);
  10413.       elsif working_eqarr /= save_eqarr and
  10414.             working_eqarr(3..8) /= "      " then
  10415.         idm_param(idmrun,"$16",working_eqarr,idm_char);
  10416.       else
  10417.         idm_param(idmrun,"$16",save_eqarr,idm_char);
  10418.       end if;
  10419.       if access_t.pin = "#    " then
  10420.         idm_param(idmrun,"$17","     ",idm_char);
  10421.       elsif access_t.pin /= save_pin and access_t.pin /= "     " then
  10422.         idm_param(idmrun,"$17",access_t.pin,idm_char);
  10423.       else
  10424.         idm_param(idmrun,"$17",save_pin,idm_char);
  10425.       end if;
  10426.       if access_t.tleac = "#" then
  10427.         idm_param(idmrun,"$18"," ",idm_char);
  10428.       elsif access_t.tleac /= save_tleac and access_t.tleac /= " " then
  10429.         idm_param(idmrun,"$18",access_t.tleac,idm_char);
  10430.       else
  10431.         idm_param(idmrun,"$18",save_tleac,idm_char);
  10432.       end if;
  10433.       if access_t.tleqe = "# " then
  10434.         idm_param(idmrun,"$19",0,idm_int1);
  10435.       elsif working_tleqe /= save_tleqe and access_t.tleqe /= "  " then
  10436.         idm_param(idmrun,"$19",working_tleqe,idm_int1);
  10437.       else
  10438.         idm_param(idmrun,"$19",save_tleqe,idm_int1);
  10439.       end if;
  10440.     end if;
  10441.     idm_execute(idmrun);
  10442.     idm_fetch(idmrun);
  10443.   end if;
  10444.  
  10445. end process_card_t;
  10446.  
  10447.  
  10448. --*********************************************************************
  10449. --*
  10450. --*    PROCESS_CARD_V
  10451. --*
  10452. --*    This procedure will process the message cards of type 'V'.
  10453. --*    The record containing the card data is retrieved from the list,
  10454. --*    and the card is processed as a function of the transaction 
  10455. --*    code.
  10456. --*
  10457. --*********************************************************************
  10458.  
  10459. procedure process_card_v is
  10460.   save_acgeo : string(1..4);
  10461.   save_acity : string(1..2);
  10462.   save_adate : string(1..8);
  10463.   save_rdate : string(1..8);
  10464.   save_mdate : integer;
  10465.   working_adate : string(1..8) := "19000000";
  10466.   working_rdate : string(1..8) := "19000000";
  10467.   working_mdate : integer;
  10468. begin
  10469.  
  10470.   access_v := list_item.access_v;
  10471.  
  10472.   if list_item.Trtype = CHANGE then
  10473.     idm_command(idmrun,"return_card_v $1");
  10474.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10475.     idm_execute(idmrun);
  10476.     idm_fetch(idmrun);
  10477.     idm_column(idmrun,1,save_secur,length_of_string);
  10478.     idm_column(idmrun,2,save_date,length_of_string);
  10479.     idm_column(idmrun,3,save_acgeo,length_of_string);
  10480.     idm_column(idmrun,4,save_acity,length_of_string);
  10481.     idm_column(idmrun,5,save_adate,length_of_string);
  10482.     idm_column(idmrun,6,save_rdate,length_of_string);
  10483.     idm_column(idmrun,7,save_mdate);
  10484.   end if;
  10485.  
  10486.   if list_item.Trtype /= ADD then
  10487.     idm_command(idmrun,"delete_card_v $1");
  10488.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10489.     idm_execute(idmrun);
  10490.     idm_fetch(idmrun);
  10491.   end if;
  10492.  
  10493.   if list_item.Trtype /= DELETE then
  10494.     idm_command(idmrun,"add_card_v $1 $2 $3 $4 $5 $6 $7 $8 $9");
  10495.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10496.     idm_param(idmrun,"$4",system_date,idm_char);
  10497.     working_adate(3..8) := access_v.adate.yy &
  10498.                            access_v.adate.mm & access_v.adate.dd;
  10499.     working_rdate(3..8) := access_v.rdate.yy &
  10500.                            access_v.rdate.mm & access_v.rdate.dd;
  10501.     working_mdate := string_to_integer(access_v.mdate);
  10502.     working_secur := secur_types'image(list_item.secur);
  10503.     if list_item.Trtype /= CHANGE then
  10504.       idm_param(idmrun,"$2",working_secur,idm_char);
  10505.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10506.       idm_param(idmrun,"$5",access_v.acgeo,idm_char);
  10507.       idm_param(idmrun,"$6",access_v.acity,idm_char);
  10508.       idm_param(idmrun,"$7",working_adate,idm_char);
  10509.       idm_param(idmrun,"$8",working_rdate,idm_char);
  10510.       idm_param(idmrun,"$9",working_mdate,idm_int1);
  10511.     else
  10512.       if working_secur /= save_secur then
  10513.         idm_param(idmrun,"$2",working_secur,idm_char);
  10514.       else
  10515.         idm_param(idmrun,"$2",save_secur,idm_char);
  10516.       end if;
  10517.       if report_as_of_time /= save_date then
  10518.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10519.       else
  10520.         idm_param(idmrun,"$3",save_date,idm_char);
  10521.       end if;
  10522.       if access_v.acgeo /= save_acgeo and access_v.acgeo /= "    " then
  10523.         idm_param(idmrun,"$5",access_v.acgeo,idm_char);
  10524.       else
  10525.         idm_param(idmrun,"$5",save_acgeo,idm_char);
  10526.       end if;
  10527.       if access_v.acity /= save_acity and access_v.acity /= "  " then
  10528.         idm_param(idmrun,"$6",access_v.acity,idm_char);
  10529.       else
  10530.         idm_param(idmrun,"$6",save_acity,idm_char);
  10531.       end if;
  10532.       if working_adate(3..8) = "#     " then
  10533.         idm_param(idmrun,"$7","       ",idm_char);
  10534.       elsif working_adate /= save_adate and
  10535.             working_adate(3..8) /= "      " then
  10536.         idm_param(idmrun,"$7",working_adate,idm_char);
  10537.       else
  10538.         idm_param(idmrun,"$7",save_adate,idm_char);
  10539.       end if;
  10540.       if working_rdate(3..8) = "#     " then
  10541.         idm_param(idmrun,"$8","      ",idm_char);
  10542.       elsif working_rdate /= save_rdate and
  10543.             working_rdate(3..8) /= "      " then
  10544.         idm_param(idmrun,"$8",working_rdate,idm_char);
  10545.       else
  10546.         idm_param(idmrun,"$8",save_rdate,idm_char);
  10547.       end if;
  10548.       if working_mdate /= save_mdate and access_v.mdate /= "    " then
  10549.         idm_param(idmrun,"$9",working_mdate,idm_int1);
  10550.       else
  10551.         idm_param(idmrun,"$9",save_mdate,idm_int1);
  10552.       end if;
  10553.     end if;
  10554.     idm_execute(idmrun);
  10555.     idm_fetch(idmrun);
  10556.   end if;
  10557.  
  10558. end process_card_v;
  10559.  
  10560. --*********************************************************************
  10561. --*
  10562. --*    PROCESS_CARD_X
  10563. --*
  10564. --*    This procedure will process the message cards of type 'X'.
  10565. --*    The record containing the card data is retrieved from the list,
  10566. --*    and the card is processed as a function of the transaction 
  10567. --*    code.
  10568. --*
  10569. --*********************************************************************
  10570.  
  10571. procedure process_card_x is
  10572.   save_gcmd  : string(1..6);
  10573.   save_rptor : string(1..6);
  10574.   save_sbrpt : string(1..6);
  10575.   save_intr1 : string(1..6);
  10576.   save_intr2 : string(1..6);
  10577.   save_tdate : string(1..8);
  10578.   save_trgeo : string(1..4);
  10579.   save_depdt : string(1..8);
  10580.   save_arrdt : string(1..8);
  10581.   working_tdate : string(1..8) := "19000000";
  10582.   working_depdt : string(1..8) := "19000000";
  10583.   working_arrdt : string(1..8) := "19000000";
  10584. begin
  10585.  
  10586.   access_x := list_item.access_x;
  10587.  
  10588.   if list_item.Trtype = CHANGE then
  10589.     idm_command(idmrun,"return_card_x $1");
  10590.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10591.     idm_execute(idmrun);
  10592.     idm_fetch(idmrun);
  10593.     idm_column(idmrun,1,save_secur,length_of_string);
  10594.     idm_column(idmrun,2,save_date,length_of_string);
  10595.     idm_column(idmrun,3,save_gcmd,length_of_string);
  10596.     idm_column(idmrun,4,save_rptor,length_of_string);
  10597.     idm_column(idmrun,5,save_sbrpt,length_of_string);
  10598.     idm_column(idmrun,6,save_intr1,length_of_string);
  10599.     idm_column(idmrun,7,save_intr2,length_of_string);
  10600.     idm_column(idmrun,8,save_tdate,length_of_string);
  10601.     idm_column(idmrun,9,save_trgeo,length_of_string);
  10602.     idm_column(idmrun,10,save_depdt,length_of_string);
  10603.     idm_column(idmrun,11,save_arrdt,length_of_string);
  10604.  
  10605.     idm_command(idmrun,"delete_card_x $1");
  10606.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10607.     idm_execute(idmrun);
  10608.     idm_fetch(idmrun);
  10609.  
  10610.     idm_command(idmrun,"add_card_x $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13");
  10611.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10612.     idm_param(idmrun,"$4",system_date,idm_char);
  10613.     working_secur := secur_types'image(list_item.secur);
  10614.     working_tdate(3..8) := access_x.tdate.yy & access_x.tdate.mm & access_x.tdate.dd;
  10615.     working_depdt(3..8) := access_x.depdt.yy & access_x.depdt.mm & access_x.depdt.dd;
  10616.     working_arrdt(3..8) := access_x.arrdt.yy & access_x.arrdt.mm & access_x.arrdt.dd;
  10617.     if working_secur /= save_secur then
  10618.       idm_param(idmrun,"$2",working_secur,idm_char);
  10619.     else
  10620.       idm_param(idmrun,"$2",save_secur,idm_char);
  10621.     end if;
  10622.     if report_as_of_time /= save_date then
  10623.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10624.     else
  10625.       idm_param(idmrun,"$3",save_date,idm_char);
  10626.     end if;
  10627.     if access_x.gcmd = "#     " then
  10628.       idm_param(idmrun,"$5","      ",idm_char);
  10629.     elsif access_x.gcmd /= save_gcmd and
  10630.           access_x.gcmd /= "      " then
  10631.       idm_param(idmrun,"$5",access_x.gcmd,idm_char);
  10632.     else
  10633.       idm_param(idmrun,"$5",save_gcmd,idm_char);
  10634.     end if;
  10635.     if access_x.rptor /= save_rptor and
  10636.        access_x.rptor /= "      " then
  10637.       idm_param(idmrun,"$6",access_x.rptor,idm_char);
  10638.     else
  10639.       idm_param(idmrun,"$6",save_rptor,idm_char);
  10640.     end if;
  10641.     if access_x.sbrpt /= save_sbrpt and
  10642.        access_x.sbrpt /= "      " then
  10643.       idm_param(idmrun,"$7",access_x.sbrpt,idm_char);
  10644.     else
  10645.       idm_param(idmrun,"$7",save_sbrpt,idm_char);
  10646.     end if;
  10647.     if access_x.intr1 = "#     " then
  10648.       idm_param(idmrun,"$8","      ",idm_char);
  10649.     elsif access_x.intr1 /= save_intr1 and
  10650.           access_x.intr1 /= "      " then
  10651.       idm_param(idmrun,"$8",access_x.intr1,idm_char);
  10652.     else
  10653.       idm_param(idmrun,"$8",save_intr1,idm_char);
  10654.     end if;
  10655.     if access_x.intr2 = "#     " then
  10656.       idm_param(idmrun,"$9","      ",idm_char);
  10657.     elsif access_x.intr2 /= save_intr2 and
  10658.           access_x.intr2 /= "      " then
  10659.       idm_param(idmrun,"$9",access_x.intr2,idm_char);
  10660.     else
  10661.       idm_param(idmrun,"$9",save_intr2,idm_char);
  10662.     end if;
  10663.     if access_x.gcmd = "#     " then
  10664.       idm_param(idmrun,"$10","      ",idm_char);
  10665.     elsif working_tdate /= save_tdate and
  10666.           working_tdate(3..8) /= "      " then
  10667.       idm_param(idmrun,"$10",working_tdate,idm_char);
  10668.     else
  10669.       idm_param(idmrun,"$10",save_tdate,idm_char);
  10670.     end if;
  10671.     if access_x.gcmd = "#     " then
  10672.       idm_param(idmrun,"$11","    ",idm_char);
  10673.     elsif access_x.trgeo /= save_trgeo and
  10674.           access_x.trgeo /= "    " then
  10675.       idm_param(idmrun,"$11",access_x.trgeo,idm_char);
  10676.     else
  10677.       idm_param(idmrun,"$11",save_trgeo,idm_char);
  10678.     end if;
  10679.     if access_x.gcmd = "#     " then
  10680.       idm_param(idmrun,"$12","      ",idm_char);
  10681.     elsif working_depdt /= save_depdt and
  10682.           working_depdt(3..8) /= "      " then
  10683.       idm_param(idmrun,"$12",working_depdt,idm_char);
  10684.     else
  10685.       idm_param(idmrun,"$12",save_depdt,idm_char);
  10686.     end if;
  10687.     if working_arrdt /= save_arrdt and
  10688.        working_arrdt(3..8) /= "      " then
  10689.       idm_param(idmrun,"$13",working_arrdt,idm_char);
  10690.     else
  10691.       idm_param(idmrun,"$13",save_arrdt,idm_char);
  10692.     end if;
  10693.  
  10694.     idm_execute(idmrun);
  10695.     idm_fetch(idmrun);
  10696.  
  10697.   end if;
  10698.  
  10699. end process_card_x;
  10700.  
  10701. --*********************************************************************
  10702. --*
  10703. --*    PROCESS_CARD_DM1
  10704. --*
  10705. --*    This procedure will process the message cards of type 'DM1'.
  10706. --*    The record containing the card data is retrieved from the list,
  10707. --*    and the card is processed as a function of the transaction 
  10708. --*    code.
  10709. --*
  10710. --*********************************************************************
  10711.  
  10712. procedure process_card_dm1 is
  10713.   save_billet : string(1..3);
  10714.   save_cornk  : string(1..5);
  10715.   save_conam  : string(1..17);
  10716. begin
  10717.  
  10718.   access_dm1 := list_item.access_dm1;
  10719.  
  10720.   if list_item.Trtype = CHANGE then
  10721.     idm_command(idmrun,"return_card_dm1 $1");
  10722.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10723.     idm_execute(idmrun);
  10724.     idm_fetch(idmrun);
  10725.     idm_column(idmrun,1,save_secur,length_of_string);
  10726.     idm_column(idmrun,2,save_date,length_of_string);
  10727.     idm_column(idmrun,3,save_billet,length_of_string);
  10728.     idm_column(idmrun,4,save_cornk,length_of_string);
  10729.     idm_column(idmrun,5,save_conam,length_of_string);
  10730.   end if;
  10731.  
  10732.   if list_item.Trtype /= ADD then
  10733.     idm_command(idmrun,"delete_card_dm1 $1");
  10734.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10735.     idm_execute(idmrun);
  10736.     idm_fetch(idmrun);
  10737.   end if;
  10738.  
  10739.   if list_item.Trtype /= DELETE then
  10740.     idm_command(idmrun,"add_card_dm1 $1 $2 $3 $4 $5 $6 $7");
  10741.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10742.     idm_param(idmrun,"$4",system_date,idm_char);
  10743.     working_secur := secur_types'image(list_item.secur);
  10744.     if list_item.Trtype /= CHANGE then
  10745.       idm_param(idmrun,"$2",working_secur,idm_char);
  10746.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10747.       idm_param(idmrun,"$5",access_dm1.billet,idm_char);
  10748.       idm_param(idmrun,"$6",access_dm1.cornk,idm_char);
  10749.       idm_param(idmrun,"$7",access_dm1.conam,idm_char);
  10750.     else
  10751.       if working_secur /= save_secur then
  10752.         idm_param(idmrun,"$2",working_secur,idm_char);
  10753.       else
  10754.         idm_param(idmrun,"$2",save_secur,idm_char);
  10755.       end if;
  10756.       if report_as_of_time /= save_date then
  10757.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10758.       else
  10759.         idm_param(idmrun,"$3",save_date,idm_char);
  10760.       end if;
  10761.       if access_dm1.billet /= save_billet and
  10762.          access_dm1.billet /= "   " then
  10763.         idm_param(idmrun,"$5",access_dm1.billet,idm_char);
  10764.       else
  10765.         idm_param(idmrun,"$5",save_billet,idm_char);
  10766.       end if;
  10767.       if access_dm1.cornk /= save_cornk and
  10768.          access_dm1.cornk /= "     " then
  10769.         idm_param(idmrun,"$6",access_dm1.cornk,idm_char);
  10770.       else
  10771.         idm_param(idmrun,"$6",save_cornk,idm_char);
  10772.       end if;
  10773.       if access_dm1.conam /= save_conam and
  10774.          access_dm1.conam /= "                 " then
  10775.         idm_param(idmrun,"$7",access_dm1.conam,idm_char);
  10776.       else
  10777.         idm_param(idmrun,"$7",save_conam,idm_char);
  10778.       end if;
  10779.     end if;
  10780.     idm_execute(idmrun);
  10781.     idm_fetch(idmrun);
  10782.   end if;
  10783.  
  10784. end process_card_dm1;
  10785.  
  10786.  
  10787. --*********************************************************************
  10788. --*
  10789. --*    PROCESS_CARD_DN1
  10790. --*
  10791. --*    This procedure will process the message cards of type 'DN1'.
  10792. --*    The record containing the card data is retrieved from the list,
  10793. --*    and the card is processed as a function of the transaction 
  10794. --*    code.
  10795. --*
  10796. --*********************************************************************
  10797.  
  10798. procedure process_card_dn1 is
  10799.   save_ntask : string(1..13);
  10800.   save_prgeo : string(1..4);
  10801.   save_point : string(1..11);
  10802.   save_ndest : string(1..11);
  10803.   save_ple_d : string(1..8);
  10804.   save_ple_h : integer;
  10805.   save_det_d : string(1..8);
  10806.   save_det_h : integer;
  10807.   save_modfg : string(1..1);
  10808.   save_cxmrs : string(1..1);
  10809.   working_ple_d : string(1..8);
  10810.   working_ple_h : integer;
  10811.   working_det_d : string(1..8);
  10812.   working_det_h : integer;
  10813. begin
  10814.  
  10815.   access_dn1 := list_item.access_dn1;
  10816.  
  10817.   if list_item.Trtype = CHANGE then
  10818.     idm_command(idmrun,"return_card_dn1 $1");
  10819.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10820.     idm_execute(idmrun);
  10821.     idm_fetch(idmrun);
  10822.     idm_column(idmrun,1,save_secur,length_of_string);
  10823.     idm_column(idmrun,2,save_date,length_of_string);
  10824.     idm_column(idmrun,3,save_ntask,length_of_string);
  10825.     idm_column(idmrun,4,save_prgeo,length_of_string);
  10826.     idm_column(idmrun,5,save_point,length_of_string);
  10827.     idm_column(idmrun,6,save_ndest,length_of_string);
  10828.     idm_column(idmrun,7,save_ple_d,length_of_string);
  10829.     idm_column(idmrun,8,save_ple_h);
  10830.     idm_column(idmrun,9,save_det_d,length_of_string);
  10831.     idm_column(idmrun,10,save_det_h);
  10832.     idm_column(idmrun,11,save_modfg,length_of_string);
  10833.     idm_column(idmrun,12,save_cxmrs,length_of_string);
  10834.   end if;
  10835.  
  10836.   if list_item.Trtype /= ADD then
  10837.     idm_command(idmrun,"delete_card_dn1 $1");
  10838.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10839.     idm_execute(idmrun);
  10840.     idm_fetch(idmrun);
  10841.   end if;
  10842.  
  10843.   if list_item.Trtype /= DELETE then
  10844.     idm_command(idmrun,"add_card_dn1 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  10845.                        "$11 $12 $13 $14");
  10846.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10847.     idm_param(idmrun,"$4",system_date,idm_char);
  10848.     if access_dn1.pletd.year = 0 then
  10849.       working_ple_d(1..4) := "    ";
  10850.     else
  10851.       working_string(1..3) := integer'image(access_dn1.pletd.year);
  10852.       working_ple_d(3..4)  := working_string(2..3);
  10853.     end if;
  10854.     working_ple_d(5..8) := access_dn1.pletd.mm & access_dn1.pletd.dd;
  10855.     working_ple_h := string_to_integer(access_dn1.pletd.hh);
  10856.     if access_dn1.deta.year = 0 then
  10857.       working_det_d(1..4) := "    ";
  10858.     else
  10859.       working_string(1..3) := integer'image(access_dn1.deta.year);
  10860.       working_det_d(3..4)  := working_string(2..3);
  10861.     end if;
  10862.     working_det_d(5..8) := access_dn1.deta.mm & access_dn1.deta.dd;
  10863.     working_det_h := string_to_integer(access_dn1.deta.hh);
  10864.     working_secur := secur_types'image(list_item.secur);
  10865.     if list_item.Trtype /= CHANGE then
  10866.       idm_param(idmrun,"$2",working_secur,idm_char);
  10867.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10868.       idm_param(idmrun,"$5",access_dn1.ntask,idm_char);
  10869.       idm_param(idmrun,"$6",access_dn1.prgeo,idm_char);
  10870.       idm_param(idmrun,"$7",access_dn1.point,idm_char);
  10871.       idm_param(idmrun,"$8",access_dn1.ndest,idm_char);
  10872.       idm_param(idmrun,"$9",working_ple_d,idm_char);
  10873.       idm_param(idmrun,"$10",working_ple_h,idm_int1);
  10874.       idm_param(idmrun,"$11",working_det_d,idm_char);
  10875.       idm_param(idmrun,"$12",working_det_h,idm_int1);
  10876.       idm_param(idmrun,"$13",access_dn1.modfg,idm_char);
  10877.       idm_param(idmrun,"$14",access_dn1.cxmrs,idm_char);
  10878.     else
  10879.       if working_secur /= save_secur then
  10880.         idm_param(idmrun,"$2",working_secur,idm_char);
  10881.       else
  10882.         idm_param(idmrun,"$2",save_secur,idm_char);
  10883.       end if;
  10884.       if report_as_of_time /= save_date then
  10885.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  10886.       else
  10887.         idm_param(idmrun,"$3",save_date,idm_char);
  10888.       end if;
  10889.       if access_dn1.ntask /= save_ntask and
  10890.          access_dn1.ntask /= "             " then
  10891.         idm_param(idmrun,"$5",access_dn1.ntask,idm_char);
  10892.       else
  10893.         idm_param(idmrun,"$5",save_ntask,idm_char);
  10894.       end if;
  10895.       if access_dn1.prgeo /= save_prgeo and
  10896.          access_dn1.prgeo /= "    " then
  10897.         idm_param(idmrun,"$6",access_dn1.prgeo,idm_char);
  10898.       else
  10899.         idm_param(idmrun,"$6",save_prgeo,idm_char);
  10900.       end if;
  10901.       if access_dn1.point /= save_point and
  10902.          access_dn1.point /= "           " then
  10903.         idm_param(idmrun,"$7",access_dn1.point,idm_char);
  10904.       else
  10905.         idm_param(idmrun,"$7",save_point,idm_char);
  10906.       end if;
  10907.       if access_dn1.ndest /= save_ndest and
  10908.          access_dn1.ndest /= "           " then
  10909.         idm_param(idmrun,"$8",access_dn1.ndest,idm_char);
  10910.       else
  10911.         idm_param(idmrun,"$8",save_ndest,idm_char);
  10912.       end if;
  10913.       if working_ple_d /= save_ple_d and
  10914.          working_ple_d(3..8) /= "       " then
  10915.         idm_param(idmrun,"$9",working_ple_d,idm_char);
  10916.       else
  10917.         idm_param(idmrun,"$9",save_ple_d,idm_char);
  10918.       end if;
  10919.       if working_ple_h /= save_ple_h and
  10920.          access_dn1.pletd.hh /= "  " then
  10921.         idm_param(idmrun,"$10",working_ple_h,idm_int1);
  10922.       else
  10923.         idm_param(idmrun,"$10",save_ple_h,idm_int1);
  10924.       end if;
  10925.       if working_det_d /= save_det_d and
  10926.          working_det_d(3..8) /= "      " then
  10927.         idm_param(idmrun,"$11",working_det_d,idm_char);
  10928.       else
  10929.         idm_param(idmrun,"$11",save_det_d,idm_char);
  10930.       end if;
  10931.       if working_det_h /= save_det_h and access_dn1.deta.hh /= "  " then
  10932.         idm_param(idmrun,"$12",working_det_h,idm_int1);
  10933.       else
  10934.         idm_param(idmrun,"$12",save_det_h,idm_int1);
  10935.       end if;
  10936.       if access_dn1.modfg /= save_modfg and access_dn1.modfg /= " " then
  10937.         idm_param(idmrun,"$13",access_dn1.modfg,idm_char);
  10938.       else
  10939.         idm_param(idmrun,"$13",save_modfg,idm_char);
  10940.       end if;
  10941.       if access_dn1.cxmrs /= save_cxmrs and access_dn1.cxmrs /= " " then
  10942.         idm_param(idmrun,"$14",access_dn1.cxmrs,idm_char);
  10943.       else
  10944.         idm_param(idmrun,"$14",save_cxmrs,idm_char);
  10945.       end if;
  10946.     end if;
  10947.     idm_execute(idmrun);
  10948.     idm_fetch(idmrun);
  10949.   end if;
  10950.  
  10951. end process_card_dn1;
  10952.  
  10953. --*********************************************************************
  10954. --*
  10955. --*    PROCESS_CARD_JM1
  10956. --*
  10957. --*    This procedure will process the message cards of type 'JM1'.
  10958. --*    The record containing the card data is retrieved from the list,
  10959. --*    and the card is processed as a function of the transaction 
  10960. --*    code.
  10961. --*
  10962. --*********************************************************************
  10963.  
  10964. procedure process_card_jm1 is
  10965.   save_mgo   : integer;
  10966.   save_ago   : integer;
  10967.   save_na    : integer;
  10968.   save_nfo   : integer;
  10969.   save_menl  : integer;
  10970.   save_navo  : integer;
  10971.   save_nave  : integer;
  10972.   save_othof : integer;
  10973.   save_othen : integer;
  10974.   save_piaod : string(1..6);
  10975.   working_mgo   : integer;
  10976.   working_ago   : integer;
  10977.   working_na    : integer;
  10978.   working_nfo   : integer;
  10979.   working_menl  : integer;
  10980.   working_navo  : integer;
  10981.   working_nave  : integer;
  10982.   working_othof : integer;
  10983.   working_othen : integer;
  10984. begin
  10985.  
  10986.   access_jm1 := list_item.access_jm1;
  10987.  
  10988.   if list_item.Trtype = CHANGE then
  10989.     idm_command(idmrun,"return_card_jm1 $1");
  10990.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  10991.     idm_execute(idmrun);
  10992.     idm_fetch(idmrun);
  10993.     idm_column(idmrun,1,save_secur,length_of_string);
  10994.     idm_column(idmrun,2,save_date,length_of_string);
  10995.     idm_column(idmrun,3,save_mgo);
  10996.     idm_column(idmrun,4,save_ago);
  10997.     idm_column(idmrun,5,save_na);
  10998.     idm_column(idmrun,6,save_nfo);
  10999.     idm_column(idmrun,7,save_menl);
  11000.     idm_column(idmrun,8,save_navo);
  11001.     idm_column(idmrun,9,save_nave);
  11002.     idm_column(idmrun,10,save_othof);
  11003.     idm_column(idmrun,11,save_othen);
  11004.     idm_column(idmrun,12,save_piaod,length_of_string);
  11005.   end if;
  11006.  
  11007.   if list_item.Trtype /= ADD then
  11008.     idm_command(idmrun,"delete_card_jm1 $1");
  11009.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11010.     idm_execute(idmrun);
  11011.     idm_fetch(idmrun);
  11012.   end if;
  11013.  
  11014.   if list_item.Trtype /= DELETE then
  11015.     idm_command(idmrun,"add_card_jm1 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  11016.                        "$11 $12 $13 $14");
  11017.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11018.     idm_param(idmrun,"$4",system_date,idm_char);
  11019.     working_mgo   := string_to_integer(access_jm1.mgo);
  11020.     working_ago   := string_to_integer(access_jm1.ago);
  11021.     working_na    := string_to_integer(access_jm1.na);
  11022.     working_nfo   := string_to_integer(access_jm1.nfo);
  11023.     working_menl  := string_to_integer(access_jm1.menl);
  11024.     working_navo  := string_to_integer(access_jm1.navo);
  11025.     working_nave  := string_to_integer(access_jm1.nave);
  11026.     working_othof := string_to_integer(access_jm1.othof);
  11027.     working_othen := string_to_integer(access_jm1.othen);
  11028.     working_secur := secur_types'image(list_item.secur);
  11029.     if list_item.Trtype /= CHANGE then
  11030.       idm_param(idmrun,"$2",working_secur,idm_char);
  11031.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  11032.       idm_param(idmrun,"$5",working_mgo,idm_int1);
  11033.       idm_param(idmrun,"$6",working_ago,idm_int1);
  11034.       idm_param(idmrun,"$7",working_na,idm_int1);
  11035.       idm_param(idmrun,"$8",working_nfo,idm_int1);
  11036.       idm_param(idmrun,"$9",working_menl,idm_int1);
  11037.       idm_param(idmrun,"$10",working_navo,idm_int1);
  11038.       idm_param(idmrun,"$11",working_nave,idm_int1);
  11039.       idm_param(idmrun,"$12",working_othof,idm_int1);
  11040.       idm_param(idmrun,"$13",working_othen,idm_int1);
  11041.       idm_param(idmrun,"$14",access_jm1.piaod,idm_char);
  11042.     else
  11043.       if working_secur /= save_secur then
  11044.         idm_param(idmrun,"$2",working_secur,idm_char);
  11045.       else
  11046.         idm_param(idmrun,"$2",save_secur,idm_char);
  11047.       end if;
  11048.       if report_as_of_time /= save_date then
  11049.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  11050.       else
  11051.         idm_param(idmrun,"$3",save_date,idm_char);
  11052.       end if;
  11053.       if working_mgo /= save_mgo and access_jm1.mgo /= "     " then
  11054.         idm_param(idmrun,"$5",working_mgo,idm_int1);
  11055.       else
  11056.         idm_param(idmrun,"$5",save_mgo,idm_int1);
  11057.       end if;
  11058.       if working_ago /= save_ago and access_jm1.ago /= "     " then
  11059.         idm_param(idmrun,"$6",working_ago,idm_int1);
  11060.       else
  11061.         idm_param(idmrun,"$6",save_ago,idm_int1);
  11062.       end if;
  11063.       if working_na /= save_na and access_jm1.na /= "     " then
  11064.         idm_param(idmrun,"$7",working_na,idm_int1);
  11065.       else
  11066.         idm_param(idmrun,"$7",save_na,idm_int1);
  11067.       end if;
  11068.       if working_nfo /= save_nfo and access_jm1.nfo /= "     " then
  11069.         idm_param(idmrun,"$8",working_nfo,idm_int1);
  11070.       else
  11071.         idm_param(idmrun,"$8",save_nfo,idm_int1);
  11072.       end if;
  11073.       if working_menl /= save_menl and access_jm1.menl /= "     " then
  11074.         idm_param(idmrun,"$9",working_menl,idm_int1);
  11075.       else
  11076.         idm_param(idmrun,"$9",save_menl,idm_int1);
  11077.       end if;
  11078.       if working_navo /= save_navo and access_jm1.navo /= "     " then
  11079.         idm_param(idmrun,"$10",working_navo,idm_int1);
  11080.       else
  11081.         idm_param(idmrun,"$10",save_navo,idm_int1);
  11082.       end if;
  11083.       if working_nave /= save_nave and access_jm1.nave /= "     " then
  11084.         idm_param(idmrun,"$11",working_nave,idm_int1);
  11085.       else
  11086.         idm_param(idmrun,"$11",save_nave,idm_int1);
  11087.       end if;
  11088.       if working_othof /= save_othof and
  11089.          access_jm1.othof /= "     " then
  11090.         idm_param(idmrun,"$12",working_othof,idm_int1);
  11091.       else
  11092.         idm_param(idmrun,"$12",save_othof,idm_int1);
  11093.       end if;
  11094.       if working_othen /= save_othen and
  11095.          access_jm1.othen /= "     " then
  11096.         idm_param(idmrun,"$13",working_othen,idm_int1);
  11097.       else
  11098.         idm_param(idmrun,"$13",save_othen,idm_int1);
  11099.       end if;
  11100.       if access_jm1.piaod /= save_piaod and
  11101.          access_jm1.piaod /= "      " then
  11102.         idm_param(idmrun,"$14",access_jm1.piaod,idm_char);
  11103.       else
  11104.         idm_param(idmrun,"$14",save_piaod,idm_char);
  11105.       end if;
  11106.     end if;
  11107.     idm_execute(idmrun);
  11108.     idm_fetch(idmrun);
  11109.   end if;
  11110.  
  11111. end process_card_jm1;
  11112.  
  11113. --*********************************************************************
  11114. --*
  11115. --*    PROCESS_CARD_KF1
  11116. --*
  11117. --*    This procedure will process the message cards of type 'KF1'.
  11118. --*    The record containing the card data is retrieved from the list,
  11119. --*    and the card is processed as a function of the transaction 
  11120. --*    code.
  11121. --*
  11122. --*********************************************************************
  11123.  
  11124. procedure process_card_kf1 is
  11125.   save_docid : string(1..4);
  11126.   save_tpaut : integer;
  11127.   save_tpasg : integer;
  11128.   save_tpavl : integer;
  11129.   save_cpaur : integer;
  11130.   save_cpasg : integer;
  11131.   save_cpavl : integer;
  11132.   save_tmthd : string(1..1);
  11133.   save_tcarq : integer;
  11134.   save_tcras : integer;
  11135.   save_tcrav : integer;
  11136.   save_trsa1 : integer;
  11137.   save_trsa2 : integer;
  11138.   save_trsa3 : integer;
  11139.   save_trsa4 : integer;
  11140.   save_trsa5 : integer;
  11141.   working_tpaut : integer;
  11142.   working_tpasg : integer;
  11143.   working_tpavl : integer;
  11144.   working_cpaur : integer;
  11145.   working_cpasg : integer;
  11146.   working_cpavl : integer;
  11147.   working_tcarq : integer;
  11148.   working_tcras : integer;
  11149.   working_tcrav : integer;
  11150.   working_trsa1 : integer;
  11151.   working_trsa2 : integer;
  11152.   working_trsa3 : integer;
  11153.   working_trsa4 : integer;
  11154.   working_trsa5 : integer;
  11155. begin
  11156.  
  11157.   access_kf1 := list_item.access_kf1;
  11158.  
  11159.   if list_item.Trtype = CHANGE then
  11160.     idm_command(idmrun,"return_card_kf1 $1 $2");
  11161.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11162.     idm_param(idmrun,"$2",access_kf1.docnr,idm_char);
  11163.     idm_execute(idmrun);
  11164.     idm_fetch(idmrun);
  11165.     idm_column(idmrun,1,save_secur,length_of_string);
  11166.     idm_column(idmrun,2,save_date,length_of_string);
  11167.     idm_column(idmrun,3,save_docid,length_of_string);
  11168.     idm_column(idmrun,4,save_tpaut);
  11169.     idm_column(idmrun,5,save_tpasg);
  11170.     idm_column(idmrun,6,save_tpavl);
  11171.     idm_column(idmrun,7,save_cpaur);
  11172.     idm_column(idmrun,8,save_cpasg);
  11173.     idm_column(idmrun,9,save_cpavl);
  11174.     idm_column(idmrun,10,save_tmthd,length_of_string);
  11175.     idm_column(idmrun,11,save_tcarq);
  11176.     idm_column(idmrun,12,save_tcras);
  11177.     idm_column(idmrun,13,save_tcrav);
  11178.     --
  11179.     -- retrieve for trsa*
  11180.     --
  11181.     idm_column(idmrun,15,save_trsa1);
  11182.     idm_column(idmrun,16,save_trsa2);
  11183.     idm_column(idmrun,17,save_trsa3);
  11184.     idm_column(idmrun,18,save_trsa4);
  11185.     idm_column(idmrun,19,save_trsa5);
  11186.   end if;
  11187.  
  11188.   if list_item.Trtype /= ADD then
  11189.     idm_command(idmrun,"delete_card_kf1 $1 $2");
  11190.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11191.     idm_param(idmrun,"$2",access_kf1.docnr,idm_char);
  11192.     idm_execute(idmrun);
  11193.     idm_fetch(idmrun);
  11194.     --
  11195.     -- delete for trsa*
  11196.     --
  11197.   end if;
  11198.  
  11199.   if list_item.Trtype /= DELETE then
  11200.     idm_command(idmrun,"add_card_kf1 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  11201.                        "$11 $12 $13 $14 $15 $16 $17 $18 $19 $20 $21");
  11202.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11203.     idm_param(idmrun,"$4",system_date,idm_char);
  11204.     idm_param(idmrun,"$5",access_kf1.docnr,idm_char);
  11205.     working_tpaut := string_to_integer(access_kf1.tpaut);
  11206.     working_tpasg := string_to_integer(access_kf1.tpasg);
  11207.     working_tpavl := string_to_integer(access_kf1.tpavl);
  11208.     working_cpaur := string_to_integer(access_kf1.cpaur);
  11209.     working_cpasg := string_to_integer(access_kf1.cpasg);
  11210.     working_cpavl := string_to_integer(access_kf1.cpavl);
  11211.     working_tcarq := string_to_integer(access_kf1.tcarq);
  11212.     working_tcras := string_to_integer(access_kf1.tcras);
  11213.     working_tcrav := string_to_integer(access_kf1.tcrav);
  11214.     working_trsa1 := string_to_integer(access_kf1.trsa1);
  11215.     working_trsa2 := string_to_integer(access_kf1.trsa2);
  11216.     working_trsa3 := string_to_integer(access_kf1.trsa3);
  11217.     working_trsa4 := string_to_integer(access_kf1.trsa4);
  11218.     working_trsa5 := string_to_integer(access_kf1.trsa5);
  11219.     working_secur := secur_types'image(list_item.secur);
  11220.     if list_item.Trtype /= CHANGE then
  11221.       idm_param(idmrun,"$2",working_secur,idm_char);
  11222.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  11223.       idm_param(idmrun,"$6",access_kf1.docid,idm_char);
  11224.       idm_param(idmrun,"$7",working_tpaut,idm_int1);
  11225.       idm_param(idmrun,"$8",working_tpasg,idm_int1);
  11226.       idm_param(idmrun,"$9",working_tpavl,idm_int1);
  11227.       idm_param(idmrun,"$10",working_cpaur,idm_int1);
  11228.       idm_param(idmrun,"$11",working_cpasg,idm_int1);
  11229.       idm_param(idmrun,"$12",working_cpavl,idm_int1);
  11230.       idm_param(idmrun,"$13",access_kf1.tmthd,idm_char);
  11231.       idm_param(idmrun,"$14",working_tcarq,idm_int1);
  11232.       idm_param(idmrun,"$15",working_tcras,idm_int1);
  11233.       idm_param(idmrun,"$16",working_tcrav,idm_int1);
  11234.       --
  11235.       -- add for trsa*
  11236.       --
  11237.       idm_param(idmrun,"$17",working_trsa1,idm_int1);
  11238.       idm_param(idmrun,"$18",working_trsa2,idm_int1);
  11239.       idm_param(idmrun,"$19",access_kf1.trsa3,idm_int1);
  11240.       idm_param(idmrun,"$20",access_kf1.trsa4,idm_int1);
  11241.       idm_param(idmrun,"$21",access_kf1.trsa5,idm_int1);
  11242.     else
  11243.       if working_secur /= save_secur then
  11244.         idm_param(idmrun,"$2",working_secur,idm_char);
  11245.       else
  11246.         idm_param(idmrun,"$2",save_secur,idm_char);
  11247.       end if;
  11248.       if report_as_of_time /= save_date then
  11249.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  11250.       else
  11251.         idm_param(idmrun,"$3",save_date,idm_char);
  11252.       end if;
  11253.       if access_kf1.docid /= save_docid and
  11254.          access_kf1.docid /= "    " then
  11255.         idm_param(idmrun,"$6",access_kf1.docid,idm_char);
  11256.       else
  11257.         idm_param(idmrun,"$6",save_docid,idm_char);
  11258.       end if;
  11259.       if access_kf1.tpaut = "#   " then
  11260.         idm_param(idmrun,"$7",0,idm_int1);
  11261.       elsif working_tpaut /= save_tpaut and
  11262.             access_kf1.tpaut /= "    " then
  11263.         idm_param(idmrun,"$7",working_tpaut,idm_int1);
  11264.       else
  11265.         idm_param(idmrun,"$7",save_tpaut,idm_int1);
  11266.       end if;
  11267.       if access_kf1.tpasg = "#   " then
  11268.         idm_param(idmrun,"$8",0,idm_int1);
  11269.       elsif working_tpasg /= save_tpasg and
  11270.             access_kf1.tpasg /= "    " then
  11271.         idm_param(idmrun,"$8",working_tpasg,idm_int1);
  11272.       else
  11273.         idm_param(idmrun,"$8",save_tpasg,idm_int1);
  11274.       end if;
  11275.       if access_kf1.tpavl = "#   " then
  11276.         idm_param(idmrun,"$9",0,idm_int1);
  11277.       elsif working_tpavl /= save_tpavl and
  11278.             access_kf1.tpavl /= "    " then
  11279.         idm_param(idmrun,"$9",working_tpavl,idm_int1);
  11280.       else
  11281.         idm_param(idmrun,"$9",save_tpavl,idm_int1);
  11282.       end if;
  11283.       if access_kf1.cpaur = "#   " then
  11284.         idm_param(idmrun,"$10",0,idm_int1);
  11285.       elsif working_cpaur /= save_cpaur and
  11286.             access_kf1.cpaur /= "    " then
  11287.         idm_param(idmrun,"$10",working_cpaur,idm_int1);
  11288.       else
  11289.         idm_param(idmrun,"$10",save_cpaur,idm_int1);
  11290.       end if;
  11291.       if access_kf1.cpasg = "#   " then
  11292.         idm_param(idmrun,"$11",0,idm_int1);
  11293.       elsif working_cpasg /= save_cpasg and
  11294.             access_kf1.cpasg /= "    " then
  11295.         idm_param(idmrun,"$11",working_cpasg,idm_int1);
  11296.       else
  11297.         idm_param(idmrun,"$11",save_cpasg,idm_int1);
  11298.       end if;
  11299.       if access_kf1.cpavl = "#   " then
  11300.         idm_param(idmrun,"$12",0,idm_int1);
  11301.       elsif working_cpavl /= save_cpavl and
  11302.             access_kf1.cpavl /= "    " then
  11303.         idm_param(idmrun,"$12",working_cpavl,idm_int1);
  11304.       else
  11305.         idm_param(idmrun,"$12",save_cpavl,idm_int1);
  11306.       end if;
  11307.       if access_kf1.tmthd /= save_tmthd and access_kf1.tmthd /= " " then
  11308.         idm_param(idmrun,"$13",access_kf1.tmthd,idm_char);
  11309.       else
  11310.         idm_param(idmrun,"$13",save_tmthd,idm_char);
  11311.       end if;
  11312.       if access_kf1.tcarq = "#  " then
  11313.         idm_param(idmrun,"$14",0,idm_int1);
  11314.       elsif working_tcarq /= save_tcarq and
  11315.             access_kf1.tcarq /= "   " then
  11316.         idm_param(idmrun,"$14",working_tcarq,idm_int1);
  11317.       else
  11318.         idm_param(idmrun,"$14",save_tcarq,idm_int1);
  11319.       end if;
  11320.       if access_kf1.tcras = "#  " then
  11321.         idm_param(idmrun,"$15",0,idm_int1);
  11322.       elsif working_tcras /= save_tcras and
  11323.             access_kf1.tcras /= "   " then
  11324.         idm_param(idmrun,"$15",working_tcras,idm_int1);
  11325.       else
  11326.         idm_param(idmrun,"$15",save_tcras,idm_int1);
  11327.       end if;
  11328.       if access_kf1.tcrav = "#  " then
  11329.         idm_param(idmrun,"$16",0,idm_int1);
  11330.       elsif working_tcrav /= save_tcrav and
  11331.             access_kf1.tcrav /= "   " then
  11332.         idm_param(idmrun,"$16",working_tcrav,idm_int1);
  11333.       else
  11334.         idm_param(idmrun,"$16",save_tcrav,idm_int1);
  11335.       end if;
  11336.       --
  11337.       -- add for trsa*
  11338.       --
  11339.       if access_kf1.trsa1 = "# " then
  11340.         idm_param(idmrun,"$17",0,idm_int1);
  11341.       elsif working_trsa1 /= save_trsa1 and
  11342.             access_kf1.trsa1 /= "  " then
  11343.         idm_param(idmrun,"$17",working_trsa1,idm_int1);
  11344.       else
  11345.         idm_param(idmrun,"$17",save_trsa1,idm_int1);
  11346.       end if;
  11347.       if access_kf1.trsa2 = "# " then
  11348.         idm_param(idmrun,"$18",0,idm_int1);
  11349.       elsif working_trsa2 /= save_trsa2 and
  11350.             access_kf1.trsa2 /= "  " then
  11351.         idm_param(idmrun,"$18",working_trsa2,idm_int1);
  11352.       else
  11353.         idm_param(idmrun,"$18",save_trsa2,idm_int1);
  11354.       end if;
  11355.       if access_kf1.trsa3 = "# " then
  11356.         idm_param(idmrun,"$19",0,idm_int1);
  11357.       elsif working_trsa3 /= save_trsa3 and
  11358.             access_kf1.trsa3 /= "  " then
  11359.         idm_param(idmrun,"$19",working_trsa3,idm_int1);
  11360.       else
  11361.         idm_param(idmrun,"$19",save_trsa3,idm_int1);
  11362.       end if;
  11363.       if access_kf1.trsa4 = "# " then
  11364.         idm_param(idmrun,"$20",0,idm_int1);
  11365.       elsif working_trsa4 /= save_trsa4 and
  11366.             access_kf1.trsa4 /= "  " then
  11367.         idm_param(idmrun,"$20",working_trsa4,idm_int1);
  11368.       else
  11369.         idm_param(idmrun,"$20",save_trsa4,idm_int1);
  11370.       end if;
  11371.       if access_kf1.trsa5 = "# " then
  11372.         idm_param(idmrun,"$21",0,idm_int1);
  11373.       elsif working_trsa5 /= save_trsa5 and
  11374.             access_kf1.trsa5 /= "  " then
  11375.         idm_param(idmrun,"$21",working_trsa5,idm_int1);
  11376.       else
  11377.         idm_param(idmrun,"$21",save_trsa5,idm_int1);
  11378.       end if;
  11379.     end if;
  11380.     idm_execute(idmrun);
  11381.     idm_fetch(idmrun);
  11382.   end if;
  11383.  
  11384. end process_card_kf1;
  11385.  
  11386.  
  11387. --*********************************************************************
  11388. --*
  11389. --*    PROCESS_CARD_KF2
  11390. --*
  11391. --*    This procedure will process the message cards of type 'KF2'.
  11392. --*    The record containing the card data is retrieved from the list,
  11393. --*    and the card is processed as a function of the transaction 
  11394. --*    code.
  11395. --*
  11396. --*********************************************************************
  11397.  
  11398. procedure process_card_kf2 is
  11399.   save_meard : integer;
  11400.   save_measq : integer;
  11401.   save_mepos : integer;
  11402.   save_memra : integer;
  11403.   save_eqsee : integer;
  11404.   save_eqsse : integer;
  11405.   save_eqree : integer;
  11406.   save_eqred : integer;
  11407.   save_essa1 : integer;
  11408.   save_essa2 : integer;
  11409.   save_essa3 : integer;
  11410.   save_essa4 : integer;
  11411.   save_essa5 : integer;
  11412.   save_essa6 : integer;
  11413.   save_essa7 : integer;
  11414.   save_essa8 : integer;
  11415.   save_essa9 : integer;
  11416.   save_ersa1 : integer;
  11417.   save_ersa2 : integer;
  11418.   save_ersa3 : integer;
  11419.   save_ersa4 : integer;
  11420.   save_ersa5 : integer;
  11421.   save_ersa6 : integer;
  11422.   save_ersa7 : integer;
  11423.   save_ersa8 : integer;
  11424.   save_ersa9 : integer;
  11425.   working_meard : integer;
  11426.   working_measq : integer;
  11427.   working_mepos : integer;
  11428.   working_memra : integer;
  11429.   working_eqsee : integer;
  11430.   working_eqsse : integer;
  11431.   working_eqree : integer;
  11432.   working_eqred : integer;
  11433.   working_essa1 : integer;
  11434.   working_essa2 : integer;
  11435.   working_essa3 : integer;
  11436.   working_essa4 : integer;
  11437.   working_essa5 : integer;
  11438.   working_essa6 : integer;
  11439.   working_essa7 : integer;
  11440.   working_essa8 : integer;
  11441.   working_essa9 : integer;
  11442.   working_ersa1 : integer;
  11443.   working_ersa2 : integer;
  11444.   working_ersa3 : integer;
  11445.   working_ersa4 : integer;
  11446.   working_ersa5 : integer;
  11447.   working_ersa6 : integer;
  11448.   working_ersa7 : integer;
  11449.   working_ersa8 : integer;
  11450.   working_ersa9 : integer;
  11451. begin
  11452.  
  11453.   access_kf2 := list_item.access_kf2;
  11454.  
  11455.   if list_item.Trtype = CHANGE then
  11456.     idm_command(idmrun,"return_card_kf2 $1 $2");
  11457.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11458.     idm_param(idmrun,"$2",access_kf2.docnr,idm_char);
  11459.     idm_execute(idmrun);
  11460.     idm_fetch(idmrun);
  11461.     idm_column(idmrun,1,save_secur,length_of_string);
  11462.     idm_column(idmrun,2,save_date,length_of_string);
  11463.     idm_column(idmrun,3,save_meard);
  11464.     idm_column(idmrun,4,save_measq);
  11465.     idm_column(idmrun,5,save_mepos);
  11466.     idm_column(idmrun,6,save_memra);
  11467.     idm_column(idmrun,7,save_eqsee);
  11468.     idm_column(idmrun,8,save_eqsse);
  11469.     idm_column(idmrun,9,save_eqree);
  11470.     idm_column(idmrun,10,save_eqred);
  11471.     --
  11472.     -- retrieve for essa*
  11473.     --
  11474.     idm_column(idmrun,11,save_essa1);
  11475.     idm_column(idmrun,12,save_essa2);
  11476.     idm_column(idmrun,13,save_essa3);
  11477.     idm_column(idmrun,14,save_essa4);
  11478.     idm_column(idmrun,15,save_essa5);
  11479.     idm_column(idmrun,16,save_essa6);
  11480.     idm_column(idmrun,17,save_essa7);
  11481.     idm_column(idmrun,18,save_essa8);
  11482.     idm_column(idmrun,19,save_essa9);
  11483.     --
  11484.     -- retrieve for ers1*
  11485.     --
  11486.     idm_column(idmrun,20,save_ersa1);
  11487.     idm_column(idmrun,21,save_ersa2);
  11488.     idm_column(idmrun,22,save_ersa3);
  11489.     idm_column(idmrun,23,save_ersa4);
  11490.     idm_column(idmrun,24,save_ersa5);
  11491.     idm_column(idmrun,25,save_ersa6);
  11492.     idm_column(idmrun,26,save_ersa7);
  11493.     idm_column(idmrun,27,save_ersa8);
  11494.     idm_column(idmrun,28,save_ersa9);
  11495.   end if;
  11496.  
  11497.   if list_item.Trtype /= ADD then
  11498.     idm_command(idmrun,"delete_card_kf2 $1 $2");
  11499.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11500.     idm_param(idmrun,"$2",access_kf2.docnr,idm_char);
  11501.     idm_execute(idmrun);
  11502.     idm_fetch(idmrun);
  11503.     --
  11504.     -- delete for essa* and ersa*
  11505.     --
  11506.   end if;
  11507.  
  11508.   if list_item.Trtype /= DELETE then
  11509.     idm_command(idmrun,"add_card_kf2 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  11510.                        "$11 $12 $13 $14 $15 $16 $17 $18 $19 $20 $21 " &
  11511.                        "$22 $23 $24 $25 $26 $27 $28 $29 $30 $31");
  11512.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11513.     idm_param(idmrun,"$4",system_date,idm_char);
  11514.     idm_param(idmrun,"$5",access_kf2.docnr,idm_char);
  11515.     working_meard := string_to_integer(access_kf2.meard);
  11516.     working_measq := string_to_integer(access_kf2.measq);
  11517.     working_mepos := string_to_integer(access_kf2.mepos);
  11518.     working_memra := string_to_integer(access_kf2.memra);
  11519.     working_eqsee := string_to_integer(access_kf2.eqsee);
  11520.     working_eqsse := string_to_integer(access_kf2.eqsse);
  11521.     working_eqree := string_to_integer(access_kf2.eqree);
  11522.     working_eqred := string_to_integer(access_kf2.eqred);
  11523.     working_essa1 := string_to_integer(access_kf2.essa1);
  11524.     working_essa2 := string_to_integer(access_kf2.essa2);
  11525.     working_essa3 := string_to_integer(access_kf2.essa3);
  11526.     working_essa4 := string_to_integer(access_kf2.essa4);
  11527.     working_essa5 := string_to_integer(access_kf2.essa5);
  11528.     working_essa6 := string_to_integer(access_kf2.essa6);
  11529.     working_essa7 := string_to_integer(access_kf2.essa7);
  11530.     working_essa8 := string_to_integer(access_kf2.essa8);
  11531.     working_essa9 := string_to_integer(access_kf2.essa9);
  11532.     working_ersa1 := string_to_integer(access_kf2.ersa1);
  11533.     working_ersa2 := string_to_integer(access_kf2.ersa2);
  11534.     working_ersa3 := string_to_integer(access_kf2.ersa3);
  11535.     working_ersa4 := string_to_integer(access_kf2.ersa4);
  11536.     working_ersa5 := string_to_integer(access_kf2.ersa5);
  11537.     working_ersa6 := string_to_integer(access_kf2.ersa6);
  11538.     working_ersa7 := string_to_integer(access_kf2.ersa7);
  11539.     working_ersa8 := string_to_integer(access_kf2.ersa8);
  11540.     working_ersa9 := string_to_integer(access_kf2.ersa9);
  11541.     working_secur := secur_types'image(list_item.secur);
  11542.     if list_item.Trtype /= CHANGE then
  11543.       idm_param(idmrun,"$2",working_secur,idm_char);
  11544.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  11545.       idm_param(idmrun,"$6",working_meard,idm_int1);
  11546.       idm_param(idmrun,"$7",working_measq,idm_int1);
  11547.       idm_param(idmrun,"$8",working_mepos,idm_int1);
  11548.       idm_param(idmrun,"$9",working_memra,idm_int1);
  11549.       idm_param(idmrun,"$10",working_eqsee,idm_int1);
  11550.       idm_param(idmrun,"$11",working_eqsse,idm_int1);
  11551.       idm_param(idmrun,"$12",working_eqree,idm_int1);
  11552.       idm_param(idmrun,"$13",working_eqred,idm_int1);
  11553.       --
  11554.       -- add for essa*
  11555.       --
  11556.       idm_param(idmrun,"$14",working_essa1,idm_int1);
  11557.       idm_param(idmrun,"$15",working_essa2,idm_int1);
  11558.       idm_param(idmrun,"$16",working_essa3,idm_int1);
  11559.       idm_param(idmrun,"$17",working_essa4,idm_int1);
  11560.       idm_param(idmrun,"$18",working_essa5,idm_int1);
  11561.       idm_param(idmrun,"$19",working_essa6,idm_int1);
  11562.       idm_param(idmrun,"$20",working_essa7,idm_int1);
  11563.       idm_param(idmrun,"$21",working_essa8,idm_int1);
  11564.       idm_param(idmrun,"$22",working_essa9,idm_int1);
  11565.       --
  11566.       -- add for ersa*
  11567.       --
  11568.       idm_param(idmrun,"$23",working_ersa1,idm_int1);
  11569.       idm_param(idmrun,"$24",working_ersa2,idm_int1);
  11570.       idm_param(idmrun,"$25",working_ersa3,idm_int1);
  11571.       idm_param(idmrun,"$26",working_ersa4,idm_int1);
  11572.       idm_param(idmrun,"$27",working_ersa5,idm_int1);
  11573.       idm_param(idmrun,"$28",working_ersa6,idm_int1);
  11574.       idm_param(idmrun,"$29",working_ersa7,idm_int1);
  11575.       idm_param(idmrun,"$30",working_ersa8,idm_int1);
  11576.       idm_param(idmrun,"$31",working_ersa9,idm_int1);
  11577.     else
  11578.       if working_secur /= save_secur then
  11579.         idm_param(idmrun,"$2",working_secur,idm_char);
  11580.       else
  11581.         idm_param(idmrun,"$2",save_secur,idm_char);
  11582.       end if;
  11583.       if report_as_of_time /= save_date then
  11584.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  11585.       else
  11586.         idm_param(idmrun,"$3",save_date,idm_char);
  11587.       end if;
  11588.       if access_kf2.meard = "#  " then
  11589.         idm_param(idmrun,"$6",0,idm_int1);
  11590.       elsif working_meard /= save_meard and
  11591.             access_kf2.meard /= "   " then
  11592.         idm_param(idmrun,"$6",working_meard,idm_int1);
  11593.       else
  11594.         idm_param(idmrun,"$6",save_meard,idm_int1);
  11595.       end if;
  11596.       if access_kf2.measq = "#  " then
  11597.         idm_param(idmrun,"$7",0,idm_int1);
  11598.       elsif working_measq /= save_measq and
  11599.             access_kf2.measq /= "   " then
  11600.         idm_param(idmrun,"$7",working_measq,idm_int1);
  11601.       else
  11602.         idm_param(idmrun,"$7",save_measq,idm_int1);
  11603.       end if;
  11604.       if access_kf2.mepos = "#  " then
  11605.         idm_param(idmrun,"$8",0,idm_int1);
  11606.       elsif working_mepos /= save_mepos and
  11607.             access_kf2.mepos /= "   " then
  11608.         idm_param(idmrun,"$8",working_mepos,idm_int1);
  11609.       else
  11610.         idm_param(idmrun,"$8",save_mepos,idm_int1);
  11611.       end if;
  11612.       if access_kf2.memra = "#  " then
  11613.         idm_param(idmrun,"$9",0,idm_int1);
  11614.       elsif working_memra /= save_memra and
  11615.             access_kf2.memra /= "   " then
  11616.         idm_param(idmrun,"$9",working_memra,idm_int1);
  11617.       else
  11618.         idm_param(idmrun,"$9",save_memra,idm_int1);
  11619.       end if;
  11620.       if access_kf2.eqsee = "# " then
  11621.         idm_param(idmrun,"$10",0,idm_int1);
  11622.       elsif working_eqsee /= save_eqsee and
  11623.             access_kf2.eqsee /= "  " then
  11624.         idm_param(idmrun,"$10",working_eqsee,idm_int1);
  11625.       else
  11626.         idm_param(idmrun,"$10",save_eqsee,idm_int1);
  11627.       end if;
  11628.       if access_kf2.eqsse = "# " then
  11629.         idm_param(idmrun,"$11",0,idm_int1);
  11630.       elsif working_eqsse /= save_eqsse and
  11631.             access_kf2.eqsse /= "  " then
  11632.         idm_param(idmrun,"$11",working_eqsse,idm_int1);
  11633.       else
  11634.         idm_param(idmrun,"$11",save_eqsse,idm_int1);
  11635.       end if;
  11636.       if access_kf2.eqree = "# " then
  11637.         idm_param(idmrun,"$12",0,idm_int1);
  11638.       elsif working_eqree /= save_eqree and
  11639.             access_kf2.eqree /= "  " then
  11640.         idm_param(idmrun,"$12",working_eqree,idm_int1);
  11641.       else
  11642.         idm_param(idmrun,"$12",save_eqree,idm_int1);
  11643.       end if;
  11644.       if access_kf2.eqred = "# " then
  11645.         idm_param(idmrun,"$13",0,idm_int1);
  11646.       elsif working_eqred /= save_eqred and
  11647.             access_kf2.eqred /= "  " then
  11648.         idm_param(idmrun,"$13",working_eqred,idm_int1);
  11649.       else
  11650.         idm_param(idmrun,"$13",save_eqred,idm_int1);
  11651.       end if;
  11652.       --
  11653.       -- add for essa*
  11654.       --
  11655.       if access_kf2.essa1 = "# " then
  11656.     idm_param(idmrun,"$14",0,idm_int1);
  11657.       elsif working_essa1 /= save_essa1 and
  11658.             access_kf2.essa1 /= "  " then
  11659.     idm_param(idmrun,"$14",working_essa1,idm_int1);
  11660.       else
  11661.     idm_param(idmrun,"$14",save_essa1,idm_int1);
  11662.       end if;
  11663.       if access_kf2.essa2 = "# " then
  11664.     idm_param(idmrun,"$15",0,idm_int1);
  11665.       elsif working_essa2 /= save_essa2 and
  11666.             access_kf2.essa2 /= "  " then
  11667.     idm_param(idmrun,"$15",working_essa2,idm_int1);
  11668.       else
  11669.     idm_param(idmrun,"$15",save_essa2,idm_int1);
  11670.       end if;
  11671.       if access_kf2.essa3 = "# " then
  11672.     idm_param(idmrun,"$16",0,idm_int1);
  11673.       elsif working_essa3 /= save_essa3 and
  11674.             access_kf2.essa3 /= "  " then
  11675.     idm_param(idmrun,"$16",working_essa3,idm_int1);
  11676.       else
  11677.     idm_param(idmrun,"$16",save_essa3,idm_int1);
  11678.       end if;
  11679.       if access_kf2.essa4 = "# " then
  11680.     idm_param(idmrun,"$17",0,idm_int1);
  11681.       elsif working_essa4 /= save_essa4 and
  11682.             access_kf2.essa4 /= "  " then
  11683.     idm_param(idmrun,"$17",working_essa4,idm_int1);
  11684.       else
  11685.     idm_param(idmrun,"$17",save_essa4,idm_int1);
  11686.       end if;
  11687.       if access_kf2.essa5 = "# " then
  11688.     idm_param(idmrun,"$18",0,idm_int1);
  11689.       elsif working_essa5 /= save_essa5 and
  11690.             access_kf2.essa5 /= "  " then
  11691.     idm_param(idmrun,"$18",working_essa5,idm_int1);
  11692.       else
  11693.     idm_param(idmrun,"$18",save_essa5,idm_int1);
  11694.       end if;
  11695.       if access_kf2.essa6 = "# " then
  11696.     idm_param(idmrun,"$19",0,idm_int1);
  11697.       elsif working_essa6 /= save_essa6 and
  11698.             access_kf2.essa6 /= "  " then
  11699.     idm_param(idmrun,"$19",working_essa6,idm_int1);
  11700.       else
  11701.     idm_param(idmrun,"$19",save_essa6,idm_int1);
  11702.       end if;
  11703.       if access_kf2.essa7 = "# " then
  11704.     idm_param(idmrun,"$20",0,idm_int1);
  11705.       elsif working_essa7 /= save_essa7 and
  11706.             access_kf2.essa7 /= "  " then
  11707.     idm_param(idmrun,"$20",working_essa7,idm_int1);
  11708.       else
  11709.     idm_param(idmrun,"$20",save_essa7,idm_int1);
  11710.       end if;
  11711.       if access_kf2.essa8 = "# " then
  11712.         idm_param(idmrun,"$21",0,idm_int1);
  11713.       elsif working_essa8 /= save_essa8 and
  11714.             access_kf2.essa8 /= "  " then
  11715.         idm_param(idmrun,"$21",working_essa8,idm_int1);
  11716.       else
  11717.         idm_param(idmrun,"$21",save_essa8,idm_int1);
  11718.       end if;
  11719.       if access_kf2.essa9 = "# " then
  11720.         idm_param(idmrun,"$22",0,idm_int1);
  11721.       elsif working_essa9 /= save_essa9 and
  11722.             access_kf2.essa9 /= "  " then
  11723.         idm_param(idmrun,"$22",working_essa9,idm_int1);
  11724.       else
  11725.         idm_param(idmrun,"$22",save_essa9,idm_int1);
  11726.       end if;
  11727.       --
  11728.       -- add for ersa*
  11729.       --
  11730.       if access_kf2.ersa1 = "# " then
  11731.     idm_param(idmrun,"$23",0,idm_int1);
  11732.       elsif working_ersa1 /= save_ersa1 and
  11733.             access_kf2.ersa1 /= "  " then
  11734.     idm_param(idmrun,"$23",working_ersa1,idm_int1);
  11735.       else
  11736.     idm_param(idmrun,"$23",save_ersa1,idm_int1);
  11737.       end if;
  11738.       if access_kf2.ersa2 = "# " then
  11739.     idm_param(idmrun,"$24",0,idm_int1);
  11740.       elsif working_ersa2 /= save_ersa2 and
  11741.             access_kf2.ersa2 /= "  " then
  11742.     idm_param(idmrun,"$24",working_ersa2,idm_int1);
  11743.       else
  11744.     idm_param(idmrun,"$24",save_ersa2,idm_int1);
  11745.       end if;
  11746.       if access_kf2.ersa3 = "# " then
  11747.     idm_param(idmrun,"$25",0,idm_int1);
  11748.       elsif working_ersa3 /= save_ersa3 and
  11749.             access_kf2.ersa3 /= "  " then
  11750.     idm_param(idmrun,"$25",working_ersa3,idm_int1);
  11751.       else
  11752.     idm_param(idmrun,"$25",save_ersa3,idm_int1);
  11753.       end if;
  11754.       if access_kf2.ersa4 = "# " then
  11755.     idm_param(idmrun,"$26",0,idm_int1);
  11756.       elsif working_ersa4 /= save_ersa4 and
  11757.             access_kf2.ersa4 /= "  " then
  11758.     idm_param(idmrun,"$26",working_ersa4,idm_int1);
  11759.       else
  11760.     idm_param(idmrun,"$26",save_ersa4,idm_int1);
  11761.       end if;
  11762.       if access_kf2.ersa5 = "# " then
  11763.     idm_param(idmrun,"$27",0,idm_int1);
  11764.       elsif working_ersa5 /= save_ersa5 and
  11765.             access_kf2.ersa5 /= "  " then
  11766.     idm_param(idmrun,"$27",working_ersa5,idm_int1);
  11767.       else
  11768.     idm_param(idmrun,"$27",save_ersa5,idm_int1);
  11769.       end if;
  11770.       if access_kf2.ersa6 = "# " then
  11771.     idm_param(idmrun,"$28",0,idm_int1);
  11772.       elsif working_ersa6 /= save_ersa6 and
  11773.             access_kf2.ersa6 /= "  " then
  11774.     idm_param(idmrun,"$28",working_ersa6,idm_int1);
  11775.       else
  11776.     idm_param(idmrun,"$28",save_ersa6,idm_int1);
  11777.       end if;
  11778.       if access_kf2.ersa7 = "# " then
  11779.     idm_param(idmrun,"$29",0,idm_int1);
  11780.       elsif working_ersa7 /= save_ersa7 and
  11781.             access_kf2.ersa7 /= "  " then
  11782.     idm_param(idmrun,"$29",working_ersa7,idm_int1);
  11783.       else
  11784.     idm_param(idmrun,"$29",save_ersa7,idm_int1);
  11785.       end if;
  11786.       if access_kf2.ersa8 = "# " then
  11787.         idm_param(idmrun,"$30",0,idm_int1);
  11788.       elsif working_ersa8 /= save_ersa8 and
  11789.             access_kf2.ersa8 /= "  " then
  11790.         idm_param(idmrun,"$30",working_ersa8,idm_int1);
  11791.       else
  11792.         idm_param(idmrun,"$30",save_ersa8,idm_int1);
  11793.       end if;
  11794.       if access_kf2.ersa9 = "# " then
  11795.         idm_param(idmrun,"$31",0,idm_int1);
  11796.       elsif working_ersa9 /= save_ersa9 and
  11797.             access_kf2.ersa9 /= "  " then
  11798.         idm_param(idmrun,"$31",working_ersa9,idm_int1);
  11799.       else
  11800.         idm_param(idmrun,"$31",save_ersa9,idm_int1);
  11801.       end if;
  11802.     end if;
  11803.     idm_execute(idmrun);
  11804.     idm_fetch(idmrun);
  11805.   end if;
  11806.  
  11807. end process_card_kf2;
  11808.  
  11809. --*********************************************************************
  11810. --*
  11811. --*    PROCESS_CARD_KF3
  11812. --*
  11813. --*    This procedure will process the message cards of type 'KF3'.
  11814. --*    The record containing the card data is retrieved from the list,
  11815. --*    and the card is processed as a function of the transaction 
  11816. --*    code.
  11817. --*
  11818. --*********************************************************************
  11819.  
  11820. procedure process_card_kf3 is
  11821.   save_sdoc  : string(1..4);
  11822.   save_respf : string(1..5);
  11823.   save_readf : integer;
  11824.   save_reasf : string(1..1);
  11825.   save_prraf : integer;
  11826.   save_prref : string(1..3);
  11827.   save_esraf : integer;
  11828.   save_esref : string(1..3);
  11829.   save_erraf : integer;
  11830.   save_erref : string(1..3);
  11831.   save_trraf : integer;
  11832.   save_trref : string(1..3);
  11833.   save_secrf : string(1..3);
  11834.   save_terrf : string(1..3);
  11835.   save_caraf : integer;
  11836.   save_cadaf : string(1..8);
  11837.   save_limf  : integer;
  11838.   save_rlimf : string(1..2);
  11839.   save_ricdf : string(1..8);
  11840.   working_readf : integer;
  11841.   working_prraf : integer;
  11842.   working_esraf : integer;
  11843.   working_erraf : integer;
  11844.   working_trraf : integer;
  11845.   working_caraf : integer;
  11846.   working_cadaf : string(1..8) := "19000000";
  11847.   working_limf  : integer;
  11848.   working_ricdf : string(1..8) := "19000000";
  11849. begin
  11850.  
  11851.   access_kf3 := list_item.access_kf3;
  11852.  
  11853.   if list_item.Trtype = CHANGE then
  11854.     idm_command(idmrun,"return_card_kf3 $1 $2");
  11855.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11856.     idm_param(idmrun,"$2",access_kf3.docnr,idm_char);
  11857.     idm_execute(idmrun);
  11858.     idm_fetch(idmrun);
  11859.     idm_column(idmrun,1,save_secur,length_of_string);
  11860.     idm_column(idmrun,2,save_date,length_of_string);
  11861.     idm_column(idmrun,3,save_sdoc,length_of_string);
  11862.     idm_column(idmrun,4,save_respf,length_of_string);
  11863.     idm_column(idmrun,5,save_readf);
  11864.     idm_column(idmrun,6,save_reasf,length_of_string);
  11865.     idm_column(idmrun,7,save_prraf);
  11866.     idm_column(idmrun,8,save_prref,length_of_string);
  11867.     idm_column(idmrun,9,save_esraf);
  11868.     idm_column(idmrun,10,save_esref,length_of_string);
  11869.     idm_column(idmrun,11,save_erraf);
  11870.     idm_column(idmrun,12,save_erref,length_of_string);
  11871.     idm_column(idmrun,13,save_trraf);
  11872.     idm_column(idmrun,14,save_trref,length_of_string);
  11873.     idm_column(idmrun,15,save_secrf,length_of_string);
  11874.     idm_column(idmrun,16,save_terrf,length_of_string);
  11875.     idm_column(idmrun,17,save_caraf);
  11876.     idm_column(idmrun,18,save_cadaf,length_of_string);
  11877.     idm_column(idmrun,19,save_limf);
  11878.     idm_column(idmrun,20,save_rlimf,length_of_string);
  11879.     idm_column(idmrun,21,save_ricdf,length_of_string);
  11880.   end if;
  11881.  
  11882.   if list_item.Trtype /= ADD then
  11883.     idm_command(idmrun,"delete_card_kf3 $1 $2");
  11884.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11885.     idm_param(idmrun,"$2",access_kf3.docnr,idm_char);
  11886.     idm_execute(idmrun);
  11887.     idm_fetch(idmrun);
  11888.   end if;
  11889.  
  11890.   if list_item.Trtype /= DELETE then
  11891.     idm_command(idmrun,"add_card_kf3 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  11892.                        "$11 $12 $13 $14 $15 $16 $17 $18 $19 $20 $21 " &
  11893.                        "$22 $23 $24");
  11894.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  11895.     idm_param(idmrun,"$4",system_date,idm_char);
  11896.     idm_param(idmrun,"$5",access_kf3.docnr,idm_char);
  11897.     working_readf := string_to_integer(access_kf3.readf);
  11898.     working_prraf := string_to_integer(access_kf3.prraf);
  11899.     working_esraf := string_to_integer(access_kf3.esraf);
  11900.     working_erraf := string_to_integer(access_kf3.erraf);
  11901.     working_trraf := string_to_integer(access_kf3.trraf);
  11902.     working_caraf := string_to_integer(access_kf3.caraf);
  11903.     working_cadaf(3..8) := access_kf3.cadaf.yy &
  11904.                            access_kf3.cadaf.mm & access_kf3.cadaf.dd;
  11905.     working_limf  := string_to_integer(access_kf3.limf);
  11906.     working_ricdf(3..8) := access_kf3.ricdf.yy &
  11907.                            access_kf3.ricdf.mm & access_kf3.ricdf.dd;
  11908.     working_secur := secur_types'image(list_item.secur);
  11909.     if list_item.Trtype /= CHANGE then
  11910.       idm_param(idmrun,"$2",working_secur,idm_char);
  11911.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  11912.       idm_param(idmrun,"$6",access_kf3.sdoc,idm_char);
  11913.       idm_param(idmrun,"$7",access_kf3.respf,idm_char);
  11914.       idm_param(idmrun,"$8",working_readf,idm_int1);
  11915.       idm_param(idmrun,"$9",access_kf3.reasf,idm_char);
  11916.       idm_param(idmrun,"$10",working_prraf,idm_int1);
  11917.       idm_param(idmrun,"$11",access_kf3.prref,idm_char);
  11918.       idm_param(idmrun,"$12",working_esraf,idm_int1);
  11919.       idm_param(idmrun,"$13",access_kf3.esref,idm_char);
  11920.       idm_param(idmrun,"$14",working_erraf,idm_int1);
  11921.       idm_param(idmrun,"$15",access_kf3.erref,idm_char);
  11922.       idm_param(idmrun,"$16",working_trraf,idm_int1);
  11923.       idm_param(idmrun,"$17",access_kf3.trref,idm_char);
  11924.       idm_param(idmrun,"$18",access_kf3.secrf,idm_char);
  11925.       idm_param(idmrun,"$19",access_kf3.terrf,idm_char);
  11926.       idm_param(idmrun,"$20",working_caraf,idm_int1);
  11927.       idm_param(idmrun,"$21",working_cadaf,idm_char);
  11928.       idm_param(idmrun,"$22",working_limf,idm_int1);
  11929.       idm_param(idmrun,"$23",access_kf3.rlimf,idm_char);
  11930.       idm_param(idmrun,"$24",working_ricdf,idm_char);
  11931.     else
  11932.       if working_secur /= save_secur then
  11933.         idm_param(idmrun,"$2",working_secur,idm_char);
  11934.       else
  11935.         idm_param(idmrun,"$2",save_secur,idm_char);
  11936.       end if;
  11937.       if report_as_of_time /= save_date then
  11938.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  11939.       else
  11940.         idm_param(idmrun,"$3",save_date,idm_char);
  11941.       end if;
  11942.       if access_kf3.sdoc /= save_sdoc and access_kf3.sdoc /= "    " then
  11943.         idm_param(idmrun,"$6",access_kf3.sdoc,idm_char);
  11944.       else
  11945.         idm_param(idmrun,"$6",save_sdoc,idm_char);
  11946.       end if;
  11947.       if access_kf3.respf = "#    " then
  11948.         idm_param(idmrun,"$7","     ",idm_char);
  11949.       elsif access_kf3.respf /= save_respf and
  11950.             access_kf3.respf /= "     " then
  11951.         idm_param(idmrun,"$7",access_kf3.respf,idm_char);
  11952.       else
  11953.         idm_param(idmrun,"$7",save_respf,idm_char);
  11954.       end if;
  11955.       if working_readf /= save_readf and access_kf3.readf /= " " then
  11956.         idm_param(idmrun,"$8",working_readf,idm_int1);
  11957.       else
  11958.         idm_param(idmrun,"$8",save_readf,idm_int1);
  11959.       end if;
  11960.       if access_kf3.reasf /= save_reasf and access_kf3.reasf /= " " then
  11961.         idm_param(idmrun,"$9",access_kf3.reasf,idm_char);
  11962.       else
  11963.         idm_param(idmrun,"$9",save_reasf,idm_char);
  11964.       end if;
  11965.       if working_prraf /= save_prraf and access_kf3.prraf /= " " then
  11966.         idm_param(idmrun,"$10",working_prraf,idm_int1);
  11967.       else
  11968.         idm_param(idmrun,"$10",save_prraf,idm_int1);
  11969.       end if;
  11970.       if access_kf3.prref = "#  " then
  11971.         idm_param(idmrun,"$11","   ",idm_char);
  11972.       elsif access_kf3.prref /= save_prref and
  11973.             access_kf3.prref /= "   " then
  11974.         idm_param(idmrun,"$11",access_kf3.prref,idm_char);
  11975.       else
  11976.         idm_param(idmrun,"$11",save_prref,idm_char);
  11977.       end if;
  11978.       if working_esraf /= save_esraf and access_kf3.esraf /= " " then
  11979.         idm_param(idmrun,"$12",working_esraf,idm_int1);
  11980.       else
  11981.         idm_param(idmrun,"$12",save_esraf,idm_int1);
  11982.       end if;
  11983.       if access_kf3.esref = "#  " then
  11984.         idm_param(idmrun,"$13","   ",idm_char);
  11985.       elsif access_kf3.esref /= save_esref and
  11986.             access_kf3.esref /= "   " then
  11987.         idm_param(idmrun,"$13",access_kf3.esref,idm_char);
  11988.       else
  11989.         idm_param(idmrun,"$13",save_esref,idm_char);
  11990.       end if;
  11991.       if working_erraf /= save_erraf and access_kf3.erraf /= " " then
  11992.         idm_param(idmrun,"$14",working_erraf,idm_int1);
  11993.       else
  11994.         idm_param(idmrun,"$14",save_erraf,idm_int1);
  11995.       end if;
  11996.       if access_kf3.erref = "#  " then
  11997.         idm_param(idmrun,"$15","   ",idm_char);
  11998.       elsif access_kf3.erref /= save_erref and
  11999.             access_kf3.erref /= "   " then
  12000.         idm_param(idmrun,"$15",access_kf3.erref,idm_char);
  12001.       else
  12002.         idm_param(idmrun,"$15",save_erref,idm_char);
  12003.       end if;
  12004.       if working_trraf /= save_trraf and access_kf3.trraf /= " " then
  12005.         idm_param(idmrun,"$16",working_trraf,idm_int1);
  12006.       else
  12007.         idm_param(idmrun,"$16",save_trraf,idm_int1);
  12008.       end if;
  12009.       if access_kf3.trref = "#  " then
  12010.         idm_param(idmrun,"$17","   ",idm_char);
  12011.       elsif access_kf3.trref /= save_trref and
  12012.             access_kf3.trref /= "   " then
  12013.         idm_param(idmrun,"$17",access_kf3.trref,idm_char);
  12014.       else
  12015.         idm_param(idmrun,"$17",save_trref,idm_char);
  12016.       end if;
  12017.       if access_kf3.secrf = "#  " then
  12018.         idm_param(idmrun,"$18","   ",idm_char);
  12019.       elsif access_kf3.secrf /= save_secrf and
  12020.             access_kf3.secrf /= "   " then
  12021.         idm_param(idmrun,"$18",access_kf3.secrf,idm_char);
  12022.       else
  12023.         idm_param(idmrun,"$18",save_secrf,idm_char);
  12024.       end if;
  12025.       if access_kf3.terrf = "#  " or access_kf3.secrf = "#  " then
  12026.         idm_param(idmrun,"$19","   ",idm_char);
  12027.       elsif access_kf3.terrf /= save_terrf and
  12028.             access_kf3.terrf /= "   " then
  12029.         idm_param(idmrun,"$19",access_kf3.terrf,idm_char);
  12030.       else
  12031.         idm_param(idmrun,"$19",save_terrf,idm_char);
  12032.       end if;
  12033.       if access_kf3.caraf = "#" then
  12034.         idm_param(idmrun,"$20",0,idm_int1);
  12035.       elsif working_caraf /= save_caraf and access_kf3.caraf /= " " then
  12036.         idm_param(idmrun,"$20",working_caraf,idm_int1);
  12037.       else
  12038.         idm_param(idmrun,"$20",save_caraf,idm_int1);
  12039.       end if;
  12040.       if working_cadaf(3..8) = "#     " or access_kf3.caraf = "#" then
  12041.         idm_param(idmrun,"$21","        ",idm_char);
  12042.       elsif working_cadaf /= save_cadaf and
  12043.             working_cadaf(3..8) /= "      " then
  12044.         idm_param(idmrun,"$21",working_cadaf,idm_char);
  12045.       else
  12046.         idm_param(idmrun,"$21",save_cadaf,idm_char);
  12047.       end if;
  12048.       if access_kf3.limf = "#" then
  12049.         idm_param(idmrun,"$22",0,idm_int1);
  12050.       elsif working_limf /= save_limf and access_kf3.limf /= " " then
  12051.         idm_param(idmrun,"$22",working_limf,idm_int1);
  12052.       else
  12053.         idm_param(idmrun,"$22",save_limf,idm_int1);
  12054.       end if;
  12055.       if access_kf3.rlimf = "# " then
  12056.         idm_param(idmrun,"$23","  ",idm_char);
  12057.       elsif access_kf3.rlimf /= save_rlimf and
  12058.             access_kf3.rlimf /= "  " then
  12059.         idm_param(idmrun,"$23",access_kf3.rlimf,idm_char);
  12060.       else
  12061.         idm_param(idmrun,"$23",save_rlimf,idm_char);
  12062.       end if;
  12063.       if working_ricdf /= save_ricdf and
  12064.          working_ricdf(3..8) /= "      " then
  12065.         idm_param(idmrun,"$24",working_ricdf,idm_char);
  12066.       else
  12067.         idm_param(idmrun,"$24",save_ricdf,idm_char);
  12068.       end if;
  12069.     end if;
  12070.     idm_execute(idmrun);
  12071.     idm_fetch(idmrun);
  12072.   end if;
  12073.  
  12074. end process_card_kf3;
  12075.  
  12076.  
  12077. --*********************************************************************
  12078. --*
  12079. --*    PROCESS_CARD_KF4
  12080. --*
  12081. --*    This procedure will process the message cards of type 'KF4'.
  12082. --*    The record containing the card data is retrieved from the list,
  12083. --*    and the card is processed as a function of the transaction 
  12084. --*    code.
  12085. --*
  12086. --*********************************************************************
  12087.  
  12088. procedure process_card_kf4 is
  12089.   save_gccla : integer;
  12090.   save_gcclb : integer;
  12091.   save_gcclc : integer;
  12092.   save_spclu : string(1..9);
  12093.   save_smra1 : integer;
  12094.   save_smaa1 : integer;
  12095.   save_smrc1 : integer;
  12096.   save_smac1 : integer;
  12097.   save_smcc2 : integer;
  12098.   save_smra2 : integer;
  12099.   save_smaa2 : integer;
  12100.   save_smrc2 : integer;
  12101.   save_smac2 : integer;
  12102.   save_smcc3 : integer;
  12103.   save_smra3 : integer;
  12104.   save_smaa3 : integer;
  12105.   save_smrc3 : integer;
  12106.   save_smac3 : integer;
  12107.   save_smcc4 : integer;
  12108.   save_smra4 : integer;
  12109.   save_smaa4 : integer;
  12110.   save_smrc4 : integer;
  12111.   save_smac4 : integer;
  12112.   working_gccla : integer;
  12113.   working_gcclb : integer;
  12114.   working_gcclc : integer;
  12115.   working_smra1 : integer;
  12116.   working_smaa1 : integer;
  12117.   working_smrc1 : integer;
  12118.   working_smac1 : integer;
  12119.   working_smcc2 : integer;
  12120.   working_smra2 : integer;
  12121.   working_smaa2 : integer;
  12122.   working_smrc2 : integer;
  12123.   working_smac2 : integer;
  12124.   working_smcc3 : integer;
  12125.   working_smra3 : integer;
  12126.   working_smaa3 : integer;
  12127.   working_smrc3 : integer;
  12128.   working_smac3 : integer;
  12129.   working_smcc4 : integer;
  12130.   working_smra4 : integer;
  12131.   working_smaa4 : integer;
  12132.   working_smrc4 : integer;
  12133.   working_smac4 : integer;
  12134. begin
  12135.  
  12136.   access_kf4 := list_item.access_kf4;
  12137.  
  12138.   if list_item.Trtype = CHANGE then
  12139.     idm_command(idmrun,"return_card_kf4 $1");
  12140.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12141.     idm_execute(idmrun);
  12142.     idm_fetch(idmrun);
  12143.     idm_column(idmrun,1,save_secur,length_of_string);
  12144.     idm_column(idmrun,2,save_date,length_of_string);
  12145.     idm_column(idmrun,3,save_gccla);
  12146.     idm_column(idmrun,4,save_gcclb);
  12147.     idm_column(idmrun,5,save_gcclc);
  12148.     idm_column(idmrun,6,save_spclu,length_of_string);
  12149.     --
  12150.     -- retrieve for smcc1
  12151.     --
  12152.     idm_column(idmrun,7,save_smra1);
  12153.     idm_column(idmrun,8,save_smaa1);
  12154.     idm_column(idmrun,9,save_smrc1);
  12155.     idm_column(idmrun,10,save_smac1);
  12156.     idm_column(idmrun,11,save_smcc2);
  12157.     idm_column(idmrun,12,save_smra2);
  12158.     idm_column(idmrun,13,save_smaa2);
  12159.     idm_column(idmrun,14,save_smrc2);
  12160.     idm_column(idmrun,15,save_smac2);
  12161.     idm_column(idmrun,16,save_smcc3);
  12162.     idm_column(idmrun,17,save_smra3);
  12163.     idm_column(idmrun,18,save_smaa3);
  12164.     idm_column(idmrun,19,save_smrc3);
  12165.     idm_column(idmrun,20,save_smac3);
  12166.     idm_column(idmrun,21,save_smcc4);
  12167.     idm_column(idmrun,22,save_smra4);
  12168.     idm_column(idmrun,23,save_smaa4);
  12169.     idm_column(idmrun,24,save_smrc4);
  12170.     idm_column(idmrun,25,save_smac4);
  12171.   end if;
  12172.  
  12173.   if list_item.Trtype /= ADD then
  12174.     idm_command(idmrun,"delete_card_kf4 $1");
  12175.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12176.     idm_execute(idmrun);
  12177.     idm_fetch(idmrun);
  12178.     --
  12179.     -- delete for smcc1
  12180.     --
  12181.   end if;
  12182.  
  12183.   if list_item.Trtype /= DELETE then
  12184.     idm_command(idmrun,"add_card_kf4 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  12185.                        "$11 $12 $13 $14 $15 $16 $17 $18 $19 $20 $21 " &
  12186.                        "$22 $23 $24 $25 $26 $27 $28");
  12187.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12188.     idm_param(idmrun,"$4",system_date,idm_char);
  12189.     idm_param(idmrun,"$9",access_kf4.smcc1,idm_char);
  12190.     working_gccla := string_to_integer(access_kf4.gccla);
  12191.     working_gcclb := string_to_integer(access_kf4.gcclb);
  12192.     working_gcclc := string_to_integer(access_kf4.gcclc);
  12193.     working_smra1 := string_to_integer(access_kf4.smra1);
  12194.     working_smaa1 := string_to_integer(access_kf4.smaa1);
  12195.     working_smrc1 := string_to_integer(access_kf4.smrc1);
  12196.     working_smac1 := string_to_integer(access_kf4.smac1);
  12197.     working_smcc2 := string_to_integer(access_kf4.smcc2);
  12198.     working_smra2 := string_to_integer(access_kf4.smra2);
  12199.     working_smaa2 := string_to_integer(access_kf4.smaa2);
  12200.     working_smrc2 := string_to_integer(access_kf4.smrc2);
  12201.     working_smac2 := string_to_integer(access_kf4.smac2);
  12202.     working_smcc3 := string_to_integer(access_kf4.smcc3);
  12203.     working_smra3 := string_to_integer(access_kf4.smra3);
  12204.     working_smaa3 := string_to_integer(access_kf4.smaa3);
  12205.     working_smrc3 := string_to_integer(access_kf4.smrc3);
  12206.     working_smac3 := string_to_integer(access_kf4.smac3);
  12207.     working_smcc4 := string_to_integer(access_kf4.smcc4);
  12208.     working_smra4 := string_to_integer(access_kf4.smra4);
  12209.     working_smaa4 := string_to_integer(access_kf4.smaa4);
  12210.     working_smrc4 := string_to_integer(access_kf4.smrc4);
  12211.     working_smac4 := string_to_integer(access_kf4.smac4);
  12212.     working_secur := secur_types'image(list_item.secur);
  12213.     if list_item.Trtype /= CHANGE then
  12214.       idm_param(idmrun,"$2",working_secur,idm_char);
  12215.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  12216.       idm_param(idmrun,"$5",working_gccla,idm_int1);
  12217.       idm_param(idmrun,"$6",working_gcclb,idm_int1);
  12218.       idm_param(idmrun,"$7",working_gcclc,idm_int1);
  12219.       idm_param(idmrun,"$8",access_kf4.spclu,idm_char);
  12220.       --
  12221.       -- add for smcc1
  12222.       --
  12223.       idm_param(idmrun,"$10",working_smra1,idm_int1);
  12224.       idm_param(idmrun,"$11",working_smaa1,idm_int1);
  12225.       idm_param(idmrun,"$12",working_smrc1,idm_int1);
  12226.       idm_param(idmrun,"$13",working_smac1,idm_int1);
  12227.       idm_param(idmrun,"$14",working_smcc2,idm_int1);
  12228.       idm_param(idmrun,"$15",working_smra2,idm_int1);
  12229.       idm_param(idmrun,"$16",working_smaa2,idm_int1);
  12230.       idm_param(idmrun,"$17",working_smrc2,idm_int1);
  12231.       idm_param(idmrun,"$18",working_smac2,idm_int1);
  12232.       idm_param(idmrun,"$19",working_smcc3,idm_int1);
  12233.       idm_param(idmrun,"$20",working_smra3,idm_int1);
  12234.       idm_param(idmrun,"$21",working_smaa3,idm_int1);
  12235.       idm_param(idmrun,"$22",working_smrc3,idm_int1);
  12236.       idm_param(idmrun,"$23",working_smac3,idm_int1);
  12237.       idm_param(idmrun,"$24",working_smcc4,idm_int1);
  12238.       idm_param(idmrun,"$25",working_smra4,idm_int1);
  12239.       idm_param(idmrun,"$26",working_smaa4,idm_int1);
  12240.       idm_param(idmrun,"$27",working_smrc4,idm_int1);
  12241.       idm_param(idmrun,"$28",working_smac4,idm_int1);
  12242.     else
  12243.       if working_secur /= save_secur then
  12244.         idm_param(idmrun,"$2",working_secur,idm_char);
  12245.       else
  12246.         idm_param(idmrun,"$2",save_secur,idm_char);
  12247.       end if;
  12248.       if report_as_of_time /= save_date then
  12249.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  12250.       else
  12251.         idm_param(idmrun,"$3",save_date,idm_char);
  12252.       end if;
  12253.       if access_kf4.gccla = "# " then
  12254.         idm_param(idmrun,"$5",0,idm_int1);
  12255.       elsif working_gccla /= save_gccla and
  12256.             access_kf4.gccla /= "  " then
  12257.         idm_param(idmrun,"$5",working_gccla,idm_int1);
  12258.       else
  12259.         idm_param(idmrun,"$5",save_gccla,idm_int1);
  12260.       end if;
  12261.       if access_kf4.gcclb = "# " or access_kf4.gccla = "# " then
  12262.         idm_param(idmrun,"$6",0,idm_int1);
  12263.       elsif working_gcclb /= save_gcclb and
  12264.             access_kf4.gcclb /= "  " then
  12265.         idm_param(idmrun,"$6",working_gcclb,idm_int1);
  12266.       else
  12267.         idm_param(idmrun,"$6",save_gcclb,idm_int1);
  12268.       end if;
  12269.       if access_kf4.gcclc = "# " or access_kf4.gcclb = "# " or
  12270.          access_kf4.gccla = "# " then
  12271.         idm_param(idmrun,"$7",0,idm_int1);
  12272.       elsif working_gcclc /= save_gcclc and
  12273.             access_kf4.gcclc /= "  " then
  12274.         idm_param(idmrun,"$7",working_gcclc,idm_int1);
  12275.       else
  12276.         idm_param(idmrun,"$7",save_gcclc,idm_int1);
  12277.       end if;
  12278.       if access_kf4.spclu = "#        " then
  12279.         idm_param(idmrun,"$8","         ",idm_char);
  12280.       elsif access_kf4.spclu /= save_spclu and
  12281.             access_kf4.spclu /= "         " then
  12282.         idm_param(idmrun,"$8",access_kf4.spclu,idm_char);
  12283.       else
  12284.         idm_param(idmrun,"$8",save_spclu,idm_char);
  12285.       end if;
  12286.       --
  12287.       -- add for smcc1
  12288.       --
  12289.       if working_smra1 /= save_smra1 and access_kf4.smra1 /= "  " then
  12290.         idm_param(idmrun,"$10",working_smra1,idm_int1);
  12291.       else
  12292.         idm_param(idmrun,"$10",save_smra1,idm_int1);
  12293.       end if;
  12294.       if working_smaa1 /= save_smaa1 and access_kf4.smaa1 /= "  " then
  12295.         idm_param(idmrun,"$11",working_smaa1,idm_int1);
  12296.       else
  12297.         idm_param(idmrun,"$11",save_smaa1,idm_int1);
  12298.       end if;
  12299.       if working_smrc1 /= save_smrc1 and access_kf4.smrc1 /= "  " then
  12300.         idm_param(idmrun,"$12",working_smrc1,idm_int1);
  12301.       else
  12302.         idm_param(idmrun,"$12",save_smrc1,idm_int1);
  12303.       end if;
  12304.       if working_smac1 /= save_smac1 and access_kf4.smac1 /= "  " then
  12305.         idm_param(idmrun,"$13",working_smac1,idm_int1);
  12306.       else
  12307.         idm_param(idmrun,"$13",save_smac1,idm_int1);
  12308.       end if;
  12309.       if access_kf4.smcc2 = "# " then
  12310.         idm_param(idmrun,"$14",0,idm_int1);
  12311.       elsif working_smcc2 /= save_smcc2 and
  12312.             access_kf4.smcc2 /= "  " then
  12313.         idm_param(idmrun,"$14",working_smcc2,idm_int1);
  12314.       else
  12315.         idm_param(idmrun,"$14",save_smcc2,idm_int1);
  12316.       end if;
  12317.       if access_kf4.smcc2 = "# " then
  12318.         idm_param(idmrun,"$15",0,idm_int1);
  12319.       elsif working_smra2 /= save_smra2 and
  12320.             access_kf4.smra2 /= "  " then
  12321.         idm_param(idmrun,"$15",working_smra2,idm_int1);
  12322.       else
  12323.         idm_param(idmrun,"$15",save_smra2,idm_int1);
  12324.       end if;
  12325.       if access_kf4.smcc2 = "# " then
  12326.         idm_param(idmrun,"$16",0,idm_int1);
  12327.       elsif working_smaa2 /= save_smaa2 and
  12328.             access_kf4.smaa2 /= "  " then
  12329.         idm_param(idmrun,"$16",working_smaa2,idm_int1);
  12330.       else
  12331.         idm_param(idmrun,"$16",save_smaa2,idm_int1);
  12332.       end if;
  12333.       if access_kf4.smcc2 = "# " then
  12334.         idm_param(idmrun,"$17",0,idm_int1);
  12335.       elsif working_smrc2 /= save_smrc2 and
  12336.             access_kf4.smrc2 /= "  " then
  12337.         idm_param(idmrun,"$17",working_smrc2,idm_int1);
  12338.       else
  12339.         idm_param(idmrun,"$17",save_smrc2,idm_int1);
  12340.       end if;
  12341.       if access_kf4.smcc2 = "# " then
  12342.         idm_param(idmrun,"$18",0,idm_int1);
  12343.       elsif working_smac2 /= save_smac2 and
  12344.             access_kf4.smac2 /= "  " then
  12345.         idm_param(idmrun,"$18",working_smac2,idm_int1);
  12346.       else
  12347.         idm_param(idmrun,"$18",save_smac2,idm_int1);
  12348.       end if;
  12349.       if access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12350.         idm_param(idmrun,"$19",0,idm_int1);
  12351.       elsif working_smcc3 /= save_smcc3 and
  12352.             access_kf4.smcc3 /= "  " then
  12353.         idm_param(idmrun,"$19",working_smcc3,idm_int1);
  12354.       else
  12355.         idm_param(idmrun,"$19",save_smcc3,idm_int1);
  12356.       end if;
  12357.       if access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12358.         idm_param(idmrun,"$20",0,idm_int1);
  12359.       elsif working_smra3 /= save_smra3 and
  12360.             access_kf4.smra3 /= "  " then
  12361.         idm_param(idmrun,"$20",working_smra3,idm_int1);
  12362.       else
  12363.         idm_param(idmrun,"$20",save_smra3,idm_int1);
  12364.       end if;
  12365.       if access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12366.         idm_param(idmrun,"$21",0,idm_int1);
  12367.       elsif working_smaa3 /= save_smaa3 and
  12368.             access_kf4.smaa3 /= "  " then
  12369.         idm_param(idmrun,"$21",working_smaa3,idm_int1);
  12370.       else
  12371.         idm_param(idmrun,"$21",save_smaa3,idm_int1);
  12372.       end if;
  12373.       if access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12374.         idm_param(idmrun,"$22",0,idm_int1);
  12375.       elsif working_smrc3 /= save_smrc3 and
  12376.             access_kf4.smrc3 /= "  " then
  12377.         idm_param(idmrun,"$22",working_smrc3,idm_int1);
  12378.       else
  12379.         idm_param(idmrun,"$22",save_smrc3,idm_int1);
  12380.       end if;
  12381.       if access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12382.         idm_param(idmrun,"$23",0,idm_int1);
  12383.       elsif working_smac3 /= save_smac3 and
  12384.             access_kf4.smac3 /= "  " then
  12385.         idm_param(idmrun,"$23",working_smac3,idm_int1);
  12386.       else
  12387.         idm_param(idmrun,"$23",save_smac3,idm_int1);
  12388.       end if;
  12389.       if access_kf4.smcc4 = "# " or
  12390.          access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12391.         idm_param(idmrun,"$24",0,idm_int1);
  12392.       elsif working_smcc4 /= save_smcc4 and
  12393.             access_kf4.smcc4 /= "  " then
  12394.         idm_param(idmrun,"$24",working_smcc4,idm_int1);
  12395.       else
  12396.         idm_param(idmrun,"$24",save_smcc4,idm_int1);
  12397.       end if;
  12398.       if access_kf4.smcc4 = "# " or
  12399.          access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12400.         idm_param(idmrun,"$25",0,idm_int1);
  12401.       elsif working_smra4 /= save_smra4 and
  12402.             access_kf4.smra4 /= "  " then
  12403.         idm_param(idmrun,"$25",working_smra4,idm_int1);
  12404.       else
  12405.         idm_param(idmrun,"$25",save_smra4,idm_int1);
  12406.       end if;
  12407.       if access_kf4.smcc4 = "# " or
  12408.          access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12409.         idm_param(idmrun,"$26",0,idm_int1);
  12410.       elsif working_smaa4 /= save_smaa4 and
  12411.             access_kf4.smaa4 /= "  " then
  12412.         idm_param(idmrun,"$26",working_smaa4,idm_int1);
  12413.       else
  12414.         idm_param(idmrun,"$26",save_smaa4,idm_int1);
  12415.       end if;
  12416.       if access_kf4.smcc4 = "# " or
  12417.          access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12418.         idm_param(idmrun,"$27",0,idm_int1);
  12419.       elsif working_smrc4 /= save_smrc4 and
  12420.             access_kf4.smrc4 /= "  " then
  12421.         idm_param(idmrun,"$27",working_smrc4,idm_int1);
  12422.       else
  12423.         idm_param(idmrun,"$27",save_smrc4,idm_int1);
  12424.       end if;
  12425.       if access_kf4.smcc4 = "# " or
  12426.          access_kf4.smcc3 = "# " or access_kf4.smcc2 = "# " then
  12427.         idm_param(idmrun,"$28",0,idm_int1);
  12428.       elsif working_smac4 /= save_smac4 and
  12429.             access_kf4.smac4 /= "  " then
  12430.         idm_param(idmrun,"$28",working_smac4,idm_int1);
  12431.       else
  12432.         idm_param(idmrun,"$28",save_smac4,idm_int1);
  12433.       end if;
  12434.     end if;
  12435.     idm_execute(idmrun);
  12436.     idm_fetch(idmrun);
  12437.   end if;
  12438.  
  12439. end process_card_kf4;
  12440.  
  12441.  
  12442. --*********************************************************************
  12443. --*
  12444. --*    PROCESS_CARD_KN1
  12445. --*
  12446. --*    This procedure will process the message cards of type 'KN1'.
  12447. --*    The record containing the card data is retrieved from the list,
  12448. --*    and the card is processed as a function of the transaction 
  12449. --*    code.
  12450. --*
  12451. --*********************************************************************
  12452.  
  12453. procedure process_card_kn1 is
  12454.   working_prma : string(1..3);
  12455.   save_marat : string(1..1);
  12456.   save_marea : string(1..3);
  12457.   save_chdat : string(1..8);
  12458.   save_fmart : string(1..1);
  12459.   save_fcdat : string(1..8);
  12460.   working_chdat : string(1..8) := "19000000";
  12461.   working_fcdat : string(1..8) := "19000000";
  12462. begin
  12463.  
  12464.   access_kn1 := list_item.access_kn1;
  12465.   working_prma := prma_types'image(access_kn1.prma);
  12466.  
  12467.   if list_item.Trtype = CHANGE then
  12468.     idm_command(idmrun,"return_card_kn1 $1 $2");
  12469.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12470.     idm_param(idmrun,"$2",working_prma,idm_char);
  12471.     idm_execute(idmrun);
  12472.     idm_fetch(idmrun);
  12473.     idm_column(idmrun,1,save_secur,length_of_string);
  12474.     idm_column(idmrun,2,save_date,length_of_string);
  12475.     idm_column(idmrun,3,save_marat,length_of_string);
  12476.     idm_column(idmrun,4,save_marea,length_of_string);
  12477.     idm_column(idmrun,5,save_chdat,length_of_string);
  12478.     idm_column(idmrun,6,save_fmart,length_of_string);
  12479.     idm_column(idmrun,7,save_fcdat,length_of_string);
  12480.   end if;
  12481.  
  12482.   if list_item.Trtype /= ADD then
  12483.     idm_command(idmrun,"delete_card_kn1 $1 $2");
  12484.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12485.     idm_param(idmrun,"$2",working_prma,idm_char);
  12486.     idm_execute(idmrun);
  12487.     idm_fetch(idmrun);
  12488.   end if;
  12489.  
  12490.   if list_item.Trtype /= DELETE then
  12491.     idm_command(idmrun,"add_card_kn1 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10");
  12492.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12493.     idm_param(idmrun,"$4",system_date,idm_char);
  12494.     idm_param(idmrun,"$5",working_prma,idm_char);
  12495.     working_secur := secur_types'image(list_item.secur);
  12496.     working_chdat(3..8) := access_kn1.chdat.yy &
  12497.                            access_kn1.chdat.mm & access_kn1.chdat.dd;
  12498.     working_fcdat(3..8) := access_kn1.fcdat.yy &
  12499.                            access_kn1.fcdat.mm & access_kn1.fcdat.dd;
  12500.     if list_item.Trtype /= CHANGE then
  12501.       idm_param(idmrun,"$2",working_secur,idm_char);
  12502.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  12503.       idm_param(idmrun,"$6",access_kn1.marat,idm_char);
  12504.       idm_param(idmrun,"$7",access_kn1.marea,idm_char);
  12505.       idm_param(idmrun,"$8",working_chdat,idm_char);
  12506.       idm_param(idmrun,"$9",access_kn1.fmart,idm_char);
  12507.       idm_param(idmrun,"$10",working_fcdat,idm_char);
  12508.     else
  12509.       if working_secur /= save_secur then
  12510.         idm_param(idmrun,"$2",working_secur,idm_char);
  12511.       else
  12512.         idm_param(idmrun,"$2",save_secur,idm_char);
  12513.       end if;
  12514.       if report_as_of_time /= save_date then
  12515.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  12516.       else
  12517.         idm_param(idmrun,"$3",save_date,idm_char);
  12518.       end if;
  12519.       if access_kn1.marat /= save_marat and access_kn1.marat /= " " then
  12520.         idm_param(idmrun,"$6",access_kn1.marat,idm_char);
  12521.       else
  12522.         idm_param(idmrun,"$6",save_marat,idm_char);
  12523.       end if;
  12524.       if access_kn1.marea /= save_marea and
  12525.          access_kn1.marea /= "   " then
  12526.         idm_param(idmrun,"$7",access_kn1.marea,idm_char);
  12527.       else
  12528.         idm_param(idmrun,"$7",save_marea,idm_char);
  12529.       end if;
  12530.       if working_chdat /= save_chdat and
  12531.          working_chdat(3..8) /= "      " then
  12532.         idm_param(idmrun,"$8",working_chdat,idm_char);
  12533.       else
  12534.         idm_param(idmrun,"$8",save_chdat,idm_char);
  12535.       end if;
  12536.       if access_kn1.fmart = "#" or working_fcdat(3..8) = "#     " then
  12537.         idm_param(idmrun,"$9"," ",idm_char);
  12538.         idm_param(idmrun,"$10","        ",idm_char);
  12539.       else
  12540.         if access_kn1.fmart /= save_fmart and
  12541.            access_kn1.fmart /= " " then
  12542.           idm_param(idmrun,"$9",access_kn1.fmart,idm_char);
  12543.         else
  12544.           idm_param(idmrun,"$9",save_fmart,idm_char);
  12545.         end if;
  12546.         if working_fcdat /= save_fcdat and
  12547.            working_fcdat(3..8) /= "      " then
  12548.           idm_param(idmrun,"$10",working_fcdat,idm_char);
  12549.         else
  12550.           idm_param(idmrun,"$10",save_fcdat,idm_char);
  12551.         end if;
  12552.       end if;
  12553.     end if;
  12554.     idm_execute(idmrun);
  12555.     idm_fetch(idmrun);
  12556.   end if;
  12557.  
  12558. end process_card_kn1;
  12559.  
  12560. --*********************************************************************
  12561. --*
  12562. --*    PROCESS_CARD_TF1
  12563. --*
  12564. --*    This procedure will process the message cards of type 'TF1'.
  12565. --*    The record containing the card data is retrieved from the list,
  12566. --*    and the card is processed as a function of the transaction 
  12567. --*    code.
  12568. --*
  12569. --*********************************************************************
  12570.  
  12571. procedure process_card_tf1 is
  12572.   save_meqs  : string(1..1);
  12573.   save_sedy  : string(1..1);
  12574.   save_tedy  : string(1..1);
  12575.   save_erddy : string(1..8);
  12576.   save_avail : string(1..1);
  12577.   save_eqret : string(1..8);
  12578.   save_geogr : string(1..4);
  12579.   save_operl : string(1..8);
  12580.   save_dafld : string(1..4);
  12581.   save_dcndy : string(1..5);
  12582.   working_erddy : string(1..8) := "19000000";
  12583.   working_eqret : string(1..8) := "19000000";
  12584.   working_operl : string(1..8) := "19000000";
  12585. begin
  12586.  
  12587.   access_tf1 := list_item.access_tf1;
  12588.  
  12589.   if list_item.Trtype = CHANGE then
  12590.     idm_command(idmrun,"return_card_tf1 $1 $2 $3");
  12591.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12592.     idm_param(idmrun,"$2",access_tf1.ueqpt,idm_char);
  12593.     idm_param(idmrun,"$3",access_tf1.mesen,idm_char);
  12594.     idm_execute(idmrun);
  12595.     idm_fetch(idmrun);
  12596.     idm_column(idmrun,1,save_secur,length_of_string);
  12597.     idm_column(idmrun,2,save_date,length_of_string);
  12598.     idm_column(idmrun,3,save_meqs,length_of_string);
  12599.     idm_column(idmrun,4,save_sedy,length_of_string);
  12600.     idm_column(idmrun,5,save_tedy,length_of_string);
  12601.     idm_column(idmrun,6,save_erddy,length_of_string);
  12602.     idm_column(idmrun,7,save_avail,length_of_string);
  12603.     idm_column(idmrun,8,save_eqret,length_of_string);
  12604.     idm_column(idmrun,9,save_geogr,length_of_string);
  12605.     idm_column(idmrun,10,save_operl,length_of_string);
  12606.     idm_column(idmrun,11,save_dafld,length_of_string);
  12607.     idm_column(idmrun,12,save_dcndy,length_of_string);
  12608.   end if;
  12609.  
  12610.   if list_item.Trtype /= ADD then
  12611.     idm_command(idmrun,"delete_card_tf1 $1 $2 $3");
  12612.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12613.     idm_param(idmrun,"$2",access_tf1.ueqpt,idm_char);
  12614.     idm_param(idmrun,"$3",access_tf1.mesen,idm_char);
  12615.     idm_execute(idmrun);
  12616.     idm_fetch(idmrun);
  12617.   end if;
  12618.  
  12619.   if list_item.Trtype /= DELETE then
  12620.     idm_command(idmrun,"add_card_tf1 $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 " &
  12621.                        "$11 $12 $13 $14 $15 $16");
  12622.     idm_param(idmrun,"$1",list_item.uic,idm_char);
  12623.     idm_param(idmrun,"$4",system_date,idm_char);
  12624.     idm_param(idmrun,"$5",access_tf1.ueqpt,idm_char);
  12625.     idm_param(idmrun,"$6",access_tf1.mesen,idm_char);
  12626.     working_secur := secur_types'image(list_item.secur);
  12627.     working_erddy(3..8) := access_tf1.erddy.yy &
  12628.                            access_tf1.erddy.mm & access_tf1.erddy.dd;
  12629.     working_eqret(3..8) := access_tf1.eqret.yy &
  12630.                            access_tf1.eqret.mm & access_tf1.eqret.dd;
  12631.     working_operl(3..8) := access_tf1.operl.yy &
  12632.                            access_tf1.operl.mm & access_tf1.operl.dd;
  12633.     if list_item.Trtype /= CHANGE then
  12634.       idm_param(idmrun,"$2",working_secur,idm_char);
  12635.       idm_param(idmrun,"$3",report_as_of_time,idm_char);
  12636.       idm_param(idmrun,"$7",access_tf1.meqs,idm_char);
  12637.       idm_param(idmrun,"$8",access_tf1.sedy,idm_char);
  12638.       idm_param(idmrun,"$9",access_tf1.tedy,idm_char);
  12639.       idm_param(idmrun,"$10",working_erddy,idm_char);
  12640.       idm_param(idmrun,"$11",access_tf1.avail,idm_char);
  12641.       idm_param(idmrun,"$12",working_eqret,idm_char);
  12642.       idm_param(idmrun,"$13",access_tf1.geogr,idm_char);
  12643.       idm_param(idmrun,"$14",working_operl,idm_char);
  12644.       idm_param(idmrun,"$15",access_tf1.dafld,idm_char);
  12645.       idm_param(idmrun,"$16",access_tf1.dcndy,idm_char);
  12646.     else
  12647.       if working_secur /= save_secur then
  12648.         idm_param(idmrun,"$2",working_secur,idm_char);
  12649.       else
  12650.         idm_param(idmrun,"$2",save_secur,idm_char);
  12651.       end if;
  12652.       if report_as_of_time /= save_date then
  12653.         idm_param(idmrun,"$3",report_as_of_time,idm_char);
  12654.       else
  12655.         idm_param(idmrun,"$3",save_date,idm_char);
  12656.       end if;
  12657.       if access_tf1.meqs /= save_meqs and access_tf1.meqs /= " " then
  12658.         idm_param(idmrun,"$7",access_tf1.meqs,idm_char);
  12659.       else
  12660.         idm_param(idmrun,"$7",save_meqs,idm_char);
  12661.       end if;
  12662.       if access_tf1.sedy /= save_sedy and access_tf1.sedy /= " " then
  12663.         idm_param(idmrun,"$8",access_tf1.sedy,idm_char);
  12664.       else
  12665.         idm_param(idmrun,"$8",save_sedy,idm_char);
  12666.       end if;
  12667.       if access_tf1.tedy /= save_tedy and access_tf1.tedy /= " " then
  12668.         idm_param(idmrun,"$9",access_tf1.tedy,idm_char);
  12669.       else
  12670.         idm_param(idmrun,"$9",save_tedy,idm_char);
  12671.       end if;
  12672.       if working_erddy /= save_erddy and
  12673.          working_erddy(3..8) /= "      " then
  12674.         idm_param(idmrun,"$10",working_erddy,idm_char);
  12675.       else
  12676.         idm_param(idmrun,"$10",save_erddy,idm_char);
  12677.       end if;
  12678.       if access_tf1.avail /= save_avail and access_tf1.avail /= " " then
  12679.         idm_param(idmrun,"$11",access_tf1.avail,idm_char);
  12680.       else
  12681.         idm_param(idmrun,"$11",save_avail,idm_char);
  12682.       end if;
  12683.       if working_eqret(3..8) = "#     " then
  12684.         idm_param(idmrun,"$12","        ",idm_char);
  12685.       elsif working_eqret /= save_eqret and
  12686.             working_eqret(3..8) /= "      " then
  12687.         idm_param(idmrun,"$12",working_eqret,idm_char);
  12688.       else
  12689.         idm_param(idmrun,"$12",save_eqret,idm_char);
  12690.       end if;
  12691.       if access_tf1.geogr = "#   " then
  12692.         idm_param(idmrun,"$13","    ",idm_char);
  12693.       elsif access_tf1.geogr /= save_geogr and
  12694.             access_tf1.geogr /= "    " then
  12695.         idm_param(idmrun,"$13",access_tf1.geogr,idm_char);
  12696.       else
  12697.         idm_param(idmrun,"$13",save_geogr,idm_char);
  12698.       end if;
  12699.       if working_operl /= save_operl and
  12700.          working_operl(3..8) /= "      " then
  12701.         idm_param(idmrun,"$14",working_operl,idm_char);
  12702.       else
  12703.         idm_param(idmrun,"$14",save_operl,idm_char);
  12704.       end if;
  12705.       if access_tf1.dafld = "#   " then
  12706.         idm_param(idmrun,"$15","    ",idm_char);
  12707.       elsif access_tf1.dafld /= save_dafld and
  12708.             access_tf1.dafld /= "    " then
  12709.         idm_param(idmrun,"$15",access_tf1.dafld,idm_char);
  12710.       else
  12711.         idm_param(idmrun,"$15",save_dafld,idm_char);
  12712.       end if;
  12713.       if access_tf1.dcndy /= save_dcndy and
  12714.          access_tf1.dcndy /= "     " then
  12715.         idm_param(idmrun,"$16",access_tf1.dcndy,idm_char);
  12716.       else
  12717.         idm_param(idmrun,"$16",save_dcndy,idm_char);
  12718.       end if;
  12719.     end if;
  12720.     idm_execute(idmrun);
  12721.     idm_fetch(idmrun);
  12722.   end if;
  12723.  
  12724. end process_card_tf1;
  12725.  
  12726. --*********************************************************************
  12727. --*
  12728. --*    GET_AND_STORE_SYSTEM_DATE
  12729. --*
  12730. --*      This procedure will get the system date and store in
  12731. --*    system_date a variable defined as a string of 8 characters
  12732. --*
  12733. --*********************************************************************
  12734.  
  12735. procedure get_and_store_system_date is
  12736.  
  12737. begin
  12738.   system_time       := clock;
  12739.   system_year       := year(system_time);
  12740.   system_month      := month(system_time);
  12741.   system_day        := day(system_time);
  12742.   system_date       := "00000000";
  12743.   working_string(1..5)    := integer'image(system_year);
  12744.   system_date(1..4) := working_string(2..5);
  12745.   if system_month < 10 then
  12746.     working_string(1..2) := integer'image(system_month);
  12747.     system_date(6..6)    := working_string(2..2);
  12748.   else
  12749.     working_string(1..3) := integer'image(system_month);
  12750.     system_date(5..6)    := working_string(2..3);
  12751.   end if;
  12752.   if system_day < 10 then
  12753.     working_string(1..2) := integer'image(system_day);
  12754.     system_date(8..8)    := working_string(2..2);
  12755.   else
  12756.     working_string(1..3) := integer'image(system_day);
  12757.     system_date(7..8)    := working_string(2..3);
  12758.   end if;
  12759.  
  12760. end get_and_store_system_date;
  12761.  
  12762.  
  12763. end Database_Build;
  12764. --::::::::::
  12765. --modcoms.src
  12766. --::::::::::
  12767. --**********************************************************************
  12768. --
  12769. --
  12770. --                  M O D U L E  C O M M U N I C A T I O N S
  12771. --
  12772. --
  12773. --*********************************************************************
  12774. with System_Utilities, Man_Machine_Interface, text_io;
  12775. with Message_Input_Module, Message_Validation_Module;
  12776. with Database_Build;
  12777. use System_Utilities, text_io;
  12778.  
  12779. package Module_Communications is
  12780.  
  12781.    task MMI_Monitor;
  12782.  
  12783.    task MI_Monitor;
  12784.  
  12785.    task MV_Monitor;
  12786.  
  12787.    task DBB_Monitor;
  12788.  
  12789. end Module_Communications;
  12790.  
  12791.  
  12792. package body Module_Communications is
  12793.  
  12794. --**********************************************************************
  12795. --                          MMI_MONITOR
  12796. --
  12797. --  This routine is the task monitoring the task packet queue for the
  12798. --  MMI module.  It will pick the oldest task packet from the queue of
  12799. --  packets designated for the MMI module.  It will call the MMI module
  12800. --  with that packet at a rendezvous then update the queue pointers.
  12801. --**********************************************************************
  12802.  
  12803. task body MMI_Monitor is
  12804.   P : Packet_Access;
  12805. begin
  12806.   loop
  12807.     if MMI_Queue.Count > 0 then
  12808.       P:= MMI_Queue.First;
  12809.       if P = MMI_Queue.Last then
  12810.         MMI_Queue.First:= null;
  12811.         MMI_Queue.Last:= null;
  12812.         MMI_Queue.Count:= 0;
  12813.       else
  12814.         MMI_Queue.First:= P.Next;
  12815.         MMI_Queue.Count:= MMI_Queue.Count-1;
  12816.       end if;
  12817.       Man_Machine_Interface.MMI_Packet_Path.Packet_Process(P);
  12818.     end if;
  12819.   end loop;
  12820.  
  12821.   exception
  12822.     when others => put_line("mmi monitor dead");
  12823. end MMI_Monitor;
  12824.  
  12825.  
  12826. --**********************************************************************
  12827. --                          MI_MONITOR
  12828. --
  12829. --  This routine is the task monitoring the task packet queue for the MI
  12830. --  module.  It will pick the oldest task packet from the queue of
  12831. --  packet designated for the MI module.  It will call the MI module
  12832. --  with that packet at a rendezvous then update the queue pointers.
  12833. --**********************************************************************
  12834.  
  12835. task body MI_Monitor is
  12836.   P : packet_access;
  12837. begin
  12838.   loop
  12839.     if MI_Queue.Count > 0 then
  12840.       P:= MI_Queue.First;
  12841.       if P = MI_Queue.Last then
  12842.         MI_Queue.First:= null;
  12843.         MI_Queue.Last:= null;
  12844.         MI_Queue.Count:= 0;
  12845.       else
  12846.         MI_Queue.First:= P.Next;
  12847.         MI_Queue.Count:= MI_Queue.Count-1;
  12848.       end if;
  12849.       Message_Input_Module.Message_Request.Request_Function(P);
  12850.     end if;
  12851.   end loop;
  12852.  
  12853.   exception
  12854.     when others => put_line("mi monitor dead");
  12855. end MI_Monitor;
  12856.  
  12857.  
  12858. --**********************************************************************
  12859. --                          MV_MONITOR
  12860. --
  12861. --  This routine is the task monitoring the task packet queue for the MV
  12862. --  module.  It will pick the oldest task packet from the queue of
  12863. --  packets designated for the MV module.  It will call the MV module
  12864. --  with that packet at a rendezvous then update the queue pointers.
  12865. --**********************************************************************
  12866.  
  12867. task body MV_Monitor is
  12868.   P : packet_access;
  12869. begin
  12870.   loop
  12871.     if MV_Queue.Count > 0 then
  12872.       P:= MV_Queue.First;
  12873.       if P = MV_Queue.Last then
  12874.         MV_Queue.First:= null;
  12875.         MV_Queue.Last:= null;
  12876.         MV_Queue.Count:= 0;
  12877.       else
  12878.         MV_Queue.First:= P.Next;
  12879.         MV_Queue.Count:= MV_Queue.Count-1;
  12880.       end if;
  12881.       Message_Validation_Module.Message_Receive.Receive_Function(P);
  12882.     end if;
  12883.   end loop;
  12884.  
  12885.   exception
  12886.     when others => put_line("mv monitor dead");
  12887. end MV_Monitor;
  12888.  
  12889.  
  12890. --**********************************************************************
  12891. --                          DBB_MONITOR
  12892. --
  12893. --  This routine is the task monitoring the task packet queue for the
  12894. --  DBB module.  It will pick the oldest task packet from the queue of
  12895. --  packets designated for the DBB module.  It will call the DBB module
  12896. --  with that packet at a rendezvous then update the queue pointers.
  12897. --**********************************************************************
  12898.  
  12899. task body DBB_Monitor is
  12900.   P : packet_access;
  12901. begin
  12902.   loop
  12903.     if DBB_Queue.Count > 0 then
  12904.       P:= DBB_Queue.First;
  12905.       if P = DBB_Queue.Last then
  12906.         DBB_Queue.First:= null;
  12907.         DBB_Queue.Last:= null;
  12908.         DBB_Queue.Count:= 0;
  12909.       else
  12910.         DBB_Queue.First:= P.Next;
  12911.         DBB_Queue.Count:= DBB_Queue.Count-1;
  12912.       end if;
  12913.       Database_Build.Database_Build_Task.Rendezvous_Point(P);
  12914.     end if;
  12915.   end loop;
  12916.  
  12917.   exception
  12918.     when others => put_line("dbb monitor dead");
  12919. end DBB_Monitor;
  12920.  
  12921.  
  12922. begin
  12923.   null;
  12924.  
  12925.   exception 
  12926.     when others => put_line("module communications dead");
  12927. end Module_Communications;
  12928. --::::::::::
  12929. --main.src
  12930. --::::::::::
  12931. with text_io;
  12932. with Module_communications;
  12933.  
  12934. procedure main is
  12935.  
  12936. begin
  12937.   loop
  12938.     null;
  12939.   end loop;
  12940.  
  12941. exception
  12942.   when others => text_io.put_line("Main dead");
  12943. end main;
  12944.  
  12945.