You are on page 1of 20

IDENTIFICATION DIVISION.

PROGRAM-ID. CST006.
AUTHOR. EU.
SECURITY. MONTAGEM DO CUSTO D PRODUTO.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. AT486.
OBJECT-COMPUTER. AT486.
SPECIAL-NAMES. DECIMAL-POINT IS COMMA.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
COPY "SEL\CSTCDMPR.SEL".
COPY "SEL\CSTCDFAT.SEL".
COPY "SEL\CSTCDMOB.SEL".
COPY "SEL\CSTCDCRE.SEL".
COPY "SEL\CSTCDPRD.SEL".
COPY "SEL\CSTCSPRD.SEL".
COPY "SEL\ACESSO.SEL".

DATA DIVISION.
FILE SECTION.
COPY "FDS\CSTCDMPR.FDS".
COPY "FDS\CSTCDFAT.FDS".
COPY "FDS\CSTCDMOB.FDS".
COPY "FDS\CSTCDCRE.FDS".
COPY "FDS\CSTCDPRD.FDS".
COPY "FDS\CSTCSPRD.FDS".

FD acesso.
01 reg-acs.
03 acs-filler PIC X.

WORKING-STORAGE SECTION.
01 prd-key.
05 prd-cdg-k PIC 9(05).
01 wst-prd-cdg PIC 9(05).
01 csp-key.
03 csp-prdcdg-k PIC 9(05).
03 csp-tipcst-k PIC 9(05).
03 csp-cdgcst-k PIC 9(05).

01 wst-variaveis-x.
03 wst-prd-nome PIC X(30).
01 wst-csp-prdcdg PIC 9(05).
01 wst-csp-qtd PIC ZZZ.ZZ9,999.
01 wst-percent PIC ZZ9,999.

01 fs PIC XX VALUE "00".


01 ws-gera PIC X(03) VALUE SPACES.
01 wst-confirma PIC X(03) VALUE SPACES.
01 ws-resp-sn PIC X(01) VALUE SPACES.
01 ws-senha-fim PIC X(10) VALUE SPACES.
01 wst-opcao PIC X(01) VALUE SPACES.
01 wst-escop PIC X(01) VALUE SPACES.
01 ws-existe PIC X(01) VALUE SPACES.
01 ws-opera PIC X(12) VALUE SPACES.
01 ws-escopo PIC X(17) VALUE SPACES.
01 ws-cont PIC 9(05) VALUE ZEROS.
01 wlncl.
03 wln PIC 99.
03 wcl PIC 99.
01 wlncl1.
03 wln1 PIC 99.
03 wcl1 PIC 99.

SCREEN SECTION.
COPY "SCR\CSTACES.SCR".
COPY "SCR\CST006A.SCR".
COPY "SCR\CST006B.SCR".
COPY "SCR\CST006C.SCR".
COPY "SCR\CST006D.SCR".
COPY "SCR\CST006E.SCR".

PROCEDURE DIVISION.
secao-01 SECTION.
pf-permissao.
OPEN INPUT acesso
IF fs = "35"
DISPLAY G-CSTACES
STOP " "
CHAIN "CST900".
*******pf-cria.
********** OPEN OUTPUT cstcsprd cstcdmpr cstcdmob cstcdprd
********** display fs
********** CLOSE cstcsprd cstcdmpr cstcdmob cstcdprd.

pf-abre.
OPEN INPUT CSTCDMPR
CSTCDFAT
CSTCDMOB
CSTCDCRE
CSTCDPRD.

pfmenu-A.
DISPLAY SPACES AT 0101
DISPLAY G-CST006A.
ACCEPT wst-opcao AT 1324
IF wst-opcao = "F" GO secao-fim.
IF wst-opcao NOT = "I" AND
wst-opcao NOT = "A" AND
wst-opcao NOT = "V" AND
wst-opcao NOT = "D" GO PFMENU-A.

IF wst-opcao = "I" MOVE "INCLUSAO " TO WS-OPERA.


IF wst-opcao = "A" MOVE "ALTERACAO " TO WS-OPERA.
IF wst-opcao = "D" MOVE "DELECAO " TO WS-OPERA.
IF wst-opcao = "V" MOVE "VISUALIZACAO" TO WS-OPERA.

pfmenu-B.
ACCEPT wst-escop AT 1362
IF wst-escop = "R" GO pfmenu-A.
IF wst-escop NOT = "M" AND
wst-escop NOT = "C" AND
wst-escop NOT = "O" AND
wst-escop NOT = "F" GO PFMENU-B.

IF wst-escop = "M" MOVE "MATERIA PRIMA " TO WS-ESCOPO.


IF wst-escop = "C" MOVE "CREDITOS " TO WS-ESCOPO.
IF wst-escop = "O" MOVE "MAO DE OBRA " TO WS-ESCOPO.
IF wst-escop = "F" MOVE "FATORES ACRESCIMO" TO WS-ESCOPO.

PF00.
OPEN I-O cstcsprd.

