Advertisement
Guest User

Untitled

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