1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Urgente RE1001b - Peso Bruto do Item

Discussão em 'EMS , HCM e Totvs 11' iniciado por rodolfo.rcs, Maio 17, 2021.

  1. rodolfo.rcs

    rodolfo.rcs Membro Participativo

    Boa tarde,

    alguém consegui ajudar como encontro o campo e tabela que representa o peso bruto do item no recebimento ?

    Não encontrei na item-doc-est. Já exportei os dados e nada.

    Versão 12.1.31.

    upload_2021-5-17_15-17-10.png
    upload_2021-5-17_15-18-2.png

    upload_2021-5-17_15-17-24.png
  2. bootstrapmaster

    bootstrapmaster Membro Master

    Meu caro, esses campos ai não existem no produto padrão, procura por uma UPC ligada ao re1001b ou screen-optimize, esses 3 campos são customizados.
  3. rodolfo.rcs

    rodolfo.rcs Membro Participativo

    Oi Richard,

    é uma appc padrão do produto por conta do GFE.

    Boa tarde Rodolfo,

    Sim, é devido a parametrização do módulo de GFE.

    Se tem marcado o parâmetro Frete Embarcador Muitiplataroma (TotvsGFE), aba Módulos II no programa CD0101 e;

    Se tem marcado o parâmetro Notas Fiscais de Entrada, aba Integrações em CD0089, apresentará esses campos adicionais na tela do RE1001b.


    RE1001B2 2.00.02.043 re1001b 21/05/21 10:18:11
    APPC: cdp/cdapi661.p


    Tem como achar o valor de campo e tela mesmo dessa APPC padrão ?
  4. bootstrapmaster

    bootstrapmaster Membro Master

    Código:
    /********************************************************************************
    ** Copyright DATASUL S.A. (1997)
    ** Todos os Direitos Reservados.
    **
    ** Este fonte e de propriedade exclusiva da DATASUL, sua reproducao
    ** parcial ou total por qualquer meio, so podera ser feita mediante
    ** autorizacao expressa.
    *******************************************************************************/
    {include/i-prgvrs.i CDAPI661 2.00.00.015 } /*** "010015" ***/
    
    &IF "{&EMSFND_VERSION}" >= "1.00"
    &THEN
    {include/i-license-manager.i CDAPI661 MUT}
    &ENDIF
    
    /****************************************************************************
    ***
    *** Testa conexÆo com o banco MGTRP antes de efetuar a integra‡Æo com o TMS
    ***
    ****************************************************************************/
    
    {include/i-epc200.i "cdapi661"} /*Defini‡Æo tt-EPC*/
    
    define input parameter p-ind-event  as character     no-undo.
    define input parameter p-ind-object as character     no-undo.
    define input parameter p-wgh-object as handle        no-undo.
    define input parameter p-wgh-frame  as widget-handle no-undo.
    define input parameter p-cod-table  as character     no-undo.
    define input parameter p-row-table  as rowid         no-undo.
    
    
    
    FIND FIRST funcao WHERE funcao.cd-funcao = "SPP_TOTVSGFE" NO-LOCK NO-ERROR.
    IF  NOT AVAIL funcao OR
        (AVAIL funcao AND funcao.ativo = NO) THEN
        RETURN "ok".
    
    
    {cdp/cdcfgdis.i}
       
    &if '{&bf_dis_versao_ems}' < '2.08' &then
    IF CONNECTED("mgtrp") THEN DO:
        RUN upc/appc-re1001b2.p (input p-ind-event,
                                 input p-ind-object,
                                 input p-wgh-object,
                                 input p-wgh-frame,
                                 input p-cod-table,
                                 input p-row-table).
        IF RETURN-VALUE = "NOK":U THEN
            RETURN "NOK":U.
    END.
    &ELSE
    /**************************** Defini‡Æo de Variaveis **********************************/
    /*Novos campos em tela*/
    DEF NEW GLOBAL SHARED variable wh-rt-tms                AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wgh-lbl-peso-bruto       AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wgh-lbl-peso-cubado      AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wgh-lbl-m3               AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-peso-bruto-re1001b2   AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-peso-cubado-re1001b2  AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-m3-re1001b2           AS widget-handle no-undo.
    
    DEF NEW GLOBAL SHARED variable wh-lbl-peso-liquido      AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-peso-liquido          AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-lbl-frete-const       AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-frete-const           AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-lbl-despesas          AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-despesas              AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-lbl-pedagio           AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-pedagio               AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-rect-12               AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-fPage1                AS widget-handle no-undo.
    DEF VARIABLE wgh-grupo                AS HANDLE NO-UNDO.
    DEF VARIABLE wgh-child                AS HANDLE NO-UNDO.
    
    def new global shared VARIABLE gr-docum-est             as ROWID         no-undo.
    
    define variable h-appc-re1001b2                         as handle        no-undo.
    DEFINE VARIABLE l-integrado                             AS LOGICAL       NO-UNDO.
    define variable h-objeto                                AS widget-handle no-undo.
    DEFINE VARIABLE r-rowid                                 AS ROWID         NO-UNDO.
    DEF VAR de-peso-bruto AS DEC NO-UNDO.
    
    {utp/ut-glob.i}
    /*{vfp/vfapi001.i}*/
    {cdp/cdcfgdis.i}
    {cdp/cdapi600.i &Docum-est="YES"
                    &Item-doc-est="YES"}
    
    DEFINE VARIABLE hDBOIN090 AS HANDLE      NO-UNDO.
    DEFINE VARIABLE hDBOIN176 AS HANDLE      NO-UNDO.
    DEFINE VARIABLE h-boin172 AS HANDLE      NO-UNDO.
    
    IF P-ind-event = "BEFORE-DISPLAY" THEN DO:
    
    
        FIND FIRST funcao WHERE funcao.cd-funcao = "SPP_TOTVSGFE" NO-LOCK NO-ERROR.
        IF  NOT AVAIL funcao OR
            (AVAIL funcao AND funcao.ativo = NO) THEN
            RETURN "ok".
    
    
        IF  VALID-HANDLE(wh-peso-bruto-re1001b2) THEN DO:
            RUN pi-inicializa-bos IN THIS-PROCEDURE.
            RUN pi-mostra-tela IN THIS-PROCEDURE.
           
            RUN pi-destroy-handle IN THIS-PROCEDURE.
            RETURN "OK":U.
    
        END.
    
    
        IF NOT VALID-HANDLE(h-appc-re1001b2) THEN
            RUN cdp/cdapi661.p PERSISTENT SET h-appc-re1001b2 (INPUT "",           
                                                               INPUT "",           
                                                               INPUT p-wgh-object, 
                                                               INPUT p-wgh-frame,  
                                                               INPUT "",           
                                                               INPUT p-row-table).
    
        FIND FIRST tab-generica NO-LOCK
             where tab-generica.utilizacao = "setup" NO-ERROR.
        IF AVAIL tab-generica THEN DO:
            IF SUBSTRING(tab-generica.char-2,230,1)  = "Y" THEN DO:
                if valid-handle(h-appc-re1001b2) THEN DO:
                    RUN pi-arruma-tela.
                    run pi-cria-campos-tela. /*  Cria‡Æo dos campos de tela **/
                END.
            END.
        end.
    
        RUN pi-inicializa-bos.
    
        IF  VALID-HANDLE(wh-peso-bruto-re1001b2) AND
            VALID-HANDLE(wh-peso-cubado-re1001b2) AND
            VALID-HANDLE(wh-m3-re1001b2) THEN DO:
    
            ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE  = ""
                   wh-peso-cubado-re1001b2:SCREEN-VALUE = ""
                   wh-m3-re1001b2:SCREEN-VALUE          = "".
        end.
    
        RUN pi-mostra-tela IN THIS-PROCEDURE.
    
        RUN pi-destroy-handle IN THIS-PROCEDURE.
    END.
    
    IF  P-ind-event = "AFTER-ENABLE" THEN DO:
    
        FIND FIRST funcao WHERE funcao.cd-funcao = "SPP_TOTVSGFE" NO-LOCK NO-ERROR.
        IF  NOT AVAIL funcao OR
            (AVAIL funcao AND funcao.ativo = NO) THEN
            RETURN "ok".
    
    
        RUN pi-inicializa-bos.
    
        FIND FIRST tt-item-doc-est
            WHERE tt-item-doc-est.r-rowid = p-row-table NO-LOCK NO-ERROR.
    
        IF  AVAIL tt-item-doc-est
        AND valid-handle(wh-peso-bruto-re1001b2) 
        AND valid-handle(wh-peso-cubado-re1001b2)
        AND VALID-HANDLE(wh-m3-re1001b2)          THEN DO:        
    
            FIND FIRST tab-generica NO-LOCK
                WHERE tab-generica.utilizacao = "item-nfe"
                  AND tab-generica.char-1     = tt-item-doc-est.serie-docto  + ";" + tt-item-doc-est.nro-docto + ";" + STRING(tt-item-doc-est.cod-emitente) + ";" +
                                                tt-item-doc-est.nat-operacao + ";" + STRING(tt-item-doc-est.sequencia) NO-ERROR.
    
            IF  NOT AVAIL tab-generica
            OR  tab-generica.dec-1 = 0 THEN DO:
    
                ASSIGN de-peso-bruto = 0.
                IF  NOT VALID-HANDLE(h-boin172) THEN
                    RUN inbo/boin172.p PERSISTENT SET h-boin172.
                RUN setConstraintItCodigo IN h-boin172 (INPUT tt-item-doc-est.it-codigo).
                RUN openQueryStatic IN h-boin172 (INPUT "ItCodigoInicial":U).
                RUN getDecField IN h-boin172 (INPUT "peso-bruto",
                                              OUTPUT de-peso-bruto).
    
    
                ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE = STRING(tt-item-doc-est.quantidade * de-peso-bruto).
    
            END.
        END.
    
        RUN pi-destroy-handle IN THIS-PROCEDURE.
    
    END.
    
    
    
    /************************************************ PROCEDURES INTERNAS ************************************************/
    PROCEDURE pi-destroy-handle:
        IF  VALID-HANDLE(h-appc-re1001b2) THEN
            DELETE PROCEDURE h-appc-re1001b2.
    
        IF  VALID-HANDLE(h-boin172) THEN
            RUN destroy IN h-boin172.
    
        IF  VALID-HANDLE(hDBOIN176) THEN
            RUN destroy IN hDBOIN176.
    
        IF  VALID-HANDLE(hDBOIN090) THEN
            RUN destroy IN hDBOIN090.
    END PROCEDURE.
    
    PROCEDURE pi-mostra-tela:
    
        FOR EACH tt-item-doc-est
                WHERE tt-item-doc-est.r-rowid = p-row-table NO-LOCK:
                FIND FIRST tab-generica NO-LOCK
                     WHERE tab-generica.utilizacao = "item-nfe"
                       AND tab-generica.char-1     = tt-item-doc-est.serie-docto  + ";" + tt-item-doc-est.nro-docto + ";" + STRING(tt-item-doc-est.cod-emitente) + ";" +
                                                     tt-item-doc-est.nat-operacao + ";" + STRING(tt-item-doc-est.sequencia) NO-ERROR.
       
                IF AVAIL tab-generica           AND
                   valid-handle(wh-peso-bruto-re1001b2)  AND
                   valid-handle(wh-peso-cubado-re1001b2) AND
                   VALID-HANDLE(wh-m3-re1001b2)          THEN DO:
                    ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE  = string(tab-generica.dec-1)
                           wh-peso-cubado-re1001b2:SCREEN-VALUE = string(tab-generica.dec-2)
                           wh-m3-re1001b2:SCREEN-VALUE          = SUBSTRING(tab-generica.char-2,1,6).
    
    
                END.
                ELSE DO:
               
                    IF VALID-HANDLE(wh-peso-bruto-re1001b2) AND
                       VALID-HANDLE(wh-peso-cubado-re1001b2) AND
                       VALID-HANDLE(wh-m3-re1001b2) THEN
                    ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE  = ""
                           wh-peso-cubado-re1001b2:SCREEN-VALUE = ""
                           wh-m3-re1001b2:SCREEN-VALUE          = "".
    
    
                    /* Inicializa peso-bruto */
                    ASSIGN de-peso-bruto = 0.
                    IF  NOT VALID-HANDLE(h-boin172) THEN
                        RUN inbo/boin172.p PERSISTENT SET h-boin172.
                    RUN setConstraintItCodigo IN h-boin172 (INPUT tt-item-doc-est.it-codigo).
                    RUN openQueryStatic IN h-boin172 (INPUT "ItCodigoInicial":U).
                    RUN getDecField IN h-boin172 (INPUT "peso-bruto",
                                                  OUTPUT de-peso-bruto).
       
                    
                    IF VALID-HANDLE(wh-peso-bruto-re1001b2) AND
                       VALID-HANDLE(wh-peso-cubado-re1001b2) AND
                       VALID-HANDLE(wh-m3-re1001b2) THEN
                    ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE = STRING(tt-item-doc-est.quantidade * de-peso-bruto).
                END.
            END.
    END PROCEDURE.
    
    PROCEDURE pi-arruma-tela:
    
        assign wgh-grupo = p-wgh-frame:first-child.
        do while valid-handle(wgh-grupo):
           assign  wgh-child = wgh-grupo:first-child.
           do  while valid-handle(wgh-child):
               case wgh-child:type :
                   when "frame" then do:
                       if  wgh-child:name = "fPage1" THEN
                           assign wh-fPage1 = wgh-child:handle.
                   END.
               END CASE.
               assign wgh-child = wgh-child:next-sibling.
           end.
           assign wgh-grupo = wgh-grupo:next-sibling.
        end.
    
        assign wgh-grupo = wh-fPage1:first-child.
        do while valid-handle(wgh-grupo):
           assign  wgh-child = wgh-grupo:first-child.
           do  while valid-handle(wgh-child):
               case wgh-child:type :
                   when "fill-in" then do:
                       if  wgh-child:name = "peso-liquido" THEN
                           assign wh-peso-liquido = wgh-child:handle.
                       if  wgh-child:name = "pr-total-cmi" THEN
                           assign wh-frete-const  = wgh-child:handle.
                       if  wgh-child:name = "despesas" THEN
                           assign wh-despesas     = wgh-child:handle.
                       if  wgh-child:name = "de-valor-pedagio" THEN
                           assign wh-pedagio     = wgh-child:handle.
                  end.
                  when "rectangle" then do:
                      if  wgh-child:name = "rect-12" THEN
                           assign wh-rect-12 = wgh-child:handle.
                  END.
               END CASE.
               assign wgh-child = wgh-child:next-sibling.
           end.
           assign wgh-grupo = wgh-grupo:next-sibling.
        end.
    
        IF VALID-HANDLE(wh-peso-liquido) AND
           valid-handle(wh-frete-const ) AND
           VALID-HANDLE(wh-despesas    ) AND
           VALID-HANDLE(wh-rect-12     ) THEN DO:
    
           IF VALID-HANDLE(wh-pedagio) THEN DO:
    
                ASSIGN wh-lbl-peso-liquido = wh-peso-liquido:SIDE-LABEL-HANDLE
                       wh-lbl-frete-const  = wh-frete-const:SIDE-LABEL-HANDLE
                       wh-lbl-despesas     = wh-despesas:SIDE-LABEL-HANDLE
                       wh-lbl-pedagio     = wh-pedagio:SIDE-LABEL-HANDLE.
    
                ASSIGN wh-lbl-peso-liquido:ROW = 1.5
                       wh-peso-liquido:ROW     = 1.5
                       wh-lbl-frete-const:ROW  = 2.5
                       wh-frete-const:ROW      = 2.5
                       wh-lbl-despesas:ROW     = 3.5
                       wh-despesas:ROW         = 3.5
                       wh-lbl-pedagio:ROW      = 4.5
                       wh-pedagio:ROW          = 4.5
                       wh-rect-12:HEIGHT       = 4.5.
               
           END.
           ELSE DO:
    
                ASSIGN wh-lbl-peso-liquido = wh-peso-liquido:SIDE-LABEL-HANDLE
                       wh-lbl-frete-const  = wh-frete-const:SIDE-LABEL-HANDLE
                       wh-lbl-despesas     = wh-despesas:SIDE-LABEL-HANDLE.
    
                ASSIGN wh-lbl-peso-liquido:ROW = 2
                       wh-peso-liquido:ROW     = 2
                       wh-lbl-frete-const:ROW  = 3
                       wh-frete-const:ROW      = 3
                       wh-lbl-despesas:ROW     = 4
                       wh-despesas:ROW         = 4
                       wh-rect-12:HEIGHT       = 4.5.
    
           END.
    
        END.
    
    END.
    
    procedure pi-cria-campos-tela: /*Cria os campos na tela*/
    
        /*retangulo*/
        CREATE RECTANGLE wh-rt-tms
        ASSIGN FRAME        = wh-fPage1
               SENSITIVE    = NO
               VISIBLE      = YES
               WIDTH-CHARS  = 37
               HEIGHT-CHARS = 5.4
               FILLED       = NO
               EDGE-PIXELS  = 2
               ROW          = 5.8
               COL          = 47.8
               GRAPHIC-EDGE = YES.
    
       /*Labels*/
        CREATE TEXT wgh-lbl-peso-bruto
        assign FRAME        = wh-fPage1
               FORMAT       = "x(12)"
               SCREEN-VALUE = "Peso Bruto:"
               height       = 0.88
               ROW          = 7
               COL          = 53
               VISIBLE      = YES
               font         = 1.
    
        CREATE TEXT wgh-lbl-peso-cubado
        assign FRAME        = wh-fPage1
               FORMAT       = "x(14)"
               SCREEN-VALUE = "Peso Cubado:"
               height       = 0.88
               ROW          = 8
               COL          = 51
               VISIBLE      = YES
               font         = 1.
    
        CREATE TEXT wgh-lbl-m3
        assign FRAME        = wh-fPage1
               FORMAT       = "x(04)"
               SCREEN-VALUE = "M3:"
               height       = 0.88
               ROW          = 9
               COL          = 58
               VISIBLE      = YES
               font         = 1.  
    
        FIND FIRST tab-generica NO-LOCK
             WHERE tab-generica.utilizacao = "SETUP":U NO-ERROR.
        IF AVAIL tab-generica THEN DO:
    
            /*Fill-in*/
            create fill-in wh-peso-bruto-re1001b2
            assign frame          = wh-fPage1
                side-label-handle = wgh-lbl-peso-bruto:handle
                data-type         = 'decimal'
                format            = '>>>>>,>>9.99999'
                width             = 16
                height            = 0.88
                row               = 7
                col               = 61
                visible           = yes
                sensitive         = IF SUBSTRING(tab-generica.char-2,15,1) = "1" THEN YES ELSE NO
                font              = 1.
               
            create fill-in wh-peso-cubado-re1001b2
            assign frame             = wh-fPage1
                   side-label-handle = wgh-lbl-peso-cubado:handle
                   data-type         = 'decimal'
                   format            = '>>>>,>>9.99999'
                   width             = 16
                   height            = 0.88
                   row               = 8
                   col               = 61
                   visible           = yes
                   sensitive         = IF SUBSTRING(tab-generica.char-2,15,1) = "1" THEN YES ELSE NO
                   font              = 1.
           
            create fill-in wh-m3-re1001b2
            assign frame             = wh-fPage1
                   side-label-handle = wgh-lbl-m3:handle
                   data-type         = 'decimal'
                   format            = '>>9.999'
                   width             = 16
                   height            = 0.88
                   row               = 9
                   col               = 61
                   visible           = YES
                   sensitive         = IF SUBSTRING(tab-generica.char-2,15,1) = "1" THEN YES ELSE NO
                   font              = 1.
    
        END.
    end.
    
    
    PROCEDURE pi-inicializa-bos:
    
        /*--- Verifica se o DBO ja esta inicializado ---*/
        IF NOT VALID-HANDLE(hDBOIN090) OR
            hDBOIN090:TYPE <> "PROCEDURE":U OR
            hDBOIN090:FILE-NAME <> "inbo/boin090q2.p":U THEN DO:
            RUN inbo/boin090q2.p PERSISTENT SET hDBOIN090.
        END.
        /*--- Verifica se o DBO ja esta inicializado ---*/
        IF NOT VALID-HANDLE(hDBOIN176) OR
           hDBOIN176:TYPE <> "PROCEDURE":U OR
           hDBOIN176:FILE-NAME <> "inbo/boin176q1.p":U THEN DO:
            RUN inbo/boin176q1.p PERSISTENT SET hDBOIN176.
        END.
    
        IF VALID-HANDLE(hDBOIN090) THEN DO:
            RUN setConstraintRowid IN hDBOIN090 (INPUT gr-docum-est) NO-ERROR.
            RUN openQueryStatic    IN hDBOIN090 (INPUT "Rowid":U) NO-ERROR.
            RUN getFirst           IN hDBOIN090.
            IF RETURN-VALUE = "OK":U THEN
                RUN getRecordTMS       IN hDBOIN090 (OUTPUT TABLE tt-docum-est).
            FIND FIRST tt-docum-est NO-ERROR.
        END.
    
        FOR EACH tt-docum-est NO-LOCK:
            IF VALID-HANDLE(hDBOIN090) THEN
                RUN goToKey IN hDBOIN090 (INPUT tt-docum-est.serie-docto,
                                          INPUT tt-docum-est.nro-docto,
                                          INPUT tt-docum-est.cod-emitente,
                                          INPUT tt-docum-est.nat-operacao).
            IF VALID-HANDLE(hDBOIN176) THEN DO:
                RUN setConstraintOfDocumEst IN hDBOIN176 (INPUT tt-docum-est.cod-emitente,
                                                          INPUT tt-docum-est.serie-docto,
                                                          INPUT tt-docum-est.nro-docto,
                                                          INPUT tt-docum-est.nat-operacao).
                RUN openQueryStatic    IN hDBOIN176 (INPUT "OfDocumEst":U) NO-ERROR.
                RUN getBatchRecordsTMS IN hDBOIN176 (OUTPUT TABLE tt-item-doc-est) NO-ERROR.
            END.
        END.
    
    END PROCEDURE.
    &ENDIF
    
    RETURN "OK":U.
    
  5. bootstrapmaster

    bootstrapmaster Membro Master

    Código:
    /********************************************************************************
    ** Copyright DATASUL S.A. (1997)
    ** Todos os Direitos Reservados.
    **
    ** Este fonte e de propriedade exclusiva da DATASUL, sua reproducao
    ** parcial ou total por qualquer meio, so podera ser feita mediante
    ** autorizacao expressa.
    *******************************************************************************/
    {include/i-prgvrs.i CDAPI661 2.00.00.015 } /*** "010015" ***/
    
    &IF "{&EMSFND_VERSION}" >= "1.00"
    &THEN
    {include/i-license-manager.i CDAPI661 MUT}
    &ENDIF
    
    /****************************************************************************
    ***
    *** Testa conexÆo com o banco MGTRP antes de efetuar a integra‡Æo com o TMS
    ***
    ****************************************************************************/
    
    {include/i-epc200.i "cdapi661"} /*Defini‡Æo tt-EPC*/
    
    define input parameter p-ind-event  as character     no-undo.
    define input parameter p-ind-object as character     no-undo.
    define input parameter p-wgh-object as handle        no-undo.
    define input parameter p-wgh-frame  as widget-handle no-undo.
    define input parameter p-cod-table  as character     no-undo.
    define input parameter p-row-table  as rowid         no-undo.
    
    
    
    FIND FIRST funcao WHERE funcao.cd-funcao = "SPP_TOTVSGFE" NO-LOCK NO-ERROR.
    IF  NOT AVAIL funcao OR
        (AVAIL funcao AND funcao.ativo = NO) THEN
        RETURN "ok".
    
    
    {cdp/cdcfgdis.i}
       
    &if '{&bf_dis_versao_ems}' < '2.08' &then
    IF CONNECTED("mgtrp") THEN DO:
        RUN upc/appc-re1001b2.p (input p-ind-event,
                                 input p-ind-object,
                                 input p-wgh-object,
                                 input p-wgh-frame,
                                 input p-cod-table,
                                 input p-row-table).
        IF RETURN-VALUE = "NOK":U THEN
            RETURN "NOK":U.
    END.
    &ELSE
    /**************************** Defini‡Æo de Variaveis **********************************/
    /*Novos campos em tela*/
    DEF NEW GLOBAL SHARED variable wh-rt-tms                AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wgh-lbl-peso-bruto       AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wgh-lbl-peso-cubado      AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wgh-lbl-m3               AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-peso-bruto-re1001b2   AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-peso-cubado-re1001b2  AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-m3-re1001b2           AS widget-handle no-undo.
    
    DEF NEW GLOBAL SHARED variable wh-lbl-peso-liquido      AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-peso-liquido          AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-lbl-frete-const       AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-frete-const           AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-lbl-despesas          AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-despesas              AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-lbl-pedagio           AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-pedagio               AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-rect-12               AS widget-handle no-undo.
    DEF NEW GLOBAL SHARED variable wh-fPage1                AS widget-handle no-undo.
    DEF VARIABLE wgh-grupo                AS HANDLE NO-UNDO.
    DEF VARIABLE wgh-child                AS HANDLE NO-UNDO.
    
    def new global shared VARIABLE gr-docum-est             as ROWID         no-undo.
    
    define variable h-appc-re1001b2                         as handle        no-undo.
    DEFINE VARIABLE l-integrado                             AS LOGICAL       NO-UNDO.
    define variable h-objeto                                AS widget-handle no-undo.
    DEFINE VARIABLE r-rowid                                 AS ROWID         NO-UNDO.
    DEF VAR de-peso-bruto AS DEC NO-UNDO.
    
    {utp/ut-glob.i}
    /*{vfp/vfapi001.i}*/
    {cdp/cdcfgdis.i}
    {cdp/cdapi600.i &Docum-est="YES"
                    &Item-doc-est="YES"}
    
    DEFINE VARIABLE hDBOIN090 AS HANDLE      NO-UNDO.
    DEFINE VARIABLE hDBOIN176 AS HANDLE      NO-UNDO.
    DEFINE VARIABLE h-boin172 AS HANDLE      NO-UNDO.
    
    IF P-ind-event = "BEFORE-DISPLAY" THEN DO:
    
    
        FIND FIRST funcao WHERE funcao.cd-funcao = "SPP_TOTVSGFE" NO-LOCK NO-ERROR.
        IF  NOT AVAIL funcao OR
            (AVAIL funcao AND funcao.ativo = NO) THEN
            RETURN "ok".
    
    
        IF  VALID-HANDLE(wh-peso-bruto-re1001b2) THEN DO:
            RUN pi-inicializa-bos IN THIS-PROCEDURE.
            RUN pi-mostra-tela IN THIS-PROCEDURE.
           
            RUN pi-destroy-handle IN THIS-PROCEDURE.
            RETURN "OK":U.
    
        END.
    
    
        IF NOT VALID-HANDLE(h-appc-re1001b2) THEN
            RUN cdp/cdapi661.p PERSISTENT SET h-appc-re1001b2 (INPUT "",           
                                                               INPUT "",           
                                                               INPUT p-wgh-object, 
                                                               INPUT p-wgh-frame,  
                                                               INPUT "",           
                                                               INPUT p-row-table).
    
        FIND FIRST tab-generica NO-LOCK
             where tab-generica.utilizacao = "setup" NO-ERROR.
        IF AVAIL tab-generica THEN DO:
            IF SUBSTRING(tab-generica.char-2,230,1)  = "Y" THEN DO:
                if valid-handle(h-appc-re1001b2) THEN DO:
                    RUN pi-arruma-tela.
                    run pi-cria-campos-tela. /*  Cria‡Æo dos campos de tela **/
                END.
            END.
        end.
    
        RUN pi-inicializa-bos.
    
        IF  VALID-HANDLE(wh-peso-bruto-re1001b2) AND
            VALID-HANDLE(wh-peso-cubado-re1001b2) AND
            VALID-HANDLE(wh-m3-re1001b2) THEN DO:
    
            ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE  = ""
                   wh-peso-cubado-re1001b2:SCREEN-VALUE = ""
                   wh-m3-re1001b2:SCREEN-VALUE          = "".
        end.
    
        RUN pi-mostra-tela IN THIS-PROCEDURE.
    
        RUN pi-destroy-handle IN THIS-PROCEDURE.
    END.
    
    IF  P-ind-event = "AFTER-ENABLE" THEN DO:
    
        FIND FIRST funcao WHERE funcao.cd-funcao = "SPP_TOTVSGFE" NO-LOCK NO-ERROR.
        IF  NOT AVAIL funcao OR
            (AVAIL funcao AND funcao.ativo = NO) THEN
            RETURN "ok".
    
    
        RUN pi-inicializa-bos.
    
        FIND FIRST tt-item-doc-est
            WHERE tt-item-doc-est.r-rowid = p-row-table NO-LOCK NO-ERROR.
    
        IF  AVAIL tt-item-doc-est
        AND valid-handle(wh-peso-bruto-re1001b2) 
        AND valid-handle(wh-peso-cubado-re1001b2)
        AND VALID-HANDLE(wh-m3-re1001b2)          THEN DO:        
    
            FIND FIRST tab-generica NO-LOCK
                WHERE tab-generica.utilizacao = "item-nfe"
                  AND tab-generica.char-1     = tt-item-doc-est.serie-docto  + ";" + tt-item-doc-est.nro-docto + ";" + STRING(tt-item-doc-est.cod-emitente) + ";" +
                                                tt-item-doc-est.nat-operacao + ";" + STRING(tt-item-doc-est.sequencia) NO-ERROR.
    
            IF  NOT AVAIL tab-generica
            OR  tab-generica.dec-1 = 0 THEN DO:
    
                ASSIGN de-peso-bruto = 0.
                IF  NOT VALID-HANDLE(h-boin172) THEN
                    RUN inbo/boin172.p PERSISTENT SET h-boin172.
                RUN setConstraintItCodigo IN h-boin172 (INPUT tt-item-doc-est.it-codigo).
                RUN openQueryStatic IN h-boin172 (INPUT "ItCodigoInicial":U).
                RUN getDecField IN h-boin172 (INPUT "peso-bruto",
                                              OUTPUT de-peso-bruto).
    
    
                ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE = STRING(tt-item-doc-est.quantidade * de-peso-bruto).
    
            END.
        END.
    
        RUN pi-destroy-handle IN THIS-PROCEDURE.
    
    END.
    
    
    
    /************************************************ PROCEDURES INTERNAS ************************************************/
    PROCEDURE pi-destroy-handle:
        IF  VALID-HANDLE(h-appc-re1001b2) THEN
            DELETE PROCEDURE h-appc-re1001b2.
    
        IF  VALID-HANDLE(h-boin172) THEN
            RUN destroy IN h-boin172.
    
        IF  VALID-HANDLE(hDBOIN176) THEN
            RUN destroy IN hDBOIN176.
    
        IF  VALID-HANDLE(hDBOIN090) THEN
            RUN destroy IN hDBOIN090.
    END PROCEDURE.
    
    PROCEDURE pi-mostra-tela:
    
        FOR EACH tt-item-doc-est
                WHERE tt-item-doc-est.r-rowid = p-row-table NO-LOCK:
                FIND FIRST tab-generica NO-LOCK
                     WHERE tab-generica.utilizacao = "item-nfe"
                       AND tab-generica.char-1     = tt-item-doc-est.serie-docto  + ";" + tt-item-doc-est.nro-docto + ";" + STRING(tt-item-doc-est.cod-emitente) + ";" +
                                                     tt-item-doc-est.nat-operacao + ";" + STRING(tt-item-doc-est.sequencia) NO-ERROR.
       
                IF AVAIL tab-generica           AND
                   valid-handle(wh-peso-bruto-re1001b2)  AND
                   valid-handle(wh-peso-cubado-re1001b2) AND
                   VALID-HANDLE(wh-m3-re1001b2)          THEN DO:
                    ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE  = string(tab-generica.dec-1)
                           wh-peso-cubado-re1001b2:SCREEN-VALUE = string(tab-generica.dec-2)
                           wh-m3-re1001b2:SCREEN-VALUE          = SUBSTRING(tab-generica.char-2,1,6).
    
    
                END.
                ELSE DO:
               
                    IF VALID-HANDLE(wh-peso-bruto-re1001b2) AND
                       VALID-HANDLE(wh-peso-cubado-re1001b2) AND
                       VALID-HANDLE(wh-m3-re1001b2) THEN
                    ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE  = ""
                           wh-peso-cubado-re1001b2:SCREEN-VALUE = ""
                           wh-m3-re1001b2:SCREEN-VALUE          = "".
    
    
                    /* Inicializa peso-bruto */
                    ASSIGN de-peso-bruto = 0.
                    IF  NOT VALID-HANDLE(h-boin172) THEN
                        RUN inbo/boin172.p PERSISTENT SET h-boin172.
                    RUN setConstraintItCodigo IN h-boin172 (INPUT tt-item-doc-est.it-codigo).
                    RUN openQueryStatic IN h-boin172 (INPUT "ItCodigoInicial":U).
                    RUN getDecField IN h-boin172 (INPUT "peso-bruto",
                                                  OUTPUT de-peso-bruto).
       
                    
                    IF VALID-HANDLE(wh-peso-bruto-re1001b2) AND
                       VALID-HANDLE(wh-peso-cubado-re1001b2) AND
                       VALID-HANDLE(wh-m3-re1001b2) THEN
                    ASSIGN wh-peso-bruto-re1001b2:SCREEN-VALUE = STRING(tt-item-doc-est.quantidade * de-peso-bruto).
                END.
            END.
    END PROCEDURE.
    
    PROCEDURE pi-arruma-tela:
    
        assign wgh-grupo = p-wgh-frame:first-child.
        do while valid-handle(wgh-grupo):
           assign  wgh-child = wgh-grupo:first-child.
           do  while valid-handle(wgh-child):
               case wgh-child:type :
                   when "frame" then do:
                       if  wgh-child:name = "fPage1" THEN
                           assign wh-fPage1 = wgh-child:handle.
                   END.
               END CASE.
               assign wgh-child = wgh-child:next-sibling.
           end.
           assign wgh-grupo = wgh-grupo:next-sibling.
        end.
    
        assign wgh-grupo = wh-fPage1:first-child.
        do while valid-handle(wgh-grupo):
           assign  wgh-child = wgh-grupo:first-child.
           do  while valid-handle(wgh-child):
               case wgh-child:type :
                   when "fill-in" then do:
                       if  wgh-child:name = "peso-liquido" THEN
                           assign wh-peso-liquido = wgh-child:handle.
                       if  wgh-child:name = "pr-total-cmi" THEN
                           assign wh-frete-const  = wgh-child:handle.
                       if  wgh-child:name = "despesas" THEN
                           assign wh-despesas     = wgh-child:handle.
                       if  wgh-child:name = "de-valor-pedagio" THEN
                           assign wh-pedagio     = wgh-child:handle.
                  end.
                  when "rectangle" then do:
                      if  wgh-child:name = "rect-12" THEN
                           assign wh-rect-12 = wgh-child:handle.
                  END.
               END CASE.
               assign wgh-child = wgh-child:next-sibling.
           end.
           assign wgh-grupo = wgh-grupo:next-sibling.
        end.
    
        IF VALID-HANDLE(wh-peso-liquido) AND
           valid-handle(wh-frete-const ) AND
           VALID-HANDLE(wh-despesas    ) AND
           VALID-HANDLE(wh-rect-12     ) THEN DO:
    
           IF VALID-HANDLE(wh-pedagio) THEN DO:
    
                ASSIGN wh-lbl-peso-liquido = wh-peso-liquido:SIDE-LABEL-HANDLE
                       wh-lbl-frete-const  = wh-frete-const:SIDE-LABEL-HANDLE
                       wh-lbl-despesas     = wh-despesas:SIDE-LABEL-HANDLE
                       wh-lbl-pedagio     = wh-pedagio:SIDE-LABEL-HANDLE.
    
                ASSIGN wh-lbl-peso-liquido:ROW = 1.5
                       wh-peso-liquido:ROW     = 1.5
                       wh-lbl-frete-const:ROW  = 2.5
                       wh-frete-const:ROW      = 2.5
                       wh-lbl-despesas:ROW     = 3.5
                       wh-despesas:ROW         = 3.5
                       wh-lbl-pedagio:ROW      = 4.5
                       wh-pedagio:ROW          = 4.5
                       wh-rect-12:HEIGHT       = 4.5.
               
           END.
           ELSE DO:
    
                ASSIGN wh-lbl-peso-liquido = wh-peso-liquido:SIDE-LABEL-HANDLE
                       wh-lbl-frete-const  = wh-frete-const:SIDE-LABEL-HANDLE
                       wh-lbl-despesas     = wh-despesas:SIDE-LABEL-HANDLE.
    
                ASSIGN wh-lbl-peso-liquido:ROW = 2
                       wh-peso-liquido:ROW     = 2
                       wh-lbl-frete-const:ROW  = 3
                       wh-frete-const:ROW      = 3
                       wh-lbl-despesas:ROW     = 4
                       wh-despesas:ROW         = 4
                       wh-rect-12:HEIGHT       = 4.5.
    
           END.
    
        END.
    
    END.
    
    procedure pi-cria-campos-tela: /*Cria os campos na tela*/
    
        /*retangulo*/
        CREATE RECTANGLE wh-rt-tms
        ASSIGN FRAME        = wh-fPage1
               SENSITIVE    = NO
               VISIBLE      = YES
               WIDTH-CHARS  = 37
               HEIGHT-CHARS = 5.4
               FILLED       = NO
               EDGE-PIXELS  = 2
               ROW          = 5.8
               COL          = 47.8
               GRAPHIC-EDGE = YES.
    
       /*Labels*/
        CREATE TEXT wgh-lbl-peso-bruto
        assign FRAME        = wh-fPage1
               FORMAT       = "x(12)"
               SCREEN-VALUE = "Peso Bruto:"
               height       = 0.88
               ROW          = 7
               COL          = 53
               VISIBLE      = YES
               font         = 1.
    
        CREATE TEXT wgh-lbl-peso-cubado
        assign FRAME        = wh-fPage1
               FORMAT       = "x(14)"
               SCREEN-VALUE = "Peso Cubado:"
               height       = 0.88
               ROW          = 8
               COL          = 51
               VISIBLE      = YES
               font         = 1.
    
        CREATE TEXT wgh-lbl-m3
        assign FRAME        = wh-fPage1
               FORMAT       = "x(04)"
               SCREEN-VALUE = "M3:"
               height       = 0.88
               ROW          = 9
               COL          = 58
               VISIBLE      = YES
               font         = 1.  
    
        FIND FIRST tab-generica NO-LOCK
             WHERE tab-generica.utilizacao = "SETUP":U NO-ERROR.
        IF AVAIL tab-generica THEN DO:
    
            /*Fill-in*/
            create fill-in wh-peso-bruto-re1001b2
            assign frame          = wh-fPage1
                side-label-handle = wgh-lbl-peso-bruto:handle
                data-type         = 'decimal'
                format            = '>>>>>,>>9.99999'
                width             = 16
                height            = 0.88
                row               = 7
                col               = 61
                visible           = yes
                sensitive         = IF SUBSTRING(tab-generica.char-2,15,1) = "1" THEN YES ELSE NO
                font              = 1.
               
            create fill-in wh-peso-cubado-re1001b2
            assign frame             = wh-fPage1
                   side-label-handle = wgh-lbl-peso-cubado:handle
                   data-type         = 'decimal'
                   format            = '>>>>,>>9.99999'
                   width             = 16
                   height            = 0.88
                   row               = 8
                   col               = 61
                   visible           = yes
                   sensitive         = IF SUBSTRING(tab-generica.char-2,15,1) = "1" THEN YES ELSE NO
                   font              = 1.
           
            create fill-in wh-m3-re1001b2
            assign frame             = wh-fPage1
                   side-label-handle = wgh-lbl-m3:handle
                   data-type         = 'decimal'
                   format            = '>>9.999'
                   width             = 16
                   height            = 0.88
                   row               = 9
                   col               = 61
                   visible           = YES
                   sensitive         = IF SUBSTRING(tab-generica.char-2,15,1) = "1" THEN YES ELSE NO
                   font              = 1.
    
        END.
    end.
    
    
    PROCEDURE pi-inicializa-bos:
    
        /*--- Verifica se o DBO ja esta inicializado ---*/
        IF NOT VALID-HANDLE(hDBOIN090) OR
            hDBOIN090:TYPE <> "PROCEDURE":U OR
            hDBOIN090:FILE-NAME <> "inbo/boin090q2.p":U THEN DO:
            RUN inbo/boin090q2.p PERSISTENT SET hDBOIN090.
        END.
        /*--- Verifica se o DBO ja esta inicializado ---*/
        IF NOT VALID-HANDLE(hDBOIN176) OR
           hDBOIN176:TYPE <> "PROCEDURE":U OR
           hDBOIN176:FILE-NAME <> "inbo/boin176q1.p":U THEN DO:
            RUN inbo/boin176q1.p PERSISTENT SET hDBOIN176.
        END.
    
        IF VALID-HANDLE(hDBOIN090) THEN DO:
            RUN setConstraintRowid IN hDBOIN090 (INPUT gr-docum-est) NO-ERROR.
            RUN openQueryStatic    IN hDBOIN090 (INPUT "Rowid":U) NO-ERROR.
            RUN getFirst           IN hDBOIN090.
            IF RETURN-VALUE = "OK":U THEN
                RUN getRecordTMS       IN hDBOIN090 (OUTPUT TABLE tt-docum-est).
            FIND FIRST tt-docum-est NO-ERROR.
        END.
    
        FOR EACH tt-docum-est NO-LOCK:
            IF VALID-HANDLE(hDBOIN090) THEN
                RUN goToKey IN hDBOIN090 (INPUT tt-docum-est.serie-docto,
                                          INPUT tt-docum-est.nro-docto,
                                          INPUT tt-docum-est.cod-emitente,
                                          INPUT tt-docum-est.nat-operacao).
            IF VALID-HANDLE(hDBOIN176) THEN DO:
                RUN setConstraintOfDocumEst IN hDBOIN176 (INPUT tt-docum-est.cod-emitente,
                                                          INPUT tt-docum-est.serie-docto,
                                                          INPUT tt-docum-est.nro-docto,
                                                          INPUT tt-docum-est.nat-operacao).
                RUN openQueryStatic    IN hDBOIN176 (INPUT "OfDocumEst":U) NO-ERROR.
                RUN getBatchRecordsTMS IN hDBOIN176 (OUTPUT TABLE tt-item-doc-est) NO-ERROR.
            END.
        END.
    
    END PROCEDURE.
    &ENDIF
    
    RETURN "OK":U.
    
  6. rodolfo.rcs

    rodolfo.rcs Membro Participativo

    Valeu Richard.

    Vou estudar uma forma de ratear o peso bruto do cabeçalho para os itens das notas.

    Obrigado!

Compartilhe esta Página