[RESOLVIDO] epc boin176

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

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

    mpdelphi Membro Participativo

    Bom dia...

    Ao entrar com uma nf que envolve beneficamento, quando escolho a ordem de compra via fifo o sistema alimenta o campo Ordem de Producao, com o mesmo numero da ordem de produção que estra atrelada à ordem de compra.

    Por uma necessidade interna, preciso modificar o valor deste campo, colocando outro nr de ordem de produção de acordo com minha necessidade.

    Porem preciso mudar isso, antes de API fazer as devidas validações.

    Alguem tem algum exemplo de EPC para essa BO onde vc modifica o valor de algum campo, para servir como guia para mim ?
  2. lhp.s

    lhp.s Membro Participativo

    Oi Marcos, bom dia.
    é no item-doc-est?
  3. lhp.s

    lhp.s Membro Participativo

    Código:
    if p-ind-event = "beforeCreateRecord":U or
       p-ind-event = "beforeUpdateRecord":U then do:
        for first tt-epc no-lock where
                  tt-epc.cod-event     = p-ind-event and
                  tt-epc.cod-parameter = "object-handle":
            h-boin176 = widget-handle(tt-epc.val-parameter).
            if valid-handle(h-boin176) then do:
                run getRecord in h-boin176(output table tt-item-doc-est).
    
                for first tt-item-doc-est no-lock,
                    first item no-lock where
                          item.it-codigo = tt-item-doc-est.it-codigo:
                    find first docum-est of tt-item-doc-est no-lock no-error.
                    if available docum-est then do:
                        find first cst_natur-oper no-lock where
                                   cst_natur-oper.nat-operacao = docum-est.nat-operacao and
                                   cst_natur-oper.entrega-futura
                                   no-error.
                        if available cst_natur-oper then do:
                            if cst_natur-oper.controle-ef = 1 and    /*1-Faturamento, 2=Remessa */
                               item.tipo-contr <> 4 then do:
                                run createError("Natureza de opera‡Æo do documento ‚ de entrega futura (faturamento). " +
                                                "Informe um item de DBITO DIRETO!").
                                return.
                            end.
    
                            if index(program-name(4),"re1001b1.w") > 0 or
                               index(program-name(4),"re1001b2.w") > 0 then do:
                                run emptyRecord.
                                run loadRecord(cst_natur-oper.controle-ef).
                                run digitRecord(cst_natur-oper.controle-ef).
                                run saveRecord(cst_natur-oper.controle-ef).
    
                                for each rowErrors:
                                    run createError(rowErrors.errorDescription).
                                end.
                            end.
                        end.
                    end.
                end.
            end.
        end.
    end.
    
    if p-ind-event = "EndValidateRecord":U then do:
        for first tt-epc no-lock where
                  tt-epc.cod-event     = p-ind-event and
                  tt-epc.cod-parameter = "object-handle":
            h-boin176 = widget-handle(tt-epc.val-parameter).
    
            if valid-handle(h-boin176) then do:
                run getRecord in h-boin176(output table tt-item-doc-est).
    
                find first tt-item-doc-est no-error.
                if available tt-item-doc-est then do:
                    find first docum-est of tt-item-doc-est no-lock no-error.
    
                    find first cst_natur-oper no-lock where
                               cst_natur-oper.nat-operacao = tt-item-doc-est.nat-operacao and
                               cst_natur-oper.entrega-futura and
                               cst_natur-oper.controle-ef  = 1
                               no-error.
    
                    if available docum-est and
                       available cst_natur-oper then do:
                        if index(program-name(6),"re1001b1.w") > 0 or
                           index(program-name(6),"re1001b2.w") > 0 then do:
                            find first cst_estab-mat no-lock where
                                       cst_estab-mat.cod-estabel = docum-est.cod-estabel
                                       no-error.
                            if available cst_estab-mat then do:
                                assign tt-item-doc-est.conta-contabil = replace(cst_estab-mat.conta-ef,".","")
                                       tt-item-doc-est.ct-codigo      = cst_estab-mat.ct-ef
                                       tt-item-doc-est.sc-codigo      = cst_estab-mat.sc-ef.
                                find current tt-item-doc-est no-lock no-error.
    
                                if valid-handle(h-boin176) then do:
                                    run getRowErrors in h-boin176(output table rowErrors).
    
                                    run emptyRowErrors in h-boin176.
    
                                    for each rowErrors where
                                             RowErrors.ErrorNumber <> 6726:
                                        run _insertErrorManual IN h-boin176(RowErrors.errorNumber,
                                                                            RowErrors.ErrorType,
                                                                            RowErrors.ErrorSubtype,
                                                                            RowErrors.errorDescription,
                                                                            RowErrors.errorHelp,
                                                                            "":U).             
                                    end.
                                end.
                            end.
                        end.
                    end.
                end.
            end.
        end.
    end.
    
    if p-ind-event = "afterCreateRecord":U or
       p-ind-event = "afterUpdateRecord":U then do:
        for first tt-epc no-lock where
                  tt-epc.cod-event     = p-ind-event and
                  tt-epc.cod-parameter = "table-rowid":
            find first item-doc-est no-lock where
                       rowid(item-doc-est) = to-rowid(tt-epc.val-parameter)
                       no-error.
            if available item-doc-est then do:
                find first docum-est of item-doc-est no-lock no-error.
                if available docum-est then do:
                    find first cst_natur-oper no-lock where
                               cst_natur-oper.nat-operacao = docum-est.nat-operacao and
                               cst_natur-oper.entrega-futura
                               no-error.
                    if available cst_natur-oper then do:
                        if index(program-name(4),"re1001b1.w") > 0 or
                           index(program-name(4),"re1001b2.w") > 0 then do:
                            find first cst_estab-mat no-lock where
                                       cst_estab-mat.cod-estabel = docum-est.cod-estabel
                                       no-error.
                            if available cst_estab-mat then do:
                                if cst_natur-oper.controle-ef = 1 then do:
                                    find current item-doc-est exclusive-lock no-error.
                                    assign item-doc-est.conta-contabil = replace(cst_estab-mat.conta-ef,".","")
                                           item-doc-est.ct-codigo      = cst_estab-mat.ct-ef
                                           item-doc-est.sc-codigo      = cst_estab-mat.sc-ef.
                                    find current item-doc-est no-lock no-error.
                                end.
                                else do:
                                    find current docum-est exclusive-lock no-error.
                                    assign docum-est.conta-trans = replace(cst_estab-mat.conta-ef,".","")
                                           docum-est.ct-trans    = cst_estab-mat.ct-ef
                                           docum-est.sc-trans    = cst_estab-mat.sc-ef.
                                    find current docum-est no-lock no-error.
                                end.
                            end.
                        end.
                    end.
                end.
            end.
        end.
    end.
    mpdelphi curtiu isso.
  4. mpdelphi

    mpdelphi Membro Participativo

  5. lhp.s

    lhp.s Membro Participativo

    o esquema está em

    [LER] run getRecord in h-boin176(output table tt-item-doc-est).
    [GRAVAR] run setRecord in h-boin176(output table tt-item-doc-est).
Status do Tópico:
Não esta aberto para novas mensagens.

Compartilhe esta Página