thanks for the reply. Very much appreciate.
I tried to create another database so I don't change the original FD. However when I run it, it error out with a CODE 48.
FILE-CONTROL.
SELECT ADDFIELD ASSIGN TO DISK extrafield.dat
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
LOCK MODE IS MANUAL
STATUS IS FILE-LOCK
RECORD KEY IS XADDFLDKEY.
DATA DIVISION.
FILE SECTION.
FD ADDFIELD LABEL RECORDS ARE STANDARD.
01 XADDFREC.
05 XADDFLDKEY
10 XSSN PIC X(09).
05 XCITY PIC X(30)
05 XCOUNTRY PIC X(30)
05 FILLER PIC X(200)
Below is the PROCEDURE DIVISION.
NL-ADDFIELD.
OPEN OUTPUT ADDFIELD.
NL-ADD-START.
INITIALIZE XADDFREC.
MOVE SPACES TO WFLG.
MOVE WGEMPR TO XEMPR.
MOVE MSSN TO XSSN.
START ADDFIELD KEY = XADDFLDKEY INVALID KEY
PERFORM ACCEPT-ADDFIELD THRU NL-ADDFIELD-END
CLOSE ADDFIELD
GO TO NL-ADDFIELD-END.
ACCEPT-ADDFIELD.
DISPLAY SPACES UPON CRT LINE 4 POSITION 1.
DISPLAY "CITY...:" LINE 5 POSITION 1
WITH FOREGROUND-COLOR 11.
DISPLAY "COUNTRY" LINE 6 POSITION 1
WITH FOREGROUND-COLOR 11.
DISPLAY XCITY LINE 5 POSITION 30
WITH FOREGROUND-COLOR 11.
DISPLAY XCOUNTRY LINE 6 POSITION 30
WITH FOREGROUND-COLOR 11.
DISPLAY
"LETTER TO CORRECT * A:CITY, B:COUNTRY * (NL)-OUT"
LINE 24 POSITION 02
WITH FOREGROUND-COLOR 12.
MOVE SPACES TO WFLG.
ACCEPT WFLG LINE 24 POSITION 78 WITH PROMPT
FOREGROUND-COLOR 12.
IF WFLG = " " OR "O" OR "o"
GO TO AFT-RD.
IF WFLG = "A"
ACCEPT XCITY LINE 5 POSITION 30 WITH PROMPT
FOREGROUND-COLOR 12.
IF WFLG = "B"
ACCEPT XCOUNTRY LINE 6 POSITION 30 WITH PROMPT
FOREGROUND-COLOR 12.
MOVE SPACES TO WFLG.
DISPLAY "IS EVERYTHING CORRECT * (Y/N) * (O) - OUT"
LINE 21 POSITION 1
WITH FOREGROUND-COLOR 12.
ACCEPT WFLG LINE 21 POSITION 78 WITH PROMPT
FOREGROUND-COLOR 12.
IF WFLG EQUAL "O"
GO TO NL-ADDFIELD-END.
IF WFLG EQUAL "N"
GO TO ACCEPT-ADDFIELD.
IF WFLG NOT EQUAL "Y"
GO TO ACCEPT-ADDFIELD.
MOVE WGEMPR TO XEMPR.
MOVE MSSN TO XSSN.
WRITE XADDFREC.
CLOSE ADDFIELD.
IF FILE-LOCK EQUAL "00"
GO TO NL-ADDFIELD-END
ELSE
IF FILE-LOCK EQUAL "22"
NEXT SENTENCE
ELSE
DISPLAY " WRITE ERROR ON ADD FIELD"
LINE 18 POSITION 01
WITH FOREGROUND-COLOR 12
DISPLAY FILE-LOCK LINE 18 POSITION 25
WITH FOREGROUND-COLOR 12
ACCEPT WFLG LINE 18 POSITION 40 WITH PROMPT
FOREGROUND-COLOR 12.
NL-ADDFIELD-END.
I think I have to create extrafield.dat first or if I use the command "OPEN OUTPUT ADDFIELD"
it should create the file if it doesn't exsist?
So before doing it, do I need to do an OPEN OUTPUT and then put in another command OPEN I-O so that I can write to the file?