pf01.
DISPLAY SPACES AT 0101
IF wst-escop = "M" DISPLAY G-CST006B.
IF wst-escop = "F" DISPLAY G-CST006C.
IF wst-escop = "C" DISPLAY G-CST006D.
IF wst-escop = "O" DISPLAY G-CST006E.
DISPLAY WS-OPERA AT 0150
MOVE spaces TO reg-csp.
MOVE 00000 TO wst-csp-prdcdg
DISPLAY
"INFORME CODIGO DO PRODUTO OU 99999 PARA DESISTIR ... "
AT 2315
ACCEPT wst-csp-prdcdg AT 0215.
DISPLAY spaces AT 2301
IF wst-csp-prdcdg = ALL "9" CLOSE cstcsprd
GO pfmenu-a.

pf02.
MOVE wst-csp-prdcdg TO prd-cod
READ cstcdprd INVALID KEY DISPLAY
"Descricao de produto nao cadastrado c/este codigo!" AT 2301
STOP " "
GO pf01.
IF fs NOT = "00" DISPLAY
"E001 - cstcdprd TEMPORARIAMENTE BLOQUEADO ... " AT 2301
GO pf01.

DISPLAY prd-nome AT 0223.

IF wst-escop = "M" PERFORM SECAO-MAT-PRI.


IF wst-escop = "C" PERFORM SECAO-CREDITO.
IF wst-escop = "O" PERFORM SECAO-MAO-OBR.
IF wst-escop = "F" PERFORM SECAO-FAT-ACR.
GO pf01.

******************************************************************************
SECAO-MAT-PRI SECTION.
******************************************************************************
pf-mp000.
DISPLAY SPACES AT 0101
DISPLAY G-CST006B.
DISPLAY WS-OPERA AT 0150

DISPLAY wst-csp-prdcdg AT 0215.


DISPLAY prd-nome AT 0223.

MOVE ZEROS TO ws-cont


MOVE wst-csp-prdcdg TO csp-prdcdg
MOVE 1 TO csp-tipcst
MOVE 0 TO csp-cdgcst

START cstcsprd KEY IS >= csp-cod


INVALID KEY GO pf-mp-naoexiste.

pf-mp01A.
READ cstcsprd NEXT RECORD AT END GO pf-mp02A.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcsprd Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
MOVE csp-key TO csp-cod
START cstcsprd KEY IS >= csp-cod
GO TO pf-mp01A.

IF csp-tipcst NOT = 1 IF ws-cont = 0 GO pf-mp-naoexiste


ELSE GO pf-mp02A.

MOVE csp-cod TO csp-key.

ADD 1 TO ws-cont.

IF ws-cont = 1 PERFORM pf-mp-mostra-prod.

PERFORM pf-mp-lermpr.
COMPUTE wln = (ws-cont + 4)

IF wln = 73 OR wln = 56 OR wln = 39 OR wln = 22


DISPLAY "TECLE <ENTER> P/VER PROXIMOS ITENS ..." AT 2301
STOP " "
MOVE 4 TO wln1
PERFORM pf-mp-limpa THRU pf-mp-limpa-99.

IF wln > 72 COMPUTE wln = (wln - 68).


IF wln > 55 COMPUTE wln = (wln - 51).
IF wln > 38 COMPUTE wln = (wln - 34).
IF wln > 21 COMPUTE wln = (wln - 17).

MOVE 15 TO wcl
DISPLAY mpr-cdg AT wlncl.
MOVE 23 TO wcl
DISPLAY mpr-nome AT wlncl.
MOVE 56 TO wcl
MOVE csp-qtd TO wst-csp-qtd
DISPLAY wst-csp-qtd AT wlncl.
MOVE 70 TO wcl
DISPLAY mpr-unidade AT wlncl.
GO pf-mp01A.

pf-mp-limpa.
ADD 1 TO wln1
IF wln1 > 21 GO pf-mp-limpa-99.
MOVE 15 TO wcl1
DISPLAY
"_____ ______________________________ ___.___,___ ___"
AT wlncl1.
GO pf-mp-limpa.

pf-mp-limpa-99.
EXIT.

pf-mp-mostra-prod.
MOVE csp-prdcdg TO prd-cod
READ cstcdprd INVALID KEY DISPLAY spaces AT 2001
DISPLAY
"ERRO FATAL - DESCRICAO DE PRODUTO NAO CADASTRADA " AT 2001
DISPLAY
" ANOTE CODIGO : " AT 2101
DISPLAY csp-prdcdg AT 2130
DISPLAY
" E CADASTRE-O ! " AT 2140
GO SECAO-99.
DISPLAY prd-nome AT 0223.

pf-mp-lermpr.
MOVE csp-cdgcst TO mpr-cod
READ cstcdmpr INVALID KEY DISPLAY SPACES AT 2001
DISPLAY
"ERRO FATAL - PRODUTO COM MATERIA PRIMA INEXISTENTE " AT 2001
DISPLAY
" ANOTE CODIGO : " AT 2101
DISPLAY csp-cdgcst AT 2130
DISPLAY
" E CADASTRE-O ! " AT 2140
GO SECAO-99.

IF FS NOT = "00" DISPLAY


"cstcdmpr TEMPORARIAMENTE BLOQUEADO, AGUARDE ..." AT 2301
GO pf-mp-lermpr.

pf-mp02A.
MOVE 1 TO csp-tipcst.
IF wst-opcao = "I" OR
wst-opcao = "D" OR
wst-opcao = "A" GO pf-mp-acpt-01.

IF wst-opcao = "V" DISPLAY SPACES AT 2301


DISPLAY "TECLE <ENTER> " AT 2301
STOP " "
GO pf-mp999.

