[RESOLVIDO] upc cp0320b

Discussão em 'EMS , HCM e Totvs 11' iniciado por mpdelphi, Fevereiro 5, 2015.

Status do Tópico:
Não esta aberto para novas mensagens.
  1. mpdelphi

    mpdelphi Membro Participativo

    Boa tarde...


    preciso criar um upc na tela cp0320b (manutenção baixa reservas), em que se o usuario escolher um lote de materia prima que nao esteja numa regra especifica... eu consiga dar um return NOK, algum ja fez algo parecido.... ?!
  2. bootstrapmaster

    bootstrapmaster Moderator Moderador Equipe de Suporte

    Eu tenho essa aqui que trata linha por linha para que o usuario só escolha os lotes pre-selecionados em uma tabela especifica, acho que vc pode partir daqui e ver o que faz.
    Código:
    &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v9r12
    &ANALYZE-RESUME
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
    /*------------------------------------------------------------------------
            ---------------------------------------------------------
                ######  ######  ######  ##  ##  ###### ######  ######
               ##  ##    ##    ##      ### ##  ##     ##  ##  ##  ##
              ######    ##    ####    ## ###  ##     ######  ##  ##
             ##  ##    ##    ##      ##  ##  ##     ##  ##  ##  ##
            ##  ##    ##    ######  ##   #  ###### ##  ##  ######
            ---------------------------------------------------------
                    ESTE FONTE DEVE SER EDITADO NO APPBUILDER
            ---------------------------------------------------------
           
       File        : upc-cd0111.p
       Purpose     : Criar um folder novo e instanciar uma viewer
       Author(s)   : Richard Edgar - Imesul
       Created     : 27/03/2012
       Notes       :
       ----------------------------------------------------------------------*/
    
    /* ***************************  Definitions  ************************** */
    
    def input parameter p-ind-event     as character     no-undo.
    def input parameter p-ind-object    as character     no-undo.
    def input parameter p-wgh-object    as handle        no-undo.
    def input parameter p-wgh-frame     as widget-handle no-undo.
    def input parameter p-cod-table     as character     no-undo.
    def input parameter p-row-table     as rowid         no-undo.
    
    define variable c-objeto            as character     no-undo.
    
    /* Global Variable Definitions **********************************************/
    define new global shared var adm-broker-hdl as handle    no-undo.
    define new global shared var h-folder       as handle    no-undo.
    define new global shared var h-viewer       as handle    no-undo.
                                                            
    define variable i-objects                   as integer   no-undo.
    define variable h-object                    as handle    no-undo.
    define variable l-record                    as logical   no-undo.
    define variable l-group-assign              as logical   no-undo.
    
    
    define var c-folder                         as character no-undo.
    define var c-objects                        as character no-undo.
    
    define variable codDepos  as handle no-undo.
    define variable loteSerie as handle no-undo.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
    
    /* ********************  Preprocessor Definitions  ******************** */
    
    &Scoped-define PROCEDURE-TYPE Procedure
    &Scoped-define DB-AWARE no
    
    
    
    /* _UIB-PREPROCESSOR-BLOCK-END */
    &ANALYZE-RESUME
    
    
    
    /* *********************** Procedure Settings ************************ */
    
    &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
    /* Settings for THIS-PROCEDURE
       Type: Procedure
       Allow:
       Frames: 0
       Add Fields to: Neither
       Other Settings: CODE-ONLY
    */
    &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
    
    /* *************************  Create Window  ************************** */
    
    &ANALYZE-SUSPEND _CREATE-WINDOW
    /* DESIGN Window definition (used by the UIB)
      CREATE WINDOW Procedure ASSIGN
             HEIGHT             = 10.13
             WIDTH              = 29.14.
    /* END WINDOW DEFINITION */
                                                                            */
    &ANALYZE-RESUME
    
    
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
    
    
    /* ***************************  Main Block  *************************** */
    
        assign c-objeto = entry(num-entries(p-wgh-object:private-data, "~/"), p-wgh-object:private-data, "~/").
       
    /* message "Evento........: " p-ind-event         skip */
    /*         "Objeto........: " p-ind-object        skip */
    /*         "Nome objeto ..: " c-objeto            skip */
    /*         "Handle Objeto.: " p-wgh-object        skip */
    /*         "Frame.........: " p-wgh-frame         skip */
    /*         "Tabela........: " p-cod-table         skip */
    /*         "Rowid.........: " string(p-row-table) skip */
    /*         view-as alert-box info buttons ok.          */
    
        for first reservas no-lock
            where rowid(reservas) = p-row-table:
    
            for each cst_ordens_plano_item no-lock
                where cst_ordens_plano_item.nr-ord-produ = reservas.nr-ord-produ
                ,
                first cst_ordens_plano of cst_ordens_plano_item no-lock
                where cst_ordens_plano.it-codigo = reservas.it-codigo
                  and cst_ordens_plano.estado <> 'Encerrada':
    
                run utils/findWidget.p('cod-depos' ,'fill-in',p-wgh-frame, output codDepos).
                run utils/findWidget.p('lote-serie','fill-in',p-wgh-frame, output loteSerie).
    
                if valid-handle(codDepos)  then assign codDepos:sensitive  = no.
                if valid-handle(loteSerie) then assign loteSerie:sensitive = no
                                                       loteSerie:screen-value = cst_ordens_plano.lote.
    
            end.
        end.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
  3. bootstrapmaster

    bootstrapmaster Moderator Moderador Equipe de Suporte

    Essa aqui faz mais o que vc quer, ela testa o codigo do item, então é só trocar o teste.
    Código:
        def input param p-ind-event                   as char             no-undo.
        def input param p-ind-object                  as char             no-undo.
        def input param p-wgh-object                  as handle           no-undo.
        def input param p-wgh-frame                   as widget-handle    no-undo.
        def input param p-cod-table                   as char             no-undo.
        def input param p-row-table                   as rowid            no-undo.   
    
        /******************** Definicao de Variaveis Locais **********************/
    
        define variable c-char            as character   no-undo.
        define variable quantOrig         as handle      no-undo.
        define variable itemPai           as handle      no-undo.
                                         
        define variable estado            as handle      no-undo.
                                         
        define variable percentual        as decimal     no-undo.
        define variable diferenca         as decimal     no-undo.
        define variable quantidadeTeorica as decimal     no-undo.
    
        define buffer bf_reservas for reservas.
    
        DEF VAR h-objeto AS HANDLE.
    
        {utp/ut-glob.i}
    
        /************************** Inicio do Programa ***************************/
    
        assign c-char = entry(num-entries(p-wgh-object:file-name,"~/"), p-wgh-object:file-name,"~/") no-error.
        def var c-objeto  as character    no-undo.
        assign c-objeto = entry(num-entries(p-wgh-object:private-data, "~/"),
                                            p-wgh-object:private-data, "~/").
       
    /*     message "EVENTO" p-ind-event skip                                       */
    /*             "OBJETO" p-ind-object skip                                      */
    /*             "NOME OBJ" c-objeto skip                                        */
    /*             "FRAME" p-wgh-frame skip                                        */
    /*             "TABELA" p-cod-table skip                                       */
    /*             "ROWID" string(p-row-table) view-as alert-box.                . */
    
        if p-ind-object = 'Viewer' then do:
            case p-ind-event:
                when 'after-enable' then do:
                    find first usuar_grp_usuar no-lock
                         where usuar_grp_usuar.cod_usuario   = c-seg-usuario
                           and usuar_grp_usuar.cod_grp_usuar = 'SCP'
                               no-error.
    
                    if not avail usuar_grp_usuar then do:
                        run utils/findWidget.p ('estado':u,
                                                'radio-set':u,
                                                p-wgh-frame,
                                                output estado).
                        if valid-handle(estado) then
                            assign estado:sensitive = false.
                    end.
                end.
                when 'after-end-update' then do:
                    find first usuar_grp_usuar no-lock
                         where usuar_grp_usuar.cod_usuario   = c-seg-usuario
                           and usuar_grp_usuar.cod_grp_usuar = 'SCP'
                               no-error.
    
                    if not avail usuar_grp_usuar then do:
    
                        find first bf_reservas no-lock
                             where rowid(bf_reservas) = p-row-table
                                   no-error.
    
                        if avail bf_reservas then do:
                            for first ord-prod of bf_reservas no-lock:
                                find first estrutura no-lock
                                     where estrutura.it-codigo = bf_reservas.item-pai
                                       and estrutura.es-codigo = bf_reservas.it-codigo
                                           no-error.
    
                                if not avail estrutura then do:
                                    run utp/ut-msgs.p('show':u,
                                                      17006,
                                                      'Erro digita‡Æo item reservas' +
                                                      '~~':u +
                                                      substitute('item &1 informado nÆo pertence a estrutura do item &2',
                                                                 bf_reservas.it-codigo, bf_reservas.item-pai)
    
                                                      ).
                                    find first bf_reservas exclusive-lock
                                         where rowid(bf_reservas) = p-row-table
                                               no-error.
                                    if avail bf_reservas then do:
                                        delete bf_reservas no-error.
                                    end.
                                    return 'nok'.
                                end.
    
                                assign quantidadeTeorica = estrutura.quant-usada * ord-prod.qt-ordem.
    
                                assign diferenca = bf_reservas.quant-orig - quantidadeTeorica.
                                assign percentual = (diferenca / quantidadeTeorica) * 100.
    
    
                                for first item no-lock
                                    where item.it-codigo = bf_reservas.it-codigo
                                    ,
                                    first grup-estoque of item no-lock:
    
                                    if percentual > grup-estoque.dec-2          or
                                       percentual < (grup-estoque.dec-1 * (-1)) then do:
                                        run utp/ut-msgs.p('show':u,
                                                          17006,
                                                          'Erro digita‡Æo quantidade Original' +
                                                          '~~':u +
                                                          substitute('Quantidade &1 informada est  fora dos limites permitidos em &2%',
                                                                     bf_reservas.quant-orig, percentual * 100)
                                                          ).
                                        find first bf_reservas exclusive-lock
                                             where rowid(bf_reservas) = p-row-table
                                                   no-error.
                                        if avail bf_reservas then do:
                                            delete bf_reservas no-error.
                                        end.
                                        return 'nok'.
                                    end.
                                end.
                            end.
                        end.
                    end.
                end.
                when 'Validate'     then do:
    
                    find first usuar_grp_usuar no-lock
                         where usuar_grp_usuar.cod_usuario   = c-seg-usuario
                           and usuar_grp_usuar.cod_grp_usuar = 'SCP'
                               no-error.
    
                    if not avail usuar_grp_usuar then do:
                        run utils/findWidget.p ('quant-orig':u,
                                                'fill-in':u,
                                                p-wgh-frame,
                                                output quantOrig).
    
                        if valid-handle(quantOrig) then do:
                            find first bf_reservas no-lock
                                 where rowid(bf_reservas) = p-row-table
                                       no-error.
    
                            if avail bf_reservas then do:
                                assign diferenca = quantOrig:input-value - bf_reservas.quant-orig.
                                assign percentual = (diferenca / bf_reservas.quant-orig) * 100.
    
                                for first item no-lock
                                    where item.it-codigo = bf_reservas.it-codigo
                                    ,
                                    first grup-estoque of item no-lock:
    
                                    if percentual > grup-estoque.dec-2          or
                                       percentual < (grup-estoque.dec-1 * (-1)) then do:
                                        run utp/ut-msgs.p('show':u,
                                                          17006,
                                                          'Erro digita‡Æo quantidade Original' +
                                                          '~~':u +
                                                          substitute('Quantidade &1 informada est  fora dos limites permitidos em &2%',
                                                                     quantOrig:screen-value, grup-estoque.dec-2)
                                                                 
                                                          ).
                                        return 'nok'.
                                    end.
                                end.
                            end.
                        end.
                    end.
                end.
            end case.
        end.
    
  4. mpdelphi

    mpdelphi Membro Participativo

    Obrigado pelo retorno.... essa upc vc ta cadastrando no cp0320b ou em alguma outro programa?, pq no cp0320b eu nao tinha achando o evento Validate..

  5. bootstrapmaster

    bootstrapmaster Moderator Moderador Equipe de Suporte

    é no cp0320b mesmo.
  6. bootstrapmaster

    bootstrapmaster Moderator Moderador Equipe de Suporte

    Meu caro, me perdoa, te passei a upc para o cp0302b e não cp0320b, pro cp0320b eu não tenho upc, me perdoa mesmo.
    mpdelphi curtiu isso.
Status do Tópico:
Não esta aberto para novas mensagens.

Compartilhe esta Página