Traveldixie
Programmer
Hello all,
I'm a starter in cobol-programming but I do feel something is weird about this problem.
Please forgive me for the lenghty program as I don't know how to show you otherwise my problem with it...
I'm working on an Athlon with XP as OS and I'm using the Microfocus compiler with that.
Usually I'm starting it up using the workbench (WB.EXE).
This time however, for some reason it seems to me as if XP is not letting me work with Indexed Files under cobol. This is the first time I have to work with these kind of files and while compiling the cobol-editor window will crash and close on me giving me an error message in windows, something like "could not find requested COM1-port. closing program" As far as I know I never asked for any COM-port...only to OPEN an indexed file with OPEN I-O... Some people I've talked to so far are telling me that "cobol don't match with XP"...but that's not a good enough answer for me, they never tell me why or what I should do or when exactly there are problems with it, or what guarantee I have that it will work if I would use Win9X (which I really would like to prevent..).
I found a way to (temporarily?) circumvent this annoyance by running the Microfocus-editor not using the Workbench but directly using the EDITOR.EXE. For some weird reason I could start programming and compiling and even running my growing program this way, even using OPEN I-O commands...
I'm saying this because maybe all this has something to do with my real problem now :
I will copy the whole program here as is...I hope someone has the time to check it out...of course I'll reward you for your time.
IDENTIFICATION DIVISION.
PROGRAM-ID. Boek-File-Operations.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. PC.
OBJECT-COMPUTER. PC.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT BOEK-FILE ASSIGN TO "s2svhbk.isq"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS BK-KEY
ALTERNATE KEY IS BK-ISBN
ALTERNATE KEY IS BK-TITEL.
SELECT CLASSIFICATIE-FILE ASSIGN TO "classif.isq"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD BOEK-FILE.
01 BK-RECORD.
05 BK-KEY PIC X(06).
05 BK-TITEL PIC X(30).
05 BK-AUTEUR.
10 BK-AUTEUR-AN PIC X(20).
10 BK-AUTEUR-VN PIC X(20).
05 BK-ISBN PIC X(13).
05 BK-UITGEVERIJ PIC X(20).
05 BK-UITGIFTE-JAAR PIC 9(04).
05 BK-CLASSIF PIC X(04).
05 BK-AANT-PAG PIC 9(04).
FD CLASSIFICATIE-FILE.
01 CLASSIF-RECORD.
05 CL-CODE PIC X(04).
05 CL-DETAIL PIC X(50).
WORKING-STORAGE SECTION.
01 WS-BK-RECORD.
05 WS-BK-KEY PIC X(06).
05 WS-BK-TITEL PIC X(30).
05 WS-BK-AUTEUR.
10 WS-BK-AUTEUR-AN PIC X(20).
10 WS-BK-AUTEUR-VN PIC X(20).
05 WS-BK-ISBN PIC X(13).
05 WS-BK-UITGEVERIJ PIC X(20).
05 WS-BK-UITGIFTE-JAAR PIC 9(04).
05 WS-BK-CLASSIF PIC X(04).
05 WS-BK-AANT-PAG PIC zzz9.
01 WS-CLASSIF-RECORD.
05 WS-CL-CODE PIC X(04).
05 WS-CL-DETAIL PIC X(50).
01 ISBNNUMBERS.
05 CYPHER PIC 9 OCCURS 12 VALUE ALL ZEROES.
05 CYPHLET PIC X VALUE ALL ZEROES.
01 ISBNRESULT.
05 RESULT PIC 99 OCCURS 10 VALUE ALL ZEROES.
01 DATUM.
05 jaar PIC 99.
05 maand PIC 99.
05 dag PIC 99.
77 keuze PIC 9 VALUE 0.
88 keuze-geldig VALUE 1 THROUGH 3.
77 nieuwrecnr PIC 9(06) VALUE 0.
77 eof PIC 9 VALUE 0.
77 groupid PIC 9(05).
77 pub PIC 9(07).
77 titleid PIC 9(06).
77 chk PIC 9(01).
77 isbnchk PIC 9 VALUE 0.
77 counter PIC 9(02) VALUE 1.
77 ptr1 PIC 9 VALUE 1.
77 ptr2 PIC 9 VALUE 1.
77 ptr3 PIC 9 VALUE 1.
77 ptr4 PIC 9 VALUE 1.
77 cijferplaats PIC 99 VALUE 1.
77 weight PIC 99 VALUE 10.
77 factor PIC 99.
77 endresult PIC 999 VALUE ALL ZEROES.
77 quotient PIC 99.
77 remains PIC 99.
77 digit PIC 99.
77 huidigjaar PIC 9999.
77 datchk PIC 9 VALUE 0.
77 classchk PIC 9 VALUE 0.
77 nogeen PIC X.
77 keyok PIC 9 VALUE 0.
PROCEDURE DIVISION.
000-Start.
INITIALIZE nieuwrecnr
INITIALIZE eof
OPEN I-O BOEK-FILE
PERFORM WITH TEST AFTER UNTIL eof = 1
READ BOEK-FILE NEXT AT END MOVE 1 TO eof
END-READ
COMPUTE nieuwrecnr = nieuwrecnr + 1
END-PERFORM
DISPLAY nieuwrecnr
CLOSE BOEK-FILE
PERFORM 100-OPKEUZE
STOP RUN
.
100-OPKEUZE.
INITIALIZE keuze
INITIALIZE isbnchk
INITIALIZE WS-BK-RECORD
DISPLAY AT 0101 SPACES
DISPLAY AT 0101 "1. Invoeren record"
DISPLAY AT 0201 "2. Wijzigen record"
DISPLAY AT 0301 "3. Verwijderen record"
DISPLAY AT 0501 "Welke operatie?(1-3)"
DISPLAY AT 1001 "9 sluiten"
PERFORM WITH TEST BEFORE UNTIL keuze-geldig
ACCEPT keuze AT 0521 WITH AUTO
EVALUATE keuze
WHEN 1 PERFORM 1000-INVOEREN
WHEN 2 PERFORM 2000-WIJZIGEN
WHEN 3 PERFORM 3000-VERWIJDEREN
WHEN 9 STOP RUN
END-EVALUATE
END-PERFORM
.
1000-INVOEREN.
INITIALIZE isbnchk, datchk, classchk
DISPLAY AT 0101 SPACES
EVALUATE keuze
WHEN 1 DISPLAY AT 0101
"VUL DE GEGEVENS VAN IN TE VOEREN BOEK IN: "
DISPLAY AT 0201
"------------------------------------------"
INITIALIZE WS-BK-RECORD
WHEN 2 DISPLAY AT 0101
"VUL DE TE WIJZIGEN GEGEVENS IN: "
DISPLAY AT 0201
"--------------------------------"
* WHEN 3 DISPLAY AT 0101
* "GEEF DE GEGEVENS VOOR TE VERWIJDEREN RECORD: "
* DISPLAY AT 0201
* "---------------------------------------------"
END-EVALUATE
DISPLAY AT 0401 "Titel: "
ACCEPT WS-BK-TITEL AT 0408 WITH REQUIRED
DISPLAY AT 0501 "Auteur: Achternaam: "
ACCEPT WS-BK-AUTEUR-AN AT 0521
DISPLAY AT 0545 "Voornaam: "
ACCEPT WS-BK-AUTEUR-VN AT 0555
DISPLAY AT 0601 "ISBN: "
PERFORM UNTIL isbnchk = 1
ACCEPT WS-BK-ISBN AT 0607 WITH REQUIRED FULL
DISPLAY AT 0621 SPACES
PERFORM 5000-ISBN-CONTROLE
END-PERFORM
DISPLAY AT 0701 "Uitgeverij: "
ACCEPT WS-BK-UITGEVERIJ AT 0713
DISPLAY AT 0801 "Jaar van uitgifte: "
PERFORM UNTIL datchk = 1
ACCEPT WS-BK-UITGIFTE-JAAR AT 0820
DISPLAY AT 0825 SPACES
PERFORM 5100-JAAR-CONTROLE
END-PERFORM
DISPLAY AT 0901 "Classificatie-code: "
PERFORM 5200-CLASSIFICATIE-ACCEPT
DISPLAY AT 1101 "Aantal pagina's: "
ACCEPT WS-BK-AANT-PAG AT 1118 WITH REQUIRED
INITIALIZE nogeen
EVALUATE keuze
WHEN 1 PERFORM 6000-WRITEAWAY
DISPLAY AT 2501 "Nog een record invoeren? (J/N)"
ACCEPT nogeen AT 2532 WITH AUTO REQUIRED
IF nogeen = "j" OR "J" THEN
INITIALIZE WS-BK-RECORD
PERFORM 1000-INVOEREN
ELSE PERFORM 100-OPKEUZE
END-IF
WHEN 2 PERFORM 7000-REWRITEAWAY
DISPLAY AT 2501 "Nog een record wijzigen? (J/N)"
ACCEPT nogeen AT 2532 WITH AUTO REQUIRED
IF nogeen = "j" OR "J" THEN
INITIALIZE WS-BK-RECORD
PERFORM 2000-WIJZIGEN
ELSE PERFORM 100-OPKEUZE
END-IF
END-EVALUATE
.
2000-WIJZIGEN.
DISPLAY AT 1010 "WE GAAN WIJZIGEN"
INITIALIZE BK-KEY
DISPLAY AT 0101 "Geef te wijzigen boeknummer: "
DISPLAY AT 0201 "Geef te wijzigen ISBN-nummer: "
DISPLAY AT 0301 "Geef te wijzigen titel: "
OPEN I-O BOEK-FILE
PERFORM UNTIL keyok=1
* ACCEPT WS-BK-KEY AT 0132 WITH PROMPT FULL
ACCEPT BK-KEY AT 0132 WITH PROMPT FULL
* MOVE WS-BK-KEY TO BK-KEY
IF BK-KEY NOT=" " THEN
READ BOEK-FILE RECORD INTO WS-BK-RECORD
INVALID KEY DISPLAY AT 0139 "Boeknummer onbekend"
MOVE 0 TO keyok
NOT INVALID KEY MOVE 1 TO keyok
PERFORM 1000-INVOEREN
END-READ
ELSE ACCEPT BK-ISBN AT 0231 WITH FULL
IF BK-ISBN NOT=" " THEN
READ BOEK-FILE INTO WS-BK-RECORD KEY IS BK-ISBN
INVALID KEY DISPLAY AT 0245 "ISBN-nummer onbekend"
MOVE 0 TO keyok
NOT INVALID KEY MOVE 1 TO keyok
PERFORM 1000-INVOEREN
END-READ
ELSE ACCEPT BK-TITEL AT 0325
IF BK-TITEL NOT=" " THEN
READ BOEK-FILE INTO WS-BK-RECORD KEY IS BK-TITEL
INVALID KEY DISPLAY AT 0357 "Boektitel onbekend"
MOVE 0 TO keyok
NOT INVALID KEY MOVE 1 TO keyok
PERFORM 1000-INVOEREN
END-READ
ELSE DISPLAY AT 1001 "Wilt u dit menu verlaten?(j/n)"
INITIALIZE nogeen
ACCEPT nogeen AT 1032
INITIALIZE BK-KEY BK-ISBN BK-TITEL
IF nogeen="J" OR "j" THEN MOVE 0 TO keyok
ELSE PERFORM 100-OPKEUZE
END-IF
END-IF
* REWRITE BOEK-FILE KEY = BK-KEY INVALID KEY DISPLAY AT
* 0139
* "Boeknummer onbekend"
CLOSE BOEK-FILE
.
3000-VERWIJDEREN.
DISPLAY AT 1010 "WE GAAN VERWIJDEREN".
5000-ISBN-CONTROLE.
INITIALIZE ISBNNUMBERS
INITIALIZE counter
INITIALIZE ptr1, ptr2, ptr3, ptr4
INITIALIZE groupid, pub, titleid, chk
INSPECT WS-BK-ISBN REPLACING ALL SPACES BY "-"
INSPECT WS-BK-ISBN TALLYING counter FOR ALL "-"
UNSTRING WS-BK-ISBN DELIMITED BY "-"
INTO groupid COUNT IN ptr1 pub COUNT IN ptr2 titleid
COUNT IN ptr3 chk COUNT IN ptr4
IF counter NOT=3 OR ptr1 > 5 OR ptr2 > 7 OR
ptr3 > 6 OR ptr4 > 1 THEN MOVE 0 TO isbnchk
DISPLAY AT 0621 "ONGELDIG ISBN-NUMMER"
ELSE PERFORM 5050-ISBNDIGITCHK
END-IF
.
5050-ISBNDIGITCHK.
MOVE WS-BK-ISBN TO ISBNNUMBERS
MOVE 10 TO weight
INITIALIZE ISBNRESULT
PERFORM 5080-CALCULUS WITH TEST AFTER
VARYING cijferplaats FROM 1 BY 1 UNTIL cijferplaats = 12
PERFORM 5090-ISBNRESULTING
.
5080-CALCULUS.
IF CYPHER(cijferplaats) IS NUMERIC
THEN COMPUTE RESULT(weight) =
CYPHER(cijferplaats)*weight
SUBTRACT 1 FROM weight
END-IF
.
5090-ISBNRESULTING.
MOVE 10 TO factor
INITIALIZE endresult
PERFORM WITH TEST BEFORE UNTIL factor = 1
COMPUTE endresult = endresult + RESULT(factor)
COMPUTE factor = factor - 1
END-PERFORM
IF CYPHLET = "X" OR "x" THEN MOVE 10 TO digit
ELSE MOVE CYPHLET TO digit
END-IF
ADD digit TO endresult
DIVIDE endresult BY 11 GIVING quotient REMAINDER remains
IF remains = 0 THEN MOVE 1 TO isbnchk
ELSE MOVE 0 TO isbnchk
DISPLAY AT 0627 "ISBN-CONTROLE KLOPT NIET"
END-IF
.
5100-JAAR-CONTROLE.
ACCEPT datum FROM DATE
STRING "20" jaar DELIMITED BY SIZE INTO huidigjaar
IF huidigjaar - WS-BK-UITGIFTE-JAAR < 0
THEN DISPLAY AT 0825 "Ongeldig jaartal"
MOVE 0 TO datchk
ELSE MOVE 1 TO datchk
.
5200-CLASSIFICATIE-ACCEPT.
ACCEPT WS-CL-CODE AT 0921
OPEN INPUT CLASSIFICATIE-FILE
IF WS-CL-CODE NOT=" " THEN
PERFORM 5250-CLASSIFICATIE-CONTROLE UNTIL classchk=1
END-IF
.
5250-CLASSIFICATIE-CONTROLE.
READ CLASSIFICATIE-FILE NEXT RECORD
AT END DISPLAY AT 0926 "ONBESTAANDE CODE"
CLOSE CLASSIFICATIE-FILE
PERFORM 5200-CLASSIFICATIE-ACCEPT
NOT AT END
IF WS-CL-CODE = CL-CODE
THEN MOVE WS-CL-CODE TO WS-BK-CLASSIF
THEN DISPLAY AT 0926 SPACES
DISPLAY AT 1001 "Classificatiethema:"CL-DETAIL
MOVE 1 TO classchk
CLOSE CLASSIFICATIE-FILE
END-IF
END-READ
.
6000-WRITEAWAY.
MOVE nieuwrecnr TO WS-BK-KEY
MOVE WS-BK-RECORD TO BK-RECORD
* WRITE BK-RECORD FROM WS-BK-RECORD
OPEN EXTEND BOEK-FILE
WRITE BK-RECORD FROM WS-BK-RECORD
END-WRITE
ADD 1 TO nieuwrecnr
CLOSE BOEK-FILE
.
7000-REWRITEAWAY.
OPEN I-O BOEK-FILE
REWRITE BK-RECORD FROM WS-BK-RECORD
END-REWRITE
CLOSE BOEK-FILE
.
The goal of this program is a normal insert of records in a indexed file using keys. The operation "1.Invoeren" is responsible for this (2. : edit 3.: delete record from file).
Choosing 1 in the main menu will allow the user to insert a record in this file "s2svhbk2.isq".
After filling in all the fields, the program is supposed to write away this record during the 6000-WRITEAWAY-procedure. And here is my problem that I don't understand : all the record information is moved into BK-RECORD without problem. Then I OPEN EXTEND the file in the hope that when I WRITE on it, it will automatically write/add the held record at the end of the file (right..?). But that doesn't happen... what does happen is that the first record will be written no problem. the second as well, but when I'm ready to write the third record, it will NOT add itself after the second record on the file, but simply overwrite the second record...so instead of getting record numbers 000001 000002 000003...I will get 000001 000003...while I'm positive that 000002 had been written correctly in the previous loop..so I don't know if this has to do with the inability of XP to accept OPEN EXTEND commands on indexed cobol files or any of the sort. I really have no idea how to approach this matter. Or am I completely wrong in the use of the OPEN EXTEND..?
Already in advance any help is greatly appreciated!!!
Have a nice day also!
I'm a starter in cobol-programming but I do feel something is weird about this problem.
Please forgive me for the lenghty program as I don't know how to show you otherwise my problem with it...
I'm working on an Athlon with XP as OS and I'm using the Microfocus compiler with that.
Usually I'm starting it up using the workbench (WB.EXE).
This time however, for some reason it seems to me as if XP is not letting me work with Indexed Files under cobol. This is the first time I have to work with these kind of files and while compiling the cobol-editor window will crash and close on me giving me an error message in windows, something like "could not find requested COM1-port. closing program" As far as I know I never asked for any COM-port...only to OPEN an indexed file with OPEN I-O... Some people I've talked to so far are telling me that "cobol don't match with XP"...but that's not a good enough answer for me, they never tell me why or what I should do or when exactly there are problems with it, or what guarantee I have that it will work if I would use Win9X (which I really would like to prevent..).
I found a way to (temporarily?) circumvent this annoyance by running the Microfocus-editor not using the Workbench but directly using the EDITOR.EXE. For some weird reason I could start programming and compiling and even running my growing program this way, even using OPEN I-O commands...
I'm saying this because maybe all this has something to do with my real problem now :
I will copy the whole program here as is...I hope someone has the time to check it out...of course I'll reward you for your time.
IDENTIFICATION DIVISION.
PROGRAM-ID. Boek-File-Operations.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. PC.
OBJECT-COMPUTER. PC.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT BOEK-FILE ASSIGN TO "s2svhbk.isq"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS BK-KEY
ALTERNATE KEY IS BK-ISBN
ALTERNATE KEY IS BK-TITEL.
SELECT CLASSIFICATIE-FILE ASSIGN TO "classif.isq"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD BOEK-FILE.
01 BK-RECORD.
05 BK-KEY PIC X(06).
05 BK-TITEL PIC X(30).
05 BK-AUTEUR.
10 BK-AUTEUR-AN PIC X(20).
10 BK-AUTEUR-VN PIC X(20).
05 BK-ISBN PIC X(13).
05 BK-UITGEVERIJ PIC X(20).
05 BK-UITGIFTE-JAAR PIC 9(04).
05 BK-CLASSIF PIC X(04).
05 BK-AANT-PAG PIC 9(04).
FD CLASSIFICATIE-FILE.
01 CLASSIF-RECORD.
05 CL-CODE PIC X(04).
05 CL-DETAIL PIC X(50).
WORKING-STORAGE SECTION.
01 WS-BK-RECORD.
05 WS-BK-KEY PIC X(06).
05 WS-BK-TITEL PIC X(30).
05 WS-BK-AUTEUR.
10 WS-BK-AUTEUR-AN PIC X(20).
10 WS-BK-AUTEUR-VN PIC X(20).
05 WS-BK-ISBN PIC X(13).
05 WS-BK-UITGEVERIJ PIC X(20).
05 WS-BK-UITGIFTE-JAAR PIC 9(04).
05 WS-BK-CLASSIF PIC X(04).
05 WS-BK-AANT-PAG PIC zzz9.
01 WS-CLASSIF-RECORD.
05 WS-CL-CODE PIC X(04).
05 WS-CL-DETAIL PIC X(50).
01 ISBNNUMBERS.
05 CYPHER PIC 9 OCCURS 12 VALUE ALL ZEROES.
05 CYPHLET PIC X VALUE ALL ZEROES.
01 ISBNRESULT.
05 RESULT PIC 99 OCCURS 10 VALUE ALL ZEROES.
01 DATUM.
05 jaar PIC 99.
05 maand PIC 99.
05 dag PIC 99.
77 keuze PIC 9 VALUE 0.
88 keuze-geldig VALUE 1 THROUGH 3.
77 nieuwrecnr PIC 9(06) VALUE 0.
77 eof PIC 9 VALUE 0.
77 groupid PIC 9(05).
77 pub PIC 9(07).
77 titleid PIC 9(06).
77 chk PIC 9(01).
77 isbnchk PIC 9 VALUE 0.
77 counter PIC 9(02) VALUE 1.
77 ptr1 PIC 9 VALUE 1.
77 ptr2 PIC 9 VALUE 1.
77 ptr3 PIC 9 VALUE 1.
77 ptr4 PIC 9 VALUE 1.
77 cijferplaats PIC 99 VALUE 1.
77 weight PIC 99 VALUE 10.
77 factor PIC 99.
77 endresult PIC 999 VALUE ALL ZEROES.
77 quotient PIC 99.
77 remains PIC 99.
77 digit PIC 99.
77 huidigjaar PIC 9999.
77 datchk PIC 9 VALUE 0.
77 classchk PIC 9 VALUE 0.
77 nogeen PIC X.
77 keyok PIC 9 VALUE 0.
PROCEDURE DIVISION.
000-Start.
INITIALIZE nieuwrecnr
INITIALIZE eof
OPEN I-O BOEK-FILE
PERFORM WITH TEST AFTER UNTIL eof = 1
READ BOEK-FILE NEXT AT END MOVE 1 TO eof
END-READ
COMPUTE nieuwrecnr = nieuwrecnr + 1
END-PERFORM
DISPLAY nieuwrecnr
CLOSE BOEK-FILE
PERFORM 100-OPKEUZE
STOP RUN
.
100-OPKEUZE.
INITIALIZE keuze
INITIALIZE isbnchk
INITIALIZE WS-BK-RECORD
DISPLAY AT 0101 SPACES
DISPLAY AT 0101 "1. Invoeren record"
DISPLAY AT 0201 "2. Wijzigen record"
DISPLAY AT 0301 "3. Verwijderen record"
DISPLAY AT 0501 "Welke operatie?(1-3)"
DISPLAY AT 1001 "9 sluiten"
PERFORM WITH TEST BEFORE UNTIL keuze-geldig
ACCEPT keuze AT 0521 WITH AUTO
EVALUATE keuze
WHEN 1 PERFORM 1000-INVOEREN
WHEN 2 PERFORM 2000-WIJZIGEN
WHEN 3 PERFORM 3000-VERWIJDEREN
WHEN 9 STOP RUN
END-EVALUATE
END-PERFORM
.
1000-INVOEREN.
INITIALIZE isbnchk, datchk, classchk
DISPLAY AT 0101 SPACES
EVALUATE keuze
WHEN 1 DISPLAY AT 0101
"VUL DE GEGEVENS VAN IN TE VOEREN BOEK IN: "
DISPLAY AT 0201
"------------------------------------------"
INITIALIZE WS-BK-RECORD
WHEN 2 DISPLAY AT 0101
"VUL DE TE WIJZIGEN GEGEVENS IN: "
DISPLAY AT 0201
"--------------------------------"
* WHEN 3 DISPLAY AT 0101
* "GEEF DE GEGEVENS VOOR TE VERWIJDEREN RECORD: "
* DISPLAY AT 0201
* "---------------------------------------------"
END-EVALUATE
DISPLAY AT 0401 "Titel: "
ACCEPT WS-BK-TITEL AT 0408 WITH REQUIRED
DISPLAY AT 0501 "Auteur: Achternaam: "
ACCEPT WS-BK-AUTEUR-AN AT 0521
DISPLAY AT 0545 "Voornaam: "
ACCEPT WS-BK-AUTEUR-VN AT 0555
DISPLAY AT 0601 "ISBN: "
PERFORM UNTIL isbnchk = 1
ACCEPT WS-BK-ISBN AT 0607 WITH REQUIRED FULL
DISPLAY AT 0621 SPACES
PERFORM 5000-ISBN-CONTROLE
END-PERFORM
DISPLAY AT 0701 "Uitgeverij: "
ACCEPT WS-BK-UITGEVERIJ AT 0713
DISPLAY AT 0801 "Jaar van uitgifte: "
PERFORM UNTIL datchk = 1
ACCEPT WS-BK-UITGIFTE-JAAR AT 0820
DISPLAY AT 0825 SPACES
PERFORM 5100-JAAR-CONTROLE
END-PERFORM
DISPLAY AT 0901 "Classificatie-code: "
PERFORM 5200-CLASSIFICATIE-ACCEPT
DISPLAY AT 1101 "Aantal pagina's: "
ACCEPT WS-BK-AANT-PAG AT 1118 WITH REQUIRED
INITIALIZE nogeen
EVALUATE keuze
WHEN 1 PERFORM 6000-WRITEAWAY
DISPLAY AT 2501 "Nog een record invoeren? (J/N)"
ACCEPT nogeen AT 2532 WITH AUTO REQUIRED
IF nogeen = "j" OR "J" THEN
INITIALIZE WS-BK-RECORD
PERFORM 1000-INVOEREN
ELSE PERFORM 100-OPKEUZE
END-IF
WHEN 2 PERFORM 7000-REWRITEAWAY
DISPLAY AT 2501 "Nog een record wijzigen? (J/N)"
ACCEPT nogeen AT 2532 WITH AUTO REQUIRED
IF nogeen = "j" OR "J" THEN
INITIALIZE WS-BK-RECORD
PERFORM 2000-WIJZIGEN
ELSE PERFORM 100-OPKEUZE
END-IF
END-EVALUATE
.
2000-WIJZIGEN.
DISPLAY AT 1010 "WE GAAN WIJZIGEN"
INITIALIZE BK-KEY
DISPLAY AT 0101 "Geef te wijzigen boeknummer: "
DISPLAY AT 0201 "Geef te wijzigen ISBN-nummer: "
DISPLAY AT 0301 "Geef te wijzigen titel: "
OPEN I-O BOEK-FILE
PERFORM UNTIL keyok=1
* ACCEPT WS-BK-KEY AT 0132 WITH PROMPT FULL
ACCEPT BK-KEY AT 0132 WITH PROMPT FULL
* MOVE WS-BK-KEY TO BK-KEY
IF BK-KEY NOT=" " THEN
READ BOEK-FILE RECORD INTO WS-BK-RECORD
INVALID KEY DISPLAY AT 0139 "Boeknummer onbekend"
MOVE 0 TO keyok
NOT INVALID KEY MOVE 1 TO keyok
PERFORM 1000-INVOEREN
END-READ
ELSE ACCEPT BK-ISBN AT 0231 WITH FULL
IF BK-ISBN NOT=" " THEN
READ BOEK-FILE INTO WS-BK-RECORD KEY IS BK-ISBN
INVALID KEY DISPLAY AT 0245 "ISBN-nummer onbekend"
MOVE 0 TO keyok
NOT INVALID KEY MOVE 1 TO keyok
PERFORM 1000-INVOEREN
END-READ
ELSE ACCEPT BK-TITEL AT 0325
IF BK-TITEL NOT=" " THEN
READ BOEK-FILE INTO WS-BK-RECORD KEY IS BK-TITEL
INVALID KEY DISPLAY AT 0357 "Boektitel onbekend"
MOVE 0 TO keyok
NOT INVALID KEY MOVE 1 TO keyok
PERFORM 1000-INVOEREN
END-READ
ELSE DISPLAY AT 1001 "Wilt u dit menu verlaten?(j/n)"
INITIALIZE nogeen
ACCEPT nogeen AT 1032
INITIALIZE BK-KEY BK-ISBN BK-TITEL
IF nogeen="J" OR "j" THEN MOVE 0 TO keyok
ELSE PERFORM 100-OPKEUZE
END-IF
END-IF
* REWRITE BOEK-FILE KEY = BK-KEY INVALID KEY DISPLAY AT
* 0139
* "Boeknummer onbekend"
CLOSE BOEK-FILE
.
3000-VERWIJDEREN.
DISPLAY AT 1010 "WE GAAN VERWIJDEREN".
5000-ISBN-CONTROLE.
INITIALIZE ISBNNUMBERS
INITIALIZE counter
INITIALIZE ptr1, ptr2, ptr3, ptr4
INITIALIZE groupid, pub, titleid, chk
INSPECT WS-BK-ISBN REPLACING ALL SPACES BY "-"
INSPECT WS-BK-ISBN TALLYING counter FOR ALL "-"
UNSTRING WS-BK-ISBN DELIMITED BY "-"
INTO groupid COUNT IN ptr1 pub COUNT IN ptr2 titleid
COUNT IN ptr3 chk COUNT IN ptr4
IF counter NOT=3 OR ptr1 > 5 OR ptr2 > 7 OR
ptr3 > 6 OR ptr4 > 1 THEN MOVE 0 TO isbnchk
DISPLAY AT 0621 "ONGELDIG ISBN-NUMMER"
ELSE PERFORM 5050-ISBNDIGITCHK
END-IF
.
5050-ISBNDIGITCHK.
MOVE WS-BK-ISBN TO ISBNNUMBERS
MOVE 10 TO weight
INITIALIZE ISBNRESULT
PERFORM 5080-CALCULUS WITH TEST AFTER
VARYING cijferplaats FROM 1 BY 1 UNTIL cijferplaats = 12
PERFORM 5090-ISBNRESULTING
.
5080-CALCULUS.
IF CYPHER(cijferplaats) IS NUMERIC
THEN COMPUTE RESULT(weight) =
CYPHER(cijferplaats)*weight
SUBTRACT 1 FROM weight
END-IF
.
5090-ISBNRESULTING.
MOVE 10 TO factor
INITIALIZE endresult
PERFORM WITH TEST BEFORE UNTIL factor = 1
COMPUTE endresult = endresult + RESULT(factor)
COMPUTE factor = factor - 1
END-PERFORM
IF CYPHLET = "X" OR "x" THEN MOVE 10 TO digit
ELSE MOVE CYPHLET TO digit
END-IF
ADD digit TO endresult
DIVIDE endresult BY 11 GIVING quotient REMAINDER remains
IF remains = 0 THEN MOVE 1 TO isbnchk
ELSE MOVE 0 TO isbnchk
DISPLAY AT 0627 "ISBN-CONTROLE KLOPT NIET"
END-IF
.
5100-JAAR-CONTROLE.
ACCEPT datum FROM DATE
STRING "20" jaar DELIMITED BY SIZE INTO huidigjaar
IF huidigjaar - WS-BK-UITGIFTE-JAAR < 0
THEN DISPLAY AT 0825 "Ongeldig jaartal"
MOVE 0 TO datchk
ELSE MOVE 1 TO datchk
.
5200-CLASSIFICATIE-ACCEPT.
ACCEPT WS-CL-CODE AT 0921
OPEN INPUT CLASSIFICATIE-FILE
IF WS-CL-CODE NOT=" " THEN
PERFORM 5250-CLASSIFICATIE-CONTROLE UNTIL classchk=1
END-IF
.
5250-CLASSIFICATIE-CONTROLE.
READ CLASSIFICATIE-FILE NEXT RECORD
AT END DISPLAY AT 0926 "ONBESTAANDE CODE"
CLOSE CLASSIFICATIE-FILE
PERFORM 5200-CLASSIFICATIE-ACCEPT
NOT AT END
IF WS-CL-CODE = CL-CODE
THEN MOVE WS-CL-CODE TO WS-BK-CLASSIF
THEN DISPLAY AT 0926 SPACES
DISPLAY AT 1001 "Classificatiethema:"CL-DETAIL
MOVE 1 TO classchk
CLOSE CLASSIFICATIE-FILE
END-IF
END-READ
.
6000-WRITEAWAY.
MOVE nieuwrecnr TO WS-BK-KEY
MOVE WS-BK-RECORD TO BK-RECORD
* WRITE BK-RECORD FROM WS-BK-RECORD
OPEN EXTEND BOEK-FILE
WRITE BK-RECORD FROM WS-BK-RECORD
END-WRITE
ADD 1 TO nieuwrecnr
CLOSE BOEK-FILE
.
7000-REWRITEAWAY.
OPEN I-O BOEK-FILE
REWRITE BK-RECORD FROM WS-BK-RECORD
END-REWRITE
CLOSE BOEK-FILE
.
The goal of this program is a normal insert of records in a indexed file using keys. The operation "1.Invoeren" is responsible for this (2. : edit 3.: delete record from file).
Choosing 1 in the main menu will allow the user to insert a record in this file "s2svhbk2.isq".
After filling in all the fields, the program is supposed to write away this record during the 6000-WRITEAWAY-procedure. And here is my problem that I don't understand : all the record information is moved into BK-RECORD without problem. Then I OPEN EXTEND the file in the hope that when I WRITE on it, it will automatically write/add the held record at the end of the file (right..?). But that doesn't happen... what does happen is that the first record will be written no problem. the second as well, but when I'm ready to write the third record, it will NOT add itself after the second record on the file, but simply overwrite the second record...so instead of getting record numbers 000001 000002 000003...I will get 000001 000003...while I'm positive that 000002 had been written correctly in the previous loop..so I don't know if this has to do with the inability of XP to accept OPEN EXTEND commands on indexed cobol files or any of the sort. I really have no idea how to approach this matter. Or am I completely wrong in the use of the OPEN EXTEND..?
Already in advance any help is greatly appreciated!!!
Have a nice day also!