pf-mp-naoexiste.
MOVE 1 TO csp-tipcst.
IF wst-opcao NOT = "I" DISPLAY
"ERRO - MAT.PRIMA N/CADASTRADA P/ESTE PRODUTO TECLE <ENTER>"
AT 2301
STOP " "
GO pf-mp999.

pf-mp-acpt-01.
DISPLAY
"INFORME CODIGO DA MATERIA PRIMA OU 99999 PARA DESISTIR ! "
AT 2315
ACCEPT csp-cdgcst AT 0315.
DISPLAY spaces AT 2301
IF csp-cdgcst = ALL "9" GO pf-mp999.

PERFORM pf-ver-cstprd THRU pf-ver-cstprd-99.


IF ws-existe = "S" AND
wst-opcao = "I" DISPLAY
"ERRO - ESTA MATERIA PRIMA JA ESTA CADASTRADA, ALTERE ..."
AT 2301
STOP " " DISPLAY SPACES AT 2301
GO pf-mp-acpt-01.
IF ws-existe = "N" AND
wst-opcao NOT = "I" DISPLAY
"ERRO - MATERIA PRIMA NAO ESTA NA COMPOSICAO, INCLUA ... "
AT 2301
STOP " " DISPLAY SPACES AT 2301
GO pf-mp-acpt-01.

PERFORM pf-ver-matpri THRU pf-ver-matpri-99.


IF ws-existe NOT = "S" GO pf-mp-acpt-01.
DISPLAY mpr-nome AT 0323.

IF wst-opcao = "D" GO pf-mp-deleta.

pf-mp-acpt-02.
DISPLAY
"INFORME QUANTIDADE OU 999.9999,999 PARA DESISTIR ... "
AT 2315
MOVE zeros TO wst-csp-qtd.
ACCEPT wst-csp-qtd AT 0369.
DISPLAY spaces AT 2301
IF wst-csp-qtd = " 0,000" GO pf-mp-acpt-02.
IF wst-csp-qtd = "999.999,999" GO pf-mp-acpt-01.
MOVE wst-csp-qtd TO csp-qtd

IF wst-opcao = "I" PERFORM pf-mp-grava-csp.


IF wst-opcao = "A" PERFORM pf-mp-regrava-csp.

GO pf-mp000.

pf-mp-grava-csp.
* ----- gravando cadastro custo produto --- *
WRITE reg-csp INVALID KEY DISPLAY SPACES AT 2201
DISPLAY
"ERRO FATAL A=Gravacao invalida custo. produto ! " AT 2201
DISPLAY fs AT 2277
GO secao-99.

pf-mp-regrava-csp.
* ----- regravando cadastro custo produto ---- *
REWRITE reg-csp INVALID KEY DISPLAY SPACES AT 2201
DISPLAY
"ERRO PRDAL X=Regravacao Invalida Custo produto " AT 2201
DISPLAY fs AT 2277
GO secao-99.

pf-mp-deleta.
DISPLAY "CONFIRMA DELECAO MAT.PRIMA [SIM/NAO]... " AT 2301
ACCEPT wst-confirma AT 2356
DISPLAY SPACES AT 2301
IF wst-confirma = "nao" OR
wst-confirma = "NAO" GO pf-mp-acpt-01.
IF wst-confirma NOT = "sim" AND
wst-confirma NOT = "SIM" GO pf-mp-deleta.

DELETE cstcsprd INVALID KEY DISPLAY


"ERRO - Delecao materia prima inexistente " AT 2301
DISPLAY fs AT 2377
STOP " "
GO pf-mp-acpt-01.
GO pf-mp000.

pf-ver-matpri.
MOVE csp-cdgcst TO mpr-cdg
MOVE "S" TO ws-existe

READ cstcdmpr INVALID KEY MOVE "N" TO ws-existe


MOVE "00" TO fs.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcdmpr Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
GO TO pf-ver-matpri.
pf-ver-matpri-99.
EXIT.

pf-ver-cstprd.
MOVE "S" TO ws-existe

READ cstcsprd INVALID KEY MOVE "N" TO ws-existe


MOVE "00" TO fs.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcsprd Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
GO TO pf-ver-cstprd.
pf-ver-cstprd-99.
EXIT.

pf-mp999.
EXIT.

******************************************************************************
SECAO-FAT-ACR SECTION.
******************************************************************************
pf-fa000.
DISPLAY SPACES AT 0101
DISPLAY G-CST006C.
DISPLAY WS-OPERA AT 0150

DISPLAY wst-csp-prdcdg AT 0215.


DISPLAY prd-nome AT 0223.

MOVE ZEROS TO ws-cont


MOVE wst-csp-prdcdg TO csp-prdcdg
MOVE 4 TO csp-tipcst
MOVE 0 TO csp-cdgcst

START cstcsprd KEY IS >= csp-cod


INVALID KEY GO pf-fa-naoexiste.

pf-fa01A.
READ cstcsprd NEXT RECORD AT END GO pf-fa02A.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcsprd Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
MOVE csp-key TO csp-cod
START cstcsprd KEY IS >= csp-cod
GO TO pf-fa01A.

IF csp-tipcst NOT = 4 IF ws-cont = 0 GO pf-fa-naoexiste


ELSE GO pf-fa02A.

MOVE csp-cod TO csp-key.

