WORK-TABLE

Discussão em 'Comandos Básicos' iniciado por fdantas, Fevereiro 3, 2009.

  1. fdantas

    fdantas Administrator Moderador

    /******************** STATEMENTS**************************************
    **
    ** DEF WORK-TABLE nome-tabela-temporaria-de-memoria
    **
    ** FIELD (DEF WORK-TABLE...)
    **
    ** objeto-1:FONT = n
    **
    **********************************************************************/
    Código:
    DEF VAR x AS LOGICAL.
    DEF VAR tot-bal LIKE customer.balance.
    
    DEF WORK-TABLE w-work
        FIELD w-state    AS CHAR FORMAT "x(2)"
        FIELD w-cust-num AS CHAR FORMAT "9999"
        FIELD w-balance  AS CHAR 
        FIELD w-acum     AS CHAR. 
    
    DEF VAR relatorio AS CHARACTER
        VIEW-AS SELECTION-LIST
        INNER-CHARS 40 INNER-LINES 10  
        SCROLLBAR-VERTICAL MULTIPLE. 
    
    DEF FRAME a
        relatorio
        WITH CENTERED
        SIZE 70 BY 10.
        
    CREATE w-work.    
    ASSIGN w-work.w-state = "UF"
           w-work.w-cust-num = "Cod."
           w-work.w-balance = "Balance"
           w-work.w-acum = "Acumulate".
    FOR EACH customer WHERE
             customer.state <> ""
        BREAK BY customer.state:
        CREATE w-work.
        IF FIRST-OF(customer.state) THEN
           ASSIGN w-work.w-state = customer.state.
        ASSIGN w-cust-num = STRING(customer.cust-num, "9999")
               w-work.w-balance = STRING(customer.balance, "999999999")
               tot-bal  = customer.balance + tot-bal
               w-work.w-acum = STRING(tot-bal, "999999999").
        IF LAST-OF(customer.state) THEN
           DO:
              CREATE w-work. 
              ASSIGN w-work.w-acum = "-----------".
              CREATE w-work.
              ASSIGN w-work.w-cust-num = "Sub-total"
                     w-work.w-acum = STRING(tot-bal, "999999999")
                     tot-bal = 0. 
              CREATE w-work.                 
           END.       
    END.
    
    FOR EACH w-work:
        x = relatorio:ADD-LAST(STRING(w-work.w-state, "X(2)") + " " +
                               STRING(w-work.w-cust, "999999999") + "  " +
                               STRING(w-work.w-balance, "999999999") + "  " +
                               STRING(w-work.w-acum, "999999999")).  
    END.
    ASSIGN relatorio:FONT = 2.
    DISPLAY relatorio WITH FRAME a.        
    ENABLE ALL WITH FRAME a.
    WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.

Compartilhe esta Página