000100 Identification Division. 000200 Program-Id. PERSREG1. 000300 Environment Division. 000400 Input-Output Section. 000500 File-Control. 000600 Select Indata Assign to PERSDD 000700 Organization is Indexed 000800 Access is Dynamic 000900 Record Key is Anstnr 001000 Alternate Record Key is Persnr 001100 Alternate Record Key is Avdnr with Duplicates 001200 File Status is Filstat 001300 . 001400 Data Division. 001500 File Section. 001600 FD Indata. 001700 01 Indatapost. 001800 05 Anstnr Pic X(05). 001900 05 Persnr Pic X(10). 002000 05 Namn. 002100 10 Fnamn Pic X(20). 002200 10 Enamn Pic X(20). 002300 05 Avdnr Pic X(05). 002400 05 Pic X(20). 002500 002600 Working-Storage Section. 002700 77 Stringnamn Pic X(20). 002800 002900 77 Filstat Pic XX. 003000 77 Pic 9(01) Value 0. 003100 88 Klar Value 1. 003200 003300 Linkage Section. 003400 01 Parameter. 003500 05 Plen Pic S9(04) Binary. 003600 05 Pdata. 003700 10 Ptyp Pic X(05). 003800 88 Anstparm Value 'ANST='. 003900 88 Persparm Value 'PERS='. 004000 88 Avdparm Value 'AVDE='. 004100 88 Listparm Value 'LISTA'. 004200 10 Nummer Pic X(10). 004300 004400 Procedure Division Using Parameter. 004500 Perform KontrolleraParameter 004600 If Return-Code > 0 004700 GoBack 004800 End-If 004900 005000 Perform Oppnafilen 005100 Evaluate True 005200 When Anstparm 005300 Perform ReadAnstnr 005400 When Persparm 005500 Perform ReadPersnr 005600 When Avdparm 005700 Perform ReadAvdnr 005800 When Listparm 005900 Perform ListAvdnrOrdning 006000 When Other 006100 Display 'Parameter ' pdata ' felaktig' 006200 Move 12 to Return-Code 006300 GoBack 006400 End-Evaluate 006500 GoBack 006600 . 006700 KontrolleraParameter. 006800 If Plen < 5 006900 Move 99 to Return-Code 007000 Display 'Parameter saknas eller felaktig' 007100 End-If 007200 . 007300*-------------------------------------------------------- 007400 Oppnafilen. 007500*-------------------------------------------------------- 007600 Open Input Indata 007700 If Filstat Not = '00' 007800 Display 'Filstatus :' Filstat 007900 Move 12 to Return-Code 008000 GoBack 008100 End-If 008200 . 008300*-------------------------------------------------------- 008400 ReadAnstnr. 008500*-------------------------------------------------------- 008600 Display 'Läser anst.nummer: ' Nummer 008700 Move Nummer to Anstnr 008800 Read Indata 008900 Invalid Key 009000 Display 'Post med nyckel: ' Anstnr ' saknas' 009100 Move 25 to Return-Code 009200 Not Invalid Key 009300 Display Indatapost 009400 End-Read 009500 Display 'Har läst anstnr' 009600 Display 'Statuskod: ' Filstat 009700 . 009800*-------------------------------------------------------- 009900 ReadPersnr. 010000*-------------------------------------------------------- 010100 Display 'Läser personnummer: ' Nummer 010200 Move Nummer to Persnr 010300 Read Indata key is Persnr 010400 Invalid Key 010500 Display 'Post med nyckel: ' Persnr ' saknas' 010600 Move 25 to Return-Code 010700 Not Invalid Key 010800 Display Indatapost 010900 End-Read 011000 Display 'Har läst persnr' 011100 Display 'Statustkod : ' Filstat 011200 . 011300*-------------------------------------------------------- 011400 ReadAvdnr. 011500* Ej unika nycklar 011600*-------------------------------------------------------- 011700 Display '*** Läser avdelningsnr: ' Nummer ' ***' 011800 Move Nummer to Avdnr 011900 Read Indata key is Avdnr 012000 Invalid Key 012100 Display 'Post med nyckel: ' Avdnr ' saknas' 012200 Move 25 to Return-Code 012300 Not Invalid Key 012400 Display Indatapost 012500 Perform Until Filstat Not = '02' 012600 Read Indata Next 012700 At End 012800 Display 'Poster med nyckel: ' Avdnr ' lästa' 012900 Not At End 013000 Display Indatapost 013100 End-Read 013200 End-Perform 013300 End-Read 013400 Display '*** Läsning klar ***' 013500 . 013510*-------------------------------------------------------- 013600 ListAvdnrOrdning. 013610*-------------------------------------------------------- 013700 Move Space to Anstnr 013800 Start Indata 013900 Key is Greater Than Avdnr 014000 Invalid Key 014100 Display 'Fel vid START av Infil' 014200 Display 'Statutkod : ' Filstat 014300 Not Invalid Key 014400 Display 'Startpunkt etablerad' 014500 End-Start 014600 Perform Until Klar 014700 Read Indata Next Record 014800 At End 014900 Set Klar to True 015000 Display 'Utskrift Klar' 015100 Not At End 015200 String 015300 Fnamn Delimited By Space 015400 Space Delimited By Size 015500 Enamn Delimited By Space 015600 Into StringNamn 015700 End-String 015800 Display Avdnr ' ' Anstnr ' ' Persnr ' ' 015900 StringNamn 016000 End-Read 016100 End-Perform 016200 . 016300 End Program PERSREG1.