ADD 1 TO ws-cont.

IF ws-cont = 1 PERFORM pf-fa-mostra-prod.

PERFORM pf-fa-lerfat.
COMPUTE wln = (ws-cont + 4)

IF wln = 73 OR wln = 56 OR wln = 39 OR wln = 22


DISPLAY "TECLE <ENTER> P/VER PROXIMOS ITENS ..." AT 2301
STOP " "
MOVE 4 TO wln1
PERFORM pf-fa-limpa THRU pf-fa-limpa-99.

IF wln > 72 COMPUTE wln = (wln - 68).


IF wln > 55 COMPUTE wln = (wln - 51).
IF wln > 38 COMPUTE wln = (wln - 34).
IF wln > 21 COMPUTE wln = (wln - 17).

MOVE 17 TO wcl
DISPLAY fat-cdg AT wlncl.
MOVE 23 TO wcl
DISPLAY fat-nome AT wlncl.
MOVE 47 TO wcl
MOVE csp-qtd TO wst-percent
DISPLAY wst-percent AT wlncl.

GO pf-fa01A.

pf-fa-limpa.
ADD 1 TO wln1
IF wln1 > 21 GO pf-fa-limpa-99.
MOVE 15 TO wcl1
DISPLAY
" ___ ____________________ ___,___ "
AT wlncl1.
GO pf-fa-limpa.

pf-fa-limpa-99.
EXIT.

pf-fa-mostra-prod.
MOVE csp-prdcdg TO prd-cod
READ cstcdprd INVALID KEY DISPLAY spaces AT 2001
DISPLAY
"ERRO FATAL - DESCRICAO DE PRODUTO NAO CADASTRADA " AT 2001
DISPLAY
" ANOTE CODIGO : " AT 2101
DISPLAY csp-prdcdg AT 2130
DISPLAY
" E CADASTRE-O ! " AT 2140
GO SECAO-99.
DISPLAY prd-nome AT 0223.

pf-fa-lerfat.
MOVE csp-cdgcst TO fat-cdg
READ cstcdfat INVALID KEY DISPLAY SPACES AT 2001
DISPLAY
"ERRO FATAL - PRODUTO C/FATOR ACRESCIMO INEXISTENTE " AT 2001
DISPLAY
" ANOTE CODIGO : " AT 2101
DISPLAY csp-cdgcst AT 2130
DISPLAY
" E CADASTRE-O ! " AT 2140
GO SECAO-99.

IF FS NOT = "00" DISPLAY


"cstcdfat TEMPORARIAMENTE BLOQUEADO, AGUARDE ..." AT 2301
GO pf-fa-lerfat.

pf-fa02A.
MOVE 4 TO csp-tipcst.
IF wst-opcao = "I" OR
wst-opcao = "D" OR
wst-opcao = "A" GO pf-fa-acpt-01.

IF wst-opcao = "V" DISPLAY SPACES AT 2301


DISPLAY "TECLE <ENTER> " AT 2301
STOP " "
GO pf-fa999.

pf-fa-naoexiste.
MOVE 4 TO csp-tipcst.
IF wst-opcao NOT = "I" DISPLAY
"ERRO - FAT.ACRES.N/CADASTRADO P/ESTE PRODUTO TECLE <ENTER>"
AT 2301
STOP " "
GO pf-fa999.
DISPLAY
"*-> PRODUTO NOVO SENDO CADASTRADO, DESEJA ASSUMIR FATORES AC
- "RESCIMO PADRAO <-*" AT 2301
DISPLAY
" SIM = ASSUME VALORES PRE-DEFINIDOS NAO = CADASTRE-OS SEPA
- "RADAMENTE [ v ] " AT 2401

ACCEPT ws-gera AT 2473


DISPLAY spaces AT 2301
IF ws-gera NOT = "SIM" AND NOT = "NAO"
GO pf-fa-naoexiste.
IF ws-gera = "NAO" GO pf-fa-acpt-01.
CLOSE cstcdfat
OPEN INPUT cstcdfat.

pf-fa-gera.
READ cstcdfat NEXT RECORD AT END GO pf-fa000.
MOVE fat-cdg TO csp-cdgcst.
MOVE fat-percentual TO csp-qtd.

PERFORM pf-fa-grava-csp.

GO pf-fa-gera.

pf-fa-acpt-01.
DISPLAY
"INFORME CODIGO DO FATOR ACRESCIMO OU 99999 PARA DESISTIR !"
AT 2310
ACCEPT csp-cdgcst AT 0315.
DISPLAY spaces AT 2301
IF csp-cdgcst = ALL "9" GO pf-fa999.

PERFORM pf-fa-ver-cstprd THRU pf-fa-ver-cstprd-99.


IF ws-existe = "S" AND
wst-opcao = "I" DISPLAY
"ERRO - FATOR DE ACRESCIMO JA FAZ PARTE DO PRODUTO ..."
AT 2301
STOP " " DISPLAY SPACES AT 2301
GO pf-fa-acpt-01.
IF ws-existe = "N" AND
wst-opcao NOT = "I" DISPLAY
"ERRO - FATOR ACRESCIMO NAO FAZ PARTE DESTE PRODUTO ... "
AT 2301
STOP " " DISPLAY SPACES AT 2301
GO pf-fa-acpt-01.

