Advertisement
Guest User

Untitled

a guest
Dec 1st, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 10.22 KB | None | 0 0
  1.        Identification Division.
  2.        Program-Id.   DEPARTAMENTO.
  3.  
  4.        Environment Division.
  5.       *special-names.   decimal-point is comma.
  6.        input-output section.
  7.        file-control.
  8.            select DEPTO assign to disk
  9.            organization indexed
  10.            access mode dynamic
  11.            record key codigo-depto
  12.       *   alternate record key nome-depto
  13.            file status arqst.
  14.  
  15.        data division.
  16.        file section.
  17.        fd  DEPTO label record standard
  18.            value of file-id is "DEPTOS.dat".
  19.        01 reg-cli.
  20.            02 codigo-depto  pic 9(04).
  21.            02 nome-depto    pic x(30).
  22.            02 responsavel   pic x(30).
  23.            02 divisao-depto pic 9(01).
  24.  
  25.        working-storage section.
  26.        01 reg-cli-e.
  27.            02 codigo-depto-e  pic 9(04).
  28.            02 nome-depto-e    pic x(30).
  29.            02 responsavel-e   pic x(30).
  30.            02 divisao-depto-e pic 9(01).
  31.  
  32.        01 data-sis.
  33.            02 ano   pic 9999.
  34.            02 mes   pic 99.
  35.            02 dia   pic 99.
  36.        01 destipo.
  37.           02 filler pic x(30) value "Presidencia".
  38.           02 filler pic x(30) value "Diretoria".
  39.           02 filler pic x(30) value "Comercial".
  40.           02 filler pic x(30) value "Operacional".
  41.           02 filler pic x(30) value "Producao".
  42.        01 irado redefines destipo.
  43.           02 irado-t pic x(30) occurs 5 times.
  44.          
  45.        01 desmes.
  46.           02 filler pic x(10) value "Janeiro".
  47.           02 filler pic x(10) value "Fevereiro".
  48.           02 filler pic x(10) value "Mar‡o".
  49.           02 filler pic x(10) value "Abril".
  50.           02 filler pic x(10) value "Maio".
  51.           02 filler pic x(10) value "Junho".
  52.           02 filler pic x(10) value "Julho".
  53.           02 filler pic x(10) value "Agosto".
  54.           02 filler pic x(10) value "Setembro".
  55.           02 filler pic x(10) value "Outubro".
  56.           02 filler pic x(10) value "Novembro".
  57.           02 filler pic x(10) value "Dezembro".
  58.        
  59.  
  60.        01 tabela-meses redefines desmes.
  61.            02 mes-t pic x(10) occurs 12 times.
  62.        01 arqst        pic x(2).
  63.        01 op           pic x(1) value spaces.
  64.        01 salva        pic x(1) value spaces.
  65.        01 wigual       pic 9 value zeros.
  66.        01 espaco       pic x(60) value spaces.
  67.        01 op-continua  pic x(1)  value spaces. 
  68.  
  69.        screen section.
  70.        01 tela1.
  71.           02 BLANK SCREEN.
  72.           02 line 2 col 5 value "Santos,    de            de     .".
  73.           02 line 2 col 55 value "Nome da Empresa qota".
  74.           02 line 4 col 29 value "Controle de Patrimonio" highlight.
  75.           02 line 6 col 29 value "1. Inclusao departamento".
  76.           02 line 8 col 29 value "2. Alteracao departamento".
  77.           02 line 10 col 29 value "3. Exclusao departamento".
  78.           02 line 12 col 29 value "4. Consulta departamento".
  79.           02 line 14 col 29 value "5. Retorno".
  80.           02 line 20 col 25 value "Escolha uma Op‡ao:".
  81.  
  82.        01 tela2.
  83.            02 BLANK SCREEN.
  84.            02 line 02 col 05 value "Santos,    de           de     .".
  85.            02 line 02 col 55 value "CONTROLE PATRIMÔNIO" highlight.
  86.            02 line 04 col 29 value "DEPARTAMENTO" highlight.
  87.            02 line 10 col 19 value "Codigo: ".
  88.            02 line 12 col 19 value "Nome: ".
  89.            02 line 14 col 19 value "responsavel: ".
  90.            02 line 16 col 19 value "divisao-depto: ".
  91.            
  92.        01 codDepto.
  93.            02 line 07 col 25 value "divisao-depto codigo".
  94.            02 line 08 col 10 value "1- Presidencia 2- Diretoria 3- Comercial 4- Operacional 5- Producao".
  95.        Procedure Division.
  96.        Inicio.
  97.        
  98.            Perform abre-arq.
  99.            Perform abertura until op = "5".
  100.        
  101.            STOP run.
  102.  
  103.        abre-arq.
  104.            open i-o DEPTO.
  105.            if arqst not = "00"
  106.                display "erro de abertura" at 2155
  107.                close DEPTO
  108.                open output DEPTO
  109.                STOP RUN.
  110.  
  111.        abertura.
  112.            
  113.            display tela1.
  114.            Perform mostra-data.
  115.            accept op at 2045 WITH PROMPT AUTO.
  116.            move spaces to op-continua
  117.            evaluate op
  118.            when "1"
  119.                perform inclusao until op-continua = "n" or "N"
  120.    
  121.            when "2"
  122.                perform alteracao until op-continua = "n" or "N"
  123.        
  124.            when "3"
  125.                perform exclusao until op-continua = "n" or "N"
  126.            
  127.            when "4"
  128.                perform consulta until op-continua = "n" or "N"
  129.            end-evaluate.
  130.          
  131.  
  132.        mostra-data.
  133.            move function current-date to data-sis.
  134.            display dia at 0213.
  135.            display mes-t(mes) at 0219.
  136.            display ano at 0233.
  137.  
  138.        inclusao.
  139.            perform tela-inclusao.
  140.            move zeros to wigual.
  141.            perform inicializar.
  142.            perform testa-codicli until wigual = 1.
  143.            perform recebe-dados.
  144.            perform grava.
  145.            perform continua.
  146.  
  147.  
  148.        tela-inclusao.
  149.        display erase at 0101.
  150.        display tela2.
  151.        display codDepto.
  152.            display "Cadastro de Departamento" at 0530 with highlight.
  153.            perform mostra-data.
  154.  
  155.        inicializar.
  156.        move spaces to op op-continua salva.
  157.            move spaces to nome-depto-e responsavel-e
  158.            move zeros to codigo-depto-e divisao-depto-e
  159.            move zeros to wigual.
  160.            display espaco at 2315.
  161.  
  162.        recebe-dados.
  163.            perform testa-nome  until nome-depto-e not = spaces.
  164.            perform testa-responsavel  until responsavel-e not = spaces.
  165.            perform testa-divisao-depto until divisao-depto-e not = zeros AND < 6 AND > 0.
  166.  
  167.        
  168.        testa-codicli.
  169.            move 1 to wigual.
  170.            move zeros to codigo-depto-e.
  171.            accept codigo-depto-e at 1032 with prompt auto.
  172.            if codigo-depto-e = spaces or "0000" then
  173.                 display "Digite um codigo diferente de zero." at 2321
  174.                 set wigual to 0
  175.            else
  176.                 move codigo-depto-e to codigo-depto
  177.                 read DEPTO not invalid key perform ja-cadastrado.
  178.  
  179.        ja-cadastrado.
  180.            display "Codigo ja cadastrado" at 2321
  181.            set wigual to 0.
  182.  
  183.  
  184.        testa-nome.
  185.            accept nome-depto-e at 1232.
  186.            if nome-depto-e = spaces then
  187.                 display "Digite o nome do departamento" at 2321
  188.        else
  189.                 display espaco at 2321.
  190.  
  191.  
  192.        testa-responsavel.
  193.            accept responsavel-e at 1432.
  194.            if responsavel-e = spaces then
  195.                 display "Digite o nome responsavel." at 2321
  196.        else
  197.                 display espaco at 2321.
  198.  
  199.      
  200.        testa-divisao-depto.
  201.            accept divisao-depto-e at 1633.
  202.            display divisao-depto-e at 1639.
  203.            display irado-t(divisao-depto-e) at 1642.
  204.            if divisao-depto-e = zeros then
  205.                 display "Digite a divisao do departamento" at 2321
  206.        else
  207.                 display espaco at 2321.
  208.  
  209.        
  210.        grava.
  211.            display "Salvar <S/N> [ ]" at 2321.
  212.            accept salva at 2335 with prompt auto.
  213.            if salva = "S" or "s" then
  214.                 move reg-cli-e to reg-cli
  215.                 write reg-cli
  216.                 IF ARQST <> "00"
  217.                    display arqst at 2221
  218.                    STOP " ".
  219.  
  220.        continua.
  221.            display espaco at 2315.
  222.            display "Continua <S/N> [ ]" at 2321.
  223.            accept op-continua at 2337 with prompt auto.
  224.        
  225.        exclusao.
  226.            perform inicializar.
  227.            display erase at 0101.
  228.            display tela2.
  229.            display "Exclusao de Registro" at 0730 with highlight.
  230.            perform inicializar.
  231.            perform le-dados.
  232.            if arqst = "00" then
  233.                display irado-t(divisao-depto-e) at 1642
  234.                display "Deseja excluir o registro<S/N> [ ]" at 2319
  235.                accept salva at 2351 with prompt auto
  236.            else
  237.                perform inicializar
  238.                display espaco at 2319
  239.                display "Registro nao encontrado." at 2321.
  240.            if salva = "S" or "s" then
  241.                display espaco at 2319
  242.                Display "Registro apagado." at 2321
  243.                delete DEPTO.
  244.            stop " ".
  245.            display espaco at 2315.
  246.            perform continua.
  247.  
  248.        estuda-erro.
  249.            display "C�digo nao encontrado." at 2321.
  250.            stop " ".
  251.  
  252.        consulta.
  253.            display tela2.
  254.            display "Consulta de Registro" at 0730 with highlight.
  255.            perform le-dados.
  256.            perform continua.
  257.  
  258.        le-dados.
  259.            perform inicializar.
  260.            perform mostra-data.
  261.            accept codigo-depto-e at  1032.
  262.            move codigo-depto-e to codigo-depto.
  263.            read DEPTO key is codigo-depto invalid key
  264.                 display "Departamento naum encontrado" at 2320
  265.                 move 1 to wigual
  266.                 stop " ".
  267.            if arqst = "00" then
  268.               display espaco at 2319
  269.               perform mostra-tela.
  270.  
  271.  
  272.        mostra-tela.
  273.            move reg-cli to reg-cli-e.
  274.            display codigo-depto-e  at 1032.
  275.            display nome-depto-e    at 1232.
  276.            display responsavel-e   at 1432.
  277.            display divisao-depto-e at 1632.
  278.            display irado-t(divisao-depto-e) at 1642.
  279.  
  280.        altera-dados.
  281.            accept codigo-depto-e   at 1032.
  282.            accept nome-depto-e     at 1232.
  283.            accept responsavel-e    at 1432.
  284.            accept divisao-depto-e  at 1632.
  285.          
  286.  
  287.        alteracao.
  288.            perform inicializar.
  289.            display tela2.
  290.            display "Altera�ao de Registro" at 0625 with highlight.
  291.            perform le-dados.
  292.            if wigual <> 1
  293.               display irado-t(divisao-depto-e) at 1642
  294.               perform altera-dados
  295.               perform recebe-dados
  296.               display "Deseja salvar altera�ao <S/N> [ ]" at 2319
  297.               accept salva at 2350 with prompt auto
  298.               if salva = "S" or "s" then
  299.                  move reg-cli-e to reg-cli
  300.                  rewrite reg-cli invalid key perform estuda-erro
  301.                  display espaco at 2315.
  302.  
  303.            perform continua.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement