COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID. BLNCLN.
*
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES. DECIMAL-POINT IS COMMA.
*
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CADASTRO ASSIGN TO CADASTRO FILE STATUS IS WS-STATUS1.
SELECT ATUALIZA ASSIGN TO ATUALIZA FILE STATUS IS WS-STATUS2.
SELECT CADFINAL ASSIGN TO CADFINAL FILE STATUS IS WS-STATUS3.
*
*
DATA DIVISION.
*
FILE SECTION.
FD CADASTRO
RECORDING MODE IS F
RECORD CONTAINS 300 CHARACTERS.
01 REG-CADASTRO PIC X(300).
*
FD ATUALIZA
RECORDING MODE IS F
BLOCK CONTAINS 200 CHARACTERS.
01 REG-ATUALIZA PIC X(200).
*
FD CADFINAL
RECORDING MODE IS F
BLOCK CONTAINS 300 CHARACTERS.
01 REG-CADFINAL PIC X(300).
*
WORKING-STORAGE SECTION.
*
01 WS-STATUS1 PIC X(02).
01 WS-STATUS2 PIC X(02).
01 WS-STATUS3 PIC X(02).
01 WS-FLAG PIC X(03) VALUE 'NAO'.
01 WS-CADASTRO.
10 CD-CODE.
15 CD-EMP-CODE PIC 9(11).
10 CD-DATA-INI PIC 9(08).
10 CD-DATA-FIM PIC 9(08).
10 CD-PLANO-DSCT PIC 9(09).
10 CD-PLANO-CNSM PIC 9(09).
10 CD-PLANO-TRFS PIC 9(09).
10 CD-EMP-NOME PIC X(40).
10 CD-EMP-END PIC X(60).
10 CD-EMP-CEP PIC 9(08).
10 CD-EMP-CITY PIC X(20).
10 CD-EMP-UF PIC X(02).
10 FILLER PIC X(116).
*
01 WS-ATUALIZA.
10 AT-FLAG PIC X(01).
10 AT-EMP-CODE PIC X(11).
10 AT-EMP-NOME PIC X(40).
10 AT-EMP-END PIC X(60).
10 AT-EMP-CEP PIC 9(08).
10 AT-EMP-CITY PIC X(20).
10 AT-EMP-UF PIC X(02).
10 FILLER PIC X(58).
*
01 AUX-CADASTRO.
10 AX-EMP-CODE PIC 9(11).
10 AX-DATA-INI PIC 9(08).
10 AX-DATA-FIM PIC 9(08).
10 AX-PLANO-DSCT PIC 9(09).
10 AX-PLANO-CNSM PIC 9(09).
10 AX-PLANO-TRFS PIC 9(09).
10 AX-EMP-NOME PIC X(40).
10 AX-EMP-END PIC X(60).
10 AX-EMP-CEP PIC 9(08).
10 AX-EMP-CITY PIC X(20).
10 AX-EMP-UF PIC X(02).
*
01 AX-DATA-EDIT.
10 AX-ANO PIC 9(4).
10 AX-MES PIC 9(2).
10 AX-DIA PIC 9(2).
*
01 AX-DATA-OK.
10 AX-DIA-OK PIC 9(2).
10 AX-MES-OK PIC 9(2).
10 AX-ANO-OK PIC 9(4).
*
PROCEDURE DIVISION.
*
0000-MAIN.
PERFORM 1000-OPEN
PERFORM 2000-ROTINA
PERFORM 4000-CLOSE
STOP RUN.
1000-OPEN.
OPEN INPUT CADASTRO
OPEN INPUT ATUALIZA
OPEN OUTPUT CADFINAL.
2000-ROTINA.
PERFORM 2500-READ
INITIALIZE AUX-CADASTRO
IF CD-EMP-CODE = 99999999999 AND AT-EMP-CODE = 99999999999
MOVE 'SIM' TO WS-FLAG
END-IF
PERFORM 3000-PERFORM UNTIL WS-FLAG = 'SIM'.
2500-READ.
PERFORM 2600-READ-CADASTRO
PERFORM 2800-READ-ATUALIZA.
2600-READ-CADASTRO.
READ CADASTRO INTO WS-CADASTRO.
2800-READ-ATUALIZA.
READ ATUALIZA INTO WS-ATUALIZA.
3000-PERFORM.
IF AT-EMP-CODE < CD-EMP-CODE
EVALUATE TRUE
WHEN AT-FLAG = 'A'
PERFORM 3100-WRITE-CADATT
PERFORM 2800-READ-ATUALIZA
WHEN AT-FLAG = 'D'
ACCEPT AX-DATA-EDIT FROM DATE
MOVE AX-DIA TO AX-DIA-OK
MOVE AX-MES TO AX-MES-OK
MOVE AX-ANO TO AX-ANO-OK
PERFORM 3200-WRITE-CADASTRO
PERFORM 2800-READ-ATUALIZA
WHEN AT-FLAG = 'I'
PERFORM 3300-WRITE-ATUALIZA
PERFORM 3200-WRITE-CADASTRO
PERFORM 2800-READ-ATUALIZA
END-EVALUATE
ELSE
IF AT-EMP-CODE = CD-EMP-CODE
PERFORM 3100-WRITE-CADATT
PERFORM 2600-READ-CADASTRO
PERFORM 2800-READ-ATUALIZA
ELSE
WRITE REG-CADFINAL FROM WS-CADASTRO
PERFORM 3300-WRITE-ATUALIZA
PERFORM 2600-READ-CADASTRO
END-IF
END-IF.
3100-WRITE-CADATT.
MOVE WS-CADASTRO TO AUX-CADASTRO
MOVE AT-EMP-CODE TO AX-EMP-CODE
MOVE AT-EMP-NOME TO AX-EMP-NOME
MOVE AT-EMP-END TO AX-EMP-END
MOVE AT-EMP-CEP TO AX-EMP-CEP
MOVE AT-EMP-CITY TO AX-EMP-CITY
MOVE AT-EMP-UF TO AX-EMP-UF
WRITE REG-CADFINAL FROM AUX-CADASTRO.
3200-WRITE-CADASTRO.
MOVE WS-CADASTRO TO AUX-CADASTRO
MOVE AX-DATA-OK TO AX-DATA-FIM
MOVE CD-EMP-CODE TO AX-EMP-CODE
MOVE CD-EMP-NOME TO AX-EMP-NOME
MOVE CD-EMP-END TO AX-EMP-END
MOVE CD-EMP-CEP TO AX-EMP-CEP
MOVE CD-EMP-CITY TO AX-EMP-CITY
MOVE CD-EMP-UF TO AX-EMP-UF
WRITE REG-CADFINAL FROM AUX-CADASTRO.
3300-WRITE-ATUALIZA.
MOVE WS-CADASTRO TO AUX-CADASTRO
MOVE AT-EMP-CODE TO AX-EMP-CODE
MOVE AT-EMP-NOME TO AX-EMP-NOME
MOVE AT-EMP-END TO AX-EMP-END
MOVE AT-EMP-CEP TO AX-EMP-CEP
MOVE AT-EMP-CITY TO AX-EMP-CITY
MOVE AT-EMP-UF TO AX-EMP-UF
WRITE REG-CADFINAL FROM AUX-CADASTRO.
4000-CLOSE.
CLOSE CADASTRO
CLOSE ATUALIZA
CLOSE CADFINAL.
PROGRAM-ID. BLNCLN.
*
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES. DECIMAL-POINT IS COMMA.
*
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CADASTRO ASSIGN TO CADASTRO FILE STATUS IS WS-STATUS1.
SELECT ATUALIZA ASSIGN TO ATUALIZA FILE STATUS IS WS-STATUS2.
SELECT CADFINAL ASSIGN TO CADFINAL FILE STATUS IS WS-STATUS3.
*
*
DATA DIVISION.
*
FILE SECTION.
FD CADASTRO
RECORDING MODE IS F
RECORD CONTAINS 300 CHARACTERS.
01 REG-CADASTRO PIC X(300).
*
FD ATUALIZA
RECORDING MODE IS F
BLOCK CONTAINS 200 CHARACTERS.
01 REG-ATUALIZA PIC X(200).
*
FD CADFINAL
RECORDING MODE IS F
BLOCK CONTAINS 300 CHARACTERS.
01 REG-CADFINAL PIC X(300).
*
WORKING-STORAGE SECTION.
*
01 WS-STATUS1 PIC X(02).
01 WS-STATUS2 PIC X(02).
01 WS-STATUS3 PIC X(02).
01 WS-FLAG PIC X(03) VALUE 'NAO'.
01 WS-CADASTRO.
10 CD-CODE.
15 CD-EMP-CODE PIC 9(11).
10 CD-DATA-INI PIC 9(08).
10 CD-DATA-FIM PIC 9(08).
10 CD-PLANO-DSCT PIC 9(09).
10 CD-PLANO-CNSM PIC 9(09).
10 CD-PLANO-TRFS PIC 9(09).
10 CD-EMP-NOME PIC X(40).
10 CD-EMP-END PIC X(60).
10 CD-EMP-CEP PIC 9(08).
10 CD-EMP-CITY PIC X(20).
10 CD-EMP-UF PIC X(02).
10 FILLER PIC X(116).
*
01 WS-ATUALIZA.
10 AT-FLAG PIC X(01).
10 AT-EMP-CODE PIC X(11).
10 AT-EMP-NOME PIC X(40).
10 AT-EMP-END PIC X(60).
10 AT-EMP-CEP PIC 9(08).
10 AT-EMP-CITY PIC X(20).
10 AT-EMP-UF PIC X(02).
10 FILLER PIC X(58).
*
01 AUX-CADASTRO.
10 AX-EMP-CODE PIC 9(11).
10 AX-DATA-INI PIC 9(08).
10 AX-DATA-FIM PIC 9(08).
10 AX-PLANO-DSCT PIC 9(09).
10 AX-PLANO-CNSM PIC 9(09).
10 AX-PLANO-TRFS PIC 9(09).
10 AX-EMP-NOME PIC X(40).
10 AX-EMP-END PIC X(60).
10 AX-EMP-CEP PIC 9(08).
10 AX-EMP-CITY PIC X(20).
10 AX-EMP-UF PIC X(02).
*
01 AX-DATA-EDIT.
10 AX-ANO PIC 9(4).
10 AX-MES PIC 9(2).
10 AX-DIA PIC 9(2).
*
01 AX-DATA-OK.
10 AX-DIA-OK PIC 9(2).
10 AX-MES-OK PIC 9(2).
10 AX-ANO-OK PIC 9(4).
*
PROCEDURE DIVISION.
*
0000-MAIN.
PERFORM 1000-OPEN
PERFORM 2000-ROTINA
PERFORM 4000-CLOSE
STOP RUN.
1000-OPEN.
OPEN INPUT CADASTRO
OPEN INPUT ATUALIZA
OPEN OUTPUT CADFINAL.
2000-ROTINA.
PERFORM 2500-READ
INITIALIZE AUX-CADASTRO
IF CD-EMP-CODE = 99999999999 AND AT-EMP-CODE = 99999999999
MOVE 'SIM' TO WS-FLAG
END-IF
PERFORM 3000-PERFORM UNTIL WS-FLAG = 'SIM'.
2500-READ.
PERFORM 2600-READ-CADASTRO
PERFORM 2800-READ-ATUALIZA.
2600-READ-CADASTRO.
READ CADASTRO INTO WS-CADASTRO.
2800-READ-ATUALIZA.
READ ATUALIZA INTO WS-ATUALIZA.
3000-PERFORM.
IF AT-EMP-CODE < CD-EMP-CODE
EVALUATE TRUE
WHEN AT-FLAG = 'A'
PERFORM 3100-WRITE-CADATT
PERFORM 2800-READ-ATUALIZA
WHEN AT-FLAG = 'D'
ACCEPT AX-DATA-EDIT FROM DATE
MOVE AX-DIA TO AX-DIA-OK
MOVE AX-MES TO AX-MES-OK
MOVE AX-ANO TO AX-ANO-OK
PERFORM 3200-WRITE-CADASTRO
PERFORM 2800-READ-ATUALIZA
WHEN AT-FLAG = 'I'
PERFORM 3300-WRITE-ATUALIZA
PERFORM 3200-WRITE-CADASTRO
PERFORM 2800-READ-ATUALIZA
END-EVALUATE
ELSE
IF AT-EMP-CODE = CD-EMP-CODE
PERFORM 3100-WRITE-CADATT
PERFORM 2600-READ-CADASTRO
PERFORM 2800-READ-ATUALIZA
ELSE
WRITE REG-CADFINAL FROM WS-CADASTRO
PERFORM 3300-WRITE-ATUALIZA
PERFORM 2600-READ-CADASTRO
END-IF
END-IF.
3100-WRITE-CADATT.
MOVE WS-CADASTRO TO AUX-CADASTRO
MOVE AT-EMP-CODE TO AX-EMP-CODE
MOVE AT-EMP-NOME TO AX-EMP-NOME
MOVE AT-EMP-END TO AX-EMP-END
MOVE AT-EMP-CEP TO AX-EMP-CEP
MOVE AT-EMP-CITY TO AX-EMP-CITY
MOVE AT-EMP-UF TO AX-EMP-UF
WRITE REG-CADFINAL FROM AUX-CADASTRO.
3200-WRITE-CADASTRO.
MOVE WS-CADASTRO TO AUX-CADASTRO
MOVE AX-DATA-OK TO AX-DATA-FIM
MOVE CD-EMP-CODE TO AX-EMP-CODE
MOVE CD-EMP-NOME TO AX-EMP-NOME
MOVE CD-EMP-END TO AX-EMP-END
MOVE CD-EMP-CEP TO AX-EMP-CEP
MOVE CD-EMP-CITY TO AX-EMP-CITY
MOVE CD-EMP-UF TO AX-EMP-UF
WRITE REG-CADFINAL FROM AUX-CADASTRO.
3300-WRITE-ATUALIZA.
MOVE WS-CADASTRO TO AUX-CADASTRO
MOVE AT-EMP-CODE TO AX-EMP-CODE
MOVE AT-EMP-NOME TO AX-EMP-NOME
MOVE AT-EMP-END TO AX-EMP-END
MOVE AT-EMP-CEP TO AX-EMP-CEP
MOVE AT-EMP-CITY TO AX-EMP-CITY
MOVE AT-EMP-UF TO AX-EMP-UF
WRITE REG-CADFINAL FROM AUX-CADASTRO.
4000-CLOSE.
CLOSE CADASTRO
CLOSE ATUALIZA
CLOSE CADFINAL.
SYSOUT
CEE3201S The system detected an operation exception (System Completion Code=0C1)
From compile unit BLNCLN at entry point BLNCLN at compile unit offset -EE8FF0F0 at entry offset -EE8FF0F0 at address 00000048.
From compile unit BLNCLN at entry point BLNCLN at compile unit offset -EE8FF0F0 at entry offset -EE8FF0F0 at address 00000048.