PERFORM pf-fa-ver-fatacr THRU pf-fa-ver-fatacr-99.


IF ws-existe NOT = "S" GO pf-fa-acpt-01.
DISPLAY fat-nome AT 0323.

IF wst-opcao = "D" GO pf-fa-deleta.

pf-fa-acpt-02.
DISPLAY
"INFORME PRECENTUAL OU 999,999 PARA DESISTIR ... "
AT 2315
MOVE fat-percentual TO wst-percent.
ACCEPT wst-percent WITH PROMPT UPDATE AT 0373.
DISPLAY spaces AT 2301
IF wst-percent = " 0,000" GO pf-fa-acpt-02.
IF wst-percent = "999,999" GO pf-fa-acpt-01.
MOVE wst-percent TO csp-qtd

IF wst-opcao = "I" PERFORM pf-fa-grava-csp.


IF wst-opcao = "A" PERFORM pf-fa-regrava-csp.

GO pf-fa000.

pf-fa-grava-csp.
* ----- gravando cadastro custo produto --- *
WRITE reg-csp INVALID KEY DISPLAY SPACES AT 2201
DISPLAY
"ERRO FATAL A=Gravacao invalida custo. produto ! " AT 2201
DISPLAY fs AT 2277
GO secao-99.
pf-fa-regrava-csp.
* ----- regravando cadastro custo produto ---- *
REWRITE reg-csp INVALID KEY DISPLAY SPACES AT 2201
DISPLAY
"ERRO PRDAL X=Regravacao Invalida Custo produto " AT 2201
DISPLAY fs AT 2277
GO secao-99.

pf-fa-deleta.
DISPLAY "CONFIRMA DELECAO FAT.ACRESC.[SIM/NAO]... " AT 2301
ACCEPT wst-confirma AT 2356
DISPLAY SPACES AT 2301
IF wst-confirma = "nao" OR
wst-confirma = "NAO" GO pf-fa-acpt-01.
IF wst-confirma NOT = "sim" AND
wst-confirma NOT = "SIM" GO pf-fa-deleta.

DELETE cstcsprd INVALID KEY DISPLAY


"ERRO - Delecao materia prima inexistente " AT 2301
DISPLAY fs AT 2377
STOP " "
GO pf-fa-acpt-01.
GO pf-fa000.

pf-fa-ver-fatacr.
MOVE csp-cdgcst TO fat-cdg
MOVE "S" TO ws-existe

READ cstcdfat INVALID KEY MOVE "N" TO ws-existe


MOVE "00" TO fs.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcdfat Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
GO TO pf-fa-ver-fatacr.
pf-fa-ver-fatacr-99.
EXIT.

pf-fa-ver-cstprd.
MOVE "S" TO ws-existe

READ cstcsprd INVALID KEY MOVE "N" TO ws-existe


MOVE "00" TO fs.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcsprd Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
GO TO pf-fa-ver-cstprd.
pf-fa-ver-cstprd-99.
EXIT.

pf-fa999.
EXIT.

******************************************************************************
SECAO-CREDITO SECTION.
******************************************************************************
pf-cr000.
DISPLAY SPACES AT 0101
DISPLAY G-CST006D.
DISPLAY WS-OPERA AT 0150

DISPLAY wst-csp-prdcdg AT 0215.


DISPLAY prd-nome AT 0223.

MOVE ZEROS TO ws-cont


MOVE wst-csp-prdcdg TO csp-prdcdg
MOVE 2 TO csp-tipcst
MOVE 0 TO csp-cdgcst

START cstcsprd KEY IS >= csp-cod


INVALID KEY GO pf-cr-naoexiste.

pf-cr01A.
READ cstcsprd NEXT RECORD AT END GO pf-cr02A.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcsprd Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
MOVE csp-key TO csp-cod
START cstcsprd KEY IS >= csp-cod
GO TO pf-cr01A.

IF csp-tipcst NOT = 2 IF ws-cont = 0 GO pf-cr-naoexiste


ELSE GO pf-cr02A.

MOVE csp-cod TO csp-key.

ADD 1 TO ws-cont.

IF ws-cont = 1 PERFORM pf-cr-mostra-prod.

PERFORM pf-cr-lercre.
COMPUTE wln = (ws-cont + 4)

IF wln = 73 OR wln = 56 OR wln = 39 OR wln = 22


DISPLAY "TECLE <ENTER> P/VER PROXIMOS ITENS ..." AT 2301
STOP " "
MOVE 4 TO wln1
PERFORM pf-cr-limpa THRU pf-cr-limpa-99.

IF wln > 72 COMPUTE wln = (wln - 68).


IF wln > 55 COMPUTE wln = (wln - 51).
IF wln > 38 COMPUTE wln = (wln - 34).
IF wln > 21 COMPUTE wln = (wln - 17).

MOVE 17 TO wcl
DISPLAY cre-cdg AT wlncl.
MOVE 23 TO wcl
DISPLAY cre-nome AT wlncl.
MOVE 47 TO wcl
MOVE csp-qtd TO wst-percent
DISPLAY wst-percent AT wlncl.

GO pf-cr01A.

pf-cr-limpa.
ADD 1 TO wln1
IF wln1 > 21 GO pf-cr-limpa-99.
MOVE 15 TO wcl1
DISPLAY
" ___ ____________________ ___,___ "
AT wlncl1.
GO pf-cr-limpa.

