SHARE
TWEET

Untitled

a guest Aug 17th, 2019 139 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def input parameter vcli_ini like customer.cust-num.
  2. def input parameter vcli_fim like customer.cust-num.
  3. def input parameter vped_ini like order.order-num.
  4. def input parameter vped_fim like order.order-num.
  5. def input parameter vite_ini like item.item-num.
  6. def input parameter vite_fim like item.item-num.
  7.  
  8. def temp-table tt-dados
  9.     field tt-cliente like customer.cust-num
  10.     field tt-nome    like customer.name
  11.     field tt-pedido  like order.order-num
  12.     field tt-data    like order.order-date
  13.     field tt-item    like item.item-num
  14.     field tt-desc    like item.item-name
  15.     field tt-quant   like order-line.qty
  16.     field tt-preco   like order-line.price
  17.     field tt-total   as decimal format "zzz,zzz,zz9.99".
  18.  
  19. form tt-pedido  column-label "Pedido"      
  20.      tt-data    column-label "Data"        
  21.      tt-item    column-label "Item"        
  22.      tt-desc    column-label "Descricao"  
  23.      tt-quant   column-label "Qtd"        
  24.      tt-preco   column-label "Valor"      
  25.      tt-total   column-label "Total"      
  26.      with frame f-relatorio stream-io width 132 down.
  27.  
  28. empty temp-table tt-dados.
  29.  
  30. for each customer no-lock where
  31.          customer.cust-num >= vcli_ini and
  32.          customer.cust-num <= vcli_fim,
  33.     each order of customer no-lock where
  34.          order.order-num >= vped_ini and
  35.          order.order-num <= vped_fim,
  36.     each order-line of order no-lock where
  37.          order-line.item-num >= vite_ini and
  38.          order-line.item-num <= vite_fim,
  39.     each item of order-line no-lock:
  40.  
  41.  
  42.     create tt-dados.
  43.     assign tt-cliente = customer.cust-num
  44.            tt-nome    = customer.name    
  45.            tt-pedido  = order.order-num  
  46.            tt-data    = order.order-date
  47.            tt-item    = item.item-num    
  48.            tt-desc    = item.item-name  
  49.            tt-quant   = order-line.qty  
  50.            tt-preco   = order-line.price
  51.            tt-total   = order-line.qty * order-line.price.
  52. end.
  53.  
  54.  
  55. output to c:\curso\relat\customer_3.lst.
  56.  
  57. for each tt-dados
  58.     break by tt-cliente
  59.           by tt-pedido:
  60.  
  61.    
  62.     accumulate tt-quant (total by tt-pedido)
  63.                tt-total (total by tt-pedido)
  64.                tt-quant (total by tt-cliente)
  65.                tt-total (total by tt-cliente).
  66.    
  67.     if first-of (tt-cliente) then
  68.         put "Cliente: " tt-cliente " - "tt-nome.
  69.  
  70.  
  71.     if first-of (tt-pedido)  then
  72.         display tt-pedido
  73.                 tt-data
  74.                 with frame f-relatorio.
  75.  
  76.  
  77.     display tt-item  
  78.             tt-desc  
  79.             tt-quant
  80.             tt-preco
  81.             tt-total
  82.             with frame f-relatorio.
  83.     down with frame f-relatorio.
  84.  
  85.  
  86.     if last-of (tt-pedido) then
  87.         do:
  88.             display "---------------" @ tt-item
  89.                     "------"          @ tt-quant
  90.                     "-------------"   @ tt-preco
  91.                     "--------------"  @ tt-total
  92.                     with frame f-relatorio.
  93.             down with frame f-relatorio.
  94.  
  95.             display "Total Pedido"                         @ tt-item
  96.                     accum total  by tt-pedido tt-quant     @ tt-quant
  97.                     (accum total by tt-pedido tt-total) /
  98.                     (accum total by tt-pedido tt-quant)    @ tt-preco
  99.                     accum total  by tt-pedido tt-total     @ tt-total
  100.                     with frame f-relatorio.
  101.             down with frame f-relatorio.
  102.             put skip(1).
  103.         end.
  104.  
  105.     if last-of (tt-dados.tt-cliente) then
  106.        do:
  107.            put skip(1).
  108.            display "---------------" @ tt-item
  109.                    "------"          @ tt-quant
  110.                    "-------------"   @ tt-preco
  111.                    "--------------"  @ tt-total
  112.                    with frame f-relatorio.
  113.             down with frame f-relatorio.
  114.  
  115.            display "Total Cliente"                         @ tt-item
  116.                    accum total  by tt-cliente tt-quant     @ tt-quant
  117.                    (accum total by tt-cliente tt-total) /
  118.                    (accum total by tt-cliente tt-quant)    @ tt-preco
  119.                    accum total  by tt-cliente tt-total     @ tt-total
  120.                    with frame f-relatorio.
  121.            down with frame f-relatorio.
  122.            put skip(2).
  123.        end.
  124.  
  125.     if last (tt-dados.tt-cliente) then
  126.         do:
  127.             put skip(2).
  128.            
  129.             display "---------------" @ tt-item
  130.                     "------"          @ tt-quant
  131.                     "-------------"   @ tt-preco
  132.                     "--------------"  @ tt-total
  133.                     with frame f-relatorio.
  134.             down with frame f-relatorio.
  135.            
  136.             display "Total Geral"             @ tt-item
  137.                     accum total  tt-quant     @ tt-quant
  138.                     (accum total tt-total) /
  139.                     (accum total tt-quant)    @ tt-preco
  140.                     accum total  tt-total     @ tt-total
  141.                     with frame f-relatorio.
  142.             down with frame f-relatorio.
  143.         end.
  144. end.
  145.  
  146.  
  147. output close.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top