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

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[RESOLVIDO] Integração emitente EMS2 com EMS5

Discussão em 'EMS , HCM e Totvs 11' iniciado por ivodarocha, Agosto 13, 2014.

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

    ivodarocha Membro Participativo

    Boa tarde!

    Alguém teria algum exemplo de como alterar um cliente no EMS2 via progress e faze-lo integrar ao EMS5?
    Meu propósito é alterar um determinado campo dos clientes em lote.


    Obrigado
  2. pizzaia

    pizzaia Membro Participativo

    ola´
    eu uso uma api porém ele atualiza apenas a tabela de emitente e não valida 100%. tem que inputar corretamente a informação.

    Código:
    {adbo/boad098.i tt-emitente no-undo}
    {include/boerrtab.i}
    
    DEF VAR r-chave AS ROWID NO-UNDO.
    DEFINE VARIABLE hDBOad098 AS HANDLE NO-UNDO. /* emitente */
    
    for FIRST emitente
        no-lock:
    
        empty temp-table tt-emitente.
    
        CREATE tt-emitente.
        BUFFER-COPY emitente TO tt-emitente.
        /* alterar o campo necessário - lembre de fazer as validações necessárias */
        assign tt-emitente.nome-emit = 'xxxx' .
    
    
        /* atualização no ems2 */
        assign r-chave = ROWID(emitente).
        empty temp-table tt-bo-erro.
        RUN validateupdate IN hDBOad098 (INPUT TABLE tt-emitente,
                                         INPUT r-chave,
                                         OUTPUT TABLE tt-bo-erro).
    
        /* seu tratamento de erro, caso a tt-bo-erro tenha algum registro */
        FOR FIRST tt-bo-erro
            NO-LOCK :
            run gravaMsg ('E'
                   , tt-emitente.cod-emitente
                   , tt-emitente.nome-emit
                   , 'Erro ao Atualizar Emitente'
                   , tt-bo-erro.mensagem ).
        END.
        IF NOT AVAILABLE tt-bo-erro then do:
            run gravaMsg ('A'
                     ,tt-emitente.cod-emitente
                     ,tt-emitente.nome-emit
                     ,'Emitente Atualizado'
                     ,'' ).
    
        end.
    
        /* atualizar ems5 */
        IF can-find(funcao where funcao.cd-funcao = "adm-cdc-ems-5.00"
                           and   funcao.ativo     = YES
                           and   funcao.log-1     = YES ) then do:
            /*
            int iEmitIni,
            int iEmitFim,
            int iIdentific,
            boolean lAtualiza,  ---> vai atualizar ?
            int iOperac,        ---> tipo de operação 1=inclusão/alteracao 2=exclusao
            int iSequencia,     ---> se diferente 0 então ioperacao = 1
            String cFilename,   ---> nome arquivo
            String cCaminho,    ---> arquivo não sabe,
            String cNome)       ---> nao utilizado
            */
            run cdp/cd1608.p (input tt-emitente.cod-emitente,
                              input tt-emitente.cod-emitente,
                              input tt-emitente.identific,
                              input YES,
                              input 1,
                              input 0,
                              input "utb765zb.tmp",
                              input "Arquivo":U,
                              input "").
    
            /* seu tratamento de erro, no caso testei se o cliente está no ems5, o erro fica no arquivo
            utb765zb.tmp */
            FIND FIRST ems5cad.cliente
                 WHERE ems5cad.cliente.cdn_cliente = tt-emitente.cod-emitente
                 NO-LOCK NO-ERROR.
    
            IF NOT AVAILABLE ems5cad.cliente THEN
                run gravaMsg ('E'
                             ,tt-emitente.cod-emitente
                             ,tt-emitente.nome-emit
                             ,'Erro na atualização do EMS5'
                             ,'' ).
    
        END.
    
    END. /* loop emitente */
    
  3. ivodarocha

    ivodarocha Membro Participativo

    @pizzaia
    Acredito que as validações são suficientes, porem não localizei esta BO boad098.i
    Você teria?

    Obrigado
  4. pizzaia

    pizzaia Membro Participativo

    opa. segue o conteúdo dela.

    Código:
    DEFINE TEMP-TABLE {1} like emitente
        field r-rowid  as rowid.
  5. pizzaia

    pizzaia Membro Participativo

    cuide com os dados, pois em testes que fiz, eu alterei a micro-região informando uma que não existe e a bo gravou assim mesmo.

    não sei se é algo que esqueçi de fazer, mas na forma que estou utilizando aconteceu isso.

    t+
    Eberson Pizzaia
  6. ivodarocha

    ivodarocha Membro Participativo

    Fiz da seguinte forma e funcionou, porem tenho integração com o AGENT (CRM) e não sei como tratar isso. Quando fazemos alterações nos emitente, automaticamente marca o registo para ser integrado mas não sei como.


    {include/tt-edit.i}
    {include/pi-edit.i}

    DEFINE VARIABLE c-arquivo AS CHARACTER NO-UNDO.
    DEFINE VARIABLE r-chave AS ROWID NO-UNDO.
    DEFINE VARIABLE hDBOad098 AS HANDLE NO-UNDO. /* MGCAD.emitente */

    ASSIGN c-arquivo = SESSION:TEMP-DIRECTORY + "IMP-EMITENTES.COD-REP.lst".

    def temp-table tt-emitente
    field cod-emitente like MGCAD.emitente.cod-emitente
    field cod-rep like MGCAD.emitente.cod-rep.

    def temp-table tt-erros
    FIELD cod-emitente LIKE MGCAD.emitente.cod-emitente
    field cod-rep-a like MGCAD.emitente.cod-rep
    field cod-rep-d like MGCAD.emitente.cod-rep
    field erro as char format "x(30)" label "Mensagem".

    def temp-table tt-raw-digita
    field raw-digita as raw.

    /* definicao de variaveis */
    DEFINE VARIABLE h-acomp AS HANDLE NO-UNDO.
    DEFINE VARIABLE cont AS INTEGER.
    DEFINE VARIABLE cont1 AS INTEGER.
    DEFINE VARIABLE cont2 AS INTEGER.
    DEFINE VARIABLE cont3 AS INTEGER.
    DEFINE VARIABLE c-dados AS CHARACTER FORMAT "x(100)".
    /*--|| CHARACTER */

    Run utp/ut-acomp.p persistent set h-acomp.
    Run pi-inicializar In h-acomp (Input "Importação").
    Run pi-seta-tipo In h-acomp (Input 6).


    RUN pi_Importacao.

    RUN pi-finalizar IN h-acomp.

    PROCEDURE pi_Importacao:
    INPUT FROM C:\temp\emitentes-rep.CSV.
    REPEAT WHILE TRUE:
    CREATE tt-emitente.
    IMPORT DELIMITER ";" tt-emitente.
    ASSIGN cont = cont + 1.
    END.
    INPUT CLOSE.


    FOR EACH tt-emitente WHERE
    tt-emitente.cod-emitente > 0.

    FIND repres WHERE repres.cod-rep = tt-emitente.cod-rep NO-ERROR.
    IF NOT AVAIL repres THEN DO:
    CREATE tt-erros.
    ASSIGN tt-erros.cod-emitente = tt-emitente.cod-emitente
    tt-erros.cod-rep-a = tt-emitente.cod-rep
    tt-erros.cod-rep-d = tt-emitente.cod-rep
    tt-erros.erro = "Representante não localizado".
    NEXT.
    END.

    FIND MGCAD.emitente WHERE MGCAD.emitente.cod-emitente = tt-emitente.cod-emitente NO-ERROR.
    IF NOT AVAIL MGCAD.emitente THEN DO:
    CREATE tt-erros.
    ASSIGN tt-erros.cod-emitente = tt-emitente.cod-emitente
    tt-erros.cod-rep-a = tt-emitente.cod-rep
    tt-erros.cod-rep-d = tt-emitente.cod-rep
    tt-erros.erro = "Emitente não localizado".
    NEXT.
    END.
    ELSE DO:
    CREATE tt-erros.
    ASSIGN tt-erros.cod-emitente = tt-emitente.cod-emitente
    tt-erros.cod-rep-a = MGCAD.emitente.cod-rep
    tt-erros.cod-rep-d = tt-emitente.cod-rep
    tt-erros.erro = "Emitente atualizado".

    ASSIGN MGCAD.emitente.cod-rep = tt-emitente.cod-rep.

    IF can-find(funcao where funcao.cd-funcao = "adm-cdc-ems-5.00"
    and funcao.ativo = YES
    and funcao.log-1 = YES ) then do:

    RUN cdp/cd1608.p (INPUT MGCAD.emitente.cod-emitente,
    INPUT MGCAD.emitente.cod-emitente,
    INPUT MGCAD.emitente.identific,
    INPUT YES,
    INPUT 1,
    INPUT 0,
    INPUT c-arquivo,
    INPUT "Arquivo":U,
    INPUT "").

    END.

    run pi-acompanhar in h-acomp (input "Emitente : " + MGCAD.emitente.nome-abrev).

    END.

    END.

    /*--|| LOG DE ERROS */
    OUTPUT TO c:/temp/Emitentes-Alterados-log.csv.
    EXPORT DELIMITER ";" "Emitente" "Representante Antes" "Representante Depois" "Mensagem".
    FOR EACH tt-erros:
    EXPORT DELIMITER ";"
    tt-erros.cod-emitente
    tt-erros.cod-rep-a
    tt-erros.cod-rep-d
    tt-erros.erro.
    END.


    END PROCEDURE.
Status do Tópico:
Não esta aberto para novas mensagens.

Compartilhe esta Página