pf-cr-limpa-99.
EXIT.

pf-cr-mostra-prod.
MOVE csp-prdcdg TO prd-cod
READ cstcdprd INVALID KEY DISPLAY spaces AT 2001
DISPLAY
"ERRO FATAL - DESCRICAO DE PRODUTO NAO CADASTRADA " AT 2001
DISPLAY
" ANOTE CODIGO : " AT 2101
DISPLAY csp-prdcdg AT 2130
DISPLAY
" E CADASTRE-O ! " AT 2140
GO SECAO-99.
DISPLAY prd-nome AT 0223.

pf-cr-lercre.
MOVE csp-cdgcst TO cre-cdg
READ cstcdcre INVALID KEY DISPLAY SPACES AT 2001
DISPLAY
"ERRO FATAL - PRODUTO C/TIPO DE CREDITO INEXISTENTE " AT 2001
DISPLAY
" ANOTE CODIGO : " AT 2101
DISPLAY csp-cdgcst AT 2130
DISPLAY
" E CADASTRE-O ! " AT 2140
GO SECAO-99.

IF FS NOT = "00" DISPLAY


"cstcdcre TEMPORARIAMENTE BLOQUEADO, AGUARDE ..." AT 2301
GO pf-cr-lercre.

pf-cr02A.
MOVE 2 TO csp-tipcst.
IF wst-opcao = "I" OR
wst-opcao = "D" OR
wst-opcao = "A" GO pf-cr-acpt-01.

IF wst-opcao = "V" DISPLAY SPACES AT 2301


DISPLAY "TECLE <ENTER> " AT 2301
STOP " "
GO pf-cr999.

pf-cr-naoexiste.
MOVE 2 TO csp-tipcst.
IF wst-opcao NOT = "I" DISPLAY
"ERRO - CREDITO NAO CADASTRADO P/ESTE PRODUTO TECLE <ENTER>"
AT 2301
STOP " "
GO pf-cr999.
DISPLAY
"*-> PRODUTO NOVO SENDO CADASTRADO, DESEJA ASSUMIR CREDITO S/
- "PRODUTO PADRAO <-*" AT 2301
DISPLAY
" SIM = ASSUME VALORES PRE-DEFINIDOS NAO = CADASTRE-OS SEPA
- "RADAMENTE [___] " AT 2401

ACCEPT ws-gera AT 2473


DISPLAY spaces AT 2301
IF ws-gera NOT = "SIM" AND NOT = "NAO"
GO pf-cr-naoexiste.
IF ws-gera = "NAO" GO pf-cr-acpt-01.
CLOSE cstcdcre
OPEN INPUT cstcdcre.

pf-cr-gera.
READ cstcdcre NEXT RECORD AT END GO pf-cr000.

MOVE cre-cdg TO csp-cdgcst.


MOVE cre-percentual TO csp-qtd.

PERFORM pf-cr-grava-csp.

GO pf-cr-gera.

pf-cr-acpt-01.
DISPLAY
"INFORME CODIGO DO CREDITO S/PROD OU 99999 PARA DESISTIR !"
AT 2315
ACCEPT csp-cdgcst AT 0315.
DISPLAY spaces AT 2301
IF csp-cdgcst = ALL "9" GO pf-cr999.

PERFORM pf-cr-ver-cstprd THRU pf-cr-ver-cstprd-99.


IF ws-existe = "S" AND
wst-opcao = "I" DISPLAY
"ERRO - TIPO DE CREDITO JA FAZ PARTE DO PRODUTO ... "
AT 2301
STOP " " DISPLAY SPACES AT 2301
GO pf-cr-acpt-01.
IF ws-existe = "N" AND
wst-opcao NOT = "I" DISPLAY
"ERRO - TIPO DE CREDITO NAO FAZ PARTE DESTE PRODUTO ... "
AT 2301
STOP " " DISPLAY SPACES AT 2301
GO pf-cr-acpt-01.

PERFORM pf-cr-ver-credito THRU pf-cr-ver-credito-99.


IF ws-existe NOT = "S" GO pf-cr-acpt-01.
DISPLAY cre-nome AT 0323.

IF wst-opcao = "D" GO pf-cr-deleta.

pf-cr-acpt-02.
DISPLAY
"INFORME PRECENTUAL OU 999,999 PARA DESISTIR ... "
AT 2315
MOVE cre-percentual TO wst-percent.
ACCEPT wst-percent WITH PROMPT UPDATE AT 0373.
DISPLAY spaces AT 2301
IF wst-percent = " 0,000" GO pf-cr-acpt-02.
IF wst-percent = "999,999" GO pf-cr-acpt-01.
MOVE wst-percent TO csp-qtd

IF wst-opcao = "I" PERFORM pf-cr-grava-csp.


IF wst-opcao = "A" PERFORM pf-cr-regrava-csp.

GO pf-cr000.

pf-cr-grava-csp.
* ----- gravando cadastro custo produto --- *
WRITE reg-csp INVALID KEY DISPLAY SPACES AT 2201
DISPLAY
"ERRO FATAL A=Gravacao invalida custo. produto ! " AT 2201
DISPLAY fs AT 2277
GO secao-99.

pf-cr-regrava-csp.
* ----- regravando cadastro custo produto ---- *
REWRITE reg-csp INVALID KEY DISPLAY SPACES AT 2201
DISPLAY
"ERRO PRDAL X=Regravacao Invalida Custo produto " AT 2201
DISPLAY fs AT 2277
GO secao-99.

pf-cr-deleta.
DISPLAY "CONFIRMA DELECAO TP.CREDITO [SIM/NAO]... " AT 2301
ACCEPT wst-confirma AT 2356
DISPLAY SPACES AT 2301
IF wst-confirma = "nao" OR
wst-confirma = "NAO" GO pf-cr-acpt-01.
IF wst-confirma NOT = "sim" AND
wst-confirma NOT = "SIM" GO pf-cr-deleta.

DELETE cstcsprd INVALID KEY DISPLAY


"ERRO - Delecao materia prima inexistente " AT 2301
DISPLAY fs AT 2377
STOP " "
GO pf-cr-acpt-01.
GO pf-cr000.

pf-cr-ver-credito.
MOVE csp-cdgcst TO cre-cdg
MOVE "S" TO ws-existe

READ cstcdcre INVALID KEY MOVE "N" TO ws-existe


MOVE "00" TO fs.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcdcre Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
GO TO pf-cr-ver-credito.
pf-cr-ver-credito-99.
EXIT.

pf-cr-ver-cstprd.
MOVE "S" TO ws-existe
READ cstcsprd INVALID KEY MOVE "N" TO ws-existe
MOVE "00" TO fs.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcsprd Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
GO TO pf-cr-ver-cstprd.
pf-cr-ver-cstprd-99.
EXIT.

pf-cr999.
EXIT.

******************************************************************************
SECAO-MAO-OBR SECTION.
******************************************************************************
pf-mo000.
DISPLAY SPACES AT 0101
DISPLAY G-CST006E.
DISPLAY WS-OPERA AT 0150

DISPLAY wst-csp-prdcdg AT 0215.


DISPLAY prd-nome AT 0223.

MOVE ZEROS TO ws-cont


MOVE wst-csp-prdcdg TO csp-prdcdg
MOVE 3 TO csp-tipcst
MOVE 0 TO csp-cdgcst

START cstcsprd KEY IS >= csp-cod


INVALID KEY GO pf-mo-naoexiste.

pf-mo01A.
READ cstcsprd NEXT RECORD AT END GO pf-mo02A.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcsprd Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
MOVE csp-key TO csp-cod
START cstcsprd KEY IS >= csp-cod
GO TO pf-mo01A.

IF csp-tipcst NOT = 3 IF ws-cont = 0 GO pf-mo-naoexiste


ELSE GO pf-mo02A.

MOVE csp-cod TO csp-key.

ADD 1 TO ws-cont.

IF ws-cont = 1 PERFORM pf-mo-mostra-prod.

PERFORM pf-mo-lermob.
COMPUTE wln = (ws-cont + 4)

IF wln = 73 OR wln = 56 OR wln = 39 OR wln = 22


DISPLAY "TECLE <ENTER> P/VER PROXIMOS ITENS ..." AT 2301
STOP " "
MOVE 4 TO wln1
PERFORM pf-mo-limpa THRU pf-mo-limpa-99.

IF wln > 72 COMPUTE wln = (wln - 68).


IF wln > 55 COMPUTE wln = (wln - 51).
IF wln > 38 COMPUTE wln = (wln - 34).
IF wln > 21 COMPUTE wln = (wln - 17).

MOVE 17 TO wcl
DISPLAY mob-cdg AT wlncl.
MOVE 23 TO wcl
DISPLAY mob-nome AT wlncl.
MOVE 57 TO wcl
MOVE csp-qtd TO wst-csp-qtd
DISPLAY wst-csp-qtd AT wlncl.

GO pf-mo01A.

pf-mo-limpa.
ADD 1 TO wln1
IF wln1 > 21 GO pf-mo-limpa-99.
MOVE 15 TO wcl1
DISPLAY
" ___ ______________________________ ___.___,___ "
AT wlncl1.
GO pf-mo-limpa.

pf-mo-limpa-99.
EXIT.

pf-mo-mostra-prod.
MOVE csp-prdcdg TO prd-cod
READ cstcdprd INVALID KEY DISPLAY spaces AT 2001
DISPLAY
"ERRO FATAL - DESCRICAO DE PRODUTO NAO CADASTRADA " AT 2001
DISPLAY
" ANOTE CODIGO : " AT 2101
DISPLAY csp-prdcdg AT 2130
DISPLAY
" E CADASTRE-O ! " AT 2140
GO SECAO-99.
DISPLAY prd-nome AT 0223.

pf-mo-lermob.
MOVE csp-cdgcst TO mob-cdg
READ cstcdmob INVALID KEY DISPLAY SPACES AT 2001
DISPLAY
"ERRO FATAL - PRODUTO C/MAO DE OBRA INEXISTENTE !!! " AT 2001
DISPLAY
" ANOTE CODIGO : " AT 2101
DISPLAY csp-cdgcst AT 2130
DISPLAY
" E CADASTRE-O ! " AT 2140
GO SECAO-99.

IF FS NOT = "00" DISPLAY


"cstcdmob TEMPORARIAMENTE BLOQUEADO, AGUARDE ..." AT 2301
GO pf-mo-lermob.
pf-mo02A.
MOVE 3 TO csp-tipcst.
IF wst-opcao = "I" OR
wst-opcao = "D" OR
wst-opcao = "A" GO pf-mo-acpt-01.

IF wst-opcao = "V" DISPLAY SPACES AT 2301


DISPLAY "TECLE <ENTER> " AT 2301
STOP " "
GO pf-mo999.

pf-mo-naoexiste.
MOVE 3 TO csp-tipcst.
IF wst-opcao NOT = "I" DISPLAY
"ERRO - MAO OBRA N/CADASTRADA P/ESTE PRODUTO TECLE <ENTER>"
AT 2301
STOP " "
GO pf-mo999.

pf-mo-acpt-01.
DISPLAY
"INFORME CODIGO DA MAO DE OBRA OU 99999 PARA DESISTIR !"
AT 2315
ACCEPT csp-cdgcst AT 0315.
DISPLAY spaces AT 2301
IF csp-cdgcst = ALL "9" GO pf-mo999.

PERFORM pf-mo-ver-cstprd THRU pf-mo-ver-cstprd-99.


IF ws-existe = "S" AND
wst-opcao = "I" DISPLAY
"ERRO - MAO DE OBRA JA FAZ PARTE DESTE PRODUTO ..."
AT 2301
STOP " " DISPLAY SPACES AT 2301
GO pf-mo-acpt-01.
IF ws-existe = "N" AND
wst-opcao NOT = "I" DISPLAY
"ERRO - MAO DE OBRA NAO FAZ PARTE DESTE PRODUTO ... "
AT 2301
STOP " " DISPLAY SPACES AT 2301
GO pf-mo-acpt-01.

PERFORM pf-mo-ver-maoobr THRU pf-mo-ver-maoobr-99.


IF ws-existe NOT = "S" GO pf-mo-acpt-01.
DISPLAY mob-nome AT 0323.

IF wst-opcao = "D" GO pf-mo-deleta.

pf-mo-acpt-02.
DISPLAY
"INFORME QUANTIDADE DE HORAS OU 999.999,999 PARA DESISTIR !"
AT 2315
MOVE zeros TO wst-csp-qtd.
ACCEPT wst-csp-qtd WITH PROMPT UPDATE AT 0369.
DISPLAY spaces AT 2301
IF wst-csp-qtd = " 0,000" GO pf-mo-acpt-02.
IF wst-csp-qtd = "999.999,999" GO pf-mo-acpt-01.
MOVE wst-csp-qtd TO csp-qtd

IF wst-opcao = "I" PERFORM pf-mo-grava-csp.


IF wst-opcao = "A" PERFORM pf-mo-regrava-csp.

GO pf-mo000.

pf-mo-grava-csp.
* ----- gravando cadastro custo produto --- *
WRITE reg-csp INVALID KEY DISPLAY SPACES AT 2201
DISPLAY
"ERRO FATAL A=Gravacao invalida custo. produto ! " AT 2201
DISPLAY fs AT 2277
GO secao-99.

pf-mo-regrava-csp.
* ----- regravando cadastro custo produto ---- *
REWRITE reg-csp INVALID KEY DISPLAY SPACES AT 2201
DISPLAY
"ERRO PRDAL X=Regravacao Invalida Custo produto " AT 2201
DISPLAY fs AT 2277
GO secao-99.

pf-mo-deleta.
DISPLAY "CONFIRMA DELECAO MAO DE OBRA[SIM/NAO]... " AT 2301
ACCEPT wst-confirma AT 2356
DISPLAY SPACES AT 2301
IF wst-confirma = "nao" OR
wst-confirma = "NAO" GO pf-mo-acpt-01.
IF wst-confirma NOT = "sim" AND
wst-confirma NOT = "SIM" GO pf-mo-deleta.

DELETE cstcsprd INVALID KEY DISPLAY


"ERRO - Delecao mao de obra inexistente " AT 2301
DISPLAY fs AT 2377
STOP " "
GO pf-mo-acpt-01.
GO pf-mo000.

pf-mo-ver-maoobr.
MOVE csp-cdgcst TO mob-cdg
MOVE "S" TO ws-existe

READ cstcdmob INVALID KEY MOVE "N" TO ws-existe


MOVE "00" TO fs.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcdmob Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
GO TO pf-mo-ver-maoobr.
pf-mo-ver-maoobr-99.
EXIT.

pf-mo-ver-cstprd.
MOVE "S" TO ws-existe

READ cstcsprd INVALID KEY MOVE "N" TO ws-existe


MOVE "00" TO fs.

IF fs NOT = "00" DISPLAY


"Aguarde - cstcsprd Temporariamente bloqueado !!! " AT 2301
DISPLAY fs AT 2377
GO TO pf-mo-ver-cstprd.
pf-mo-ver-cstprd-99.
EXIT.

pf-mo999.
EXIT.

secao-99 SECTION.
pf-aborta.
DISPLAY "ERRO FATAL - OPERACAO ABORTADA " AT 2301
ACCEPT ws-senha-fim AT 2360
IF ws-senha-fim NOT = "ERROGRAVE" GO pf-aborta.

secao-fim SECTION.
pf-fim.
DISPLAY SPACES AT 0101
CLOSE CSTCDMPR CSTCDFAT CSTCDMOB
CSTCDCRE CSTCDPRD CSTCSPRD.
CHAIN "CST900".