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] Rateio Valores APB (Implantacao Titulos)

Discussão em 'EMS , HCM e Totvs 11' iniciado por lhp.s, Novembro 11, 2010.

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

    lhp.s Membro Participativo

    Oi senhores, boa tarde.

    Estou com uma situaçao aqui um tanto chata.

    Fiz um programa para importar titulos no APB. O titulo está indo para o lote ficando pedente.
    Tá tudo certinho, capa do lote, itens belezinha. Porém ao consultar o rateio de valores,
    o tipo de fluxo e cta ctbl nao aparecem. E dessa forma nao consigo atualizar a referencia.
    Outros dados, como unidade de negocio, plano de ctas sao atualizados...apenas fluxo e cta ctbl q nao....

    Antes de executar a api, faço um message com as informaçoes da temp-table ( tt_integr_apb_aprop_ctbl_pend)
    e os dados (fluxo e cta ) estao ok.
    Nao estou usando a matriz na API, faço o DE-PARA antes, alimentando a tt com meus dados reais do ems5., e
    estes (fluxo e ct) estão cadastrados de acordo.

    Que será q estou fazendo de errado?

    Código:
    
    def new global shared var v_log_atualiza_refer_apb as logical initial yes no-undo.
    define temp-table titulo-apb
      field estab as char
      field espec as char
      field serie as char
      field docto as char
      field parc  as char
      field forne as int
      field refer as char
      field emiss as date
      field venct as date
      field saldo as dec
      field despe as int
      field port  as int
      field modal as int.
    {c:\clientes\cliente\apb\apb.i}
    /************************************************************************************************************/
    
    def var inumSeq  as int no-undo.
    def var v_hdl_aux as handle no-undo.
    
    run carregaTable.
    
    output to "c:\clientes\cliente\apb\erro-apb.txt".
    
    for first titulo-apb where
      titulo-apb.estab <> "" break by
      titulo-apb.refer :
    
      if first-of(titulo-apb.refer)
      then do: 
          run piLimpaTabelas.
          run createLote.
          assign inumSeq = 10.
      end.
    
    
       find first tt_integr_apb_lote_impl no-lock no-error.   
       run createItens.
    
       find first  tt_integr_apb_item_lote_impl3v no-lock no-error. 
       run createAprop.
     
       if last-of(titulo-apb.refer)
       then do: 
           assign v_log_atualiza_refer_apb = false.
           find first tt_integr_apb_aprop_ctbl_pend no-lock no-error.
               
           display tt_integr_apb_lote_impl    
           with width 300 stream-io down.
               
           run piLiberaTabelas.
           run prgfin/apb/apb900zg.py persistent set v_hdl_aux.
    
           run pi_main_block_api_tit_ap_cria_4 in v_hdl_aux (Input 5,
                                         Input 'MTZ-001',
                                         input-output table tt_integr_apb_item_lote_impl3v).
                                                
           disp titulo-apb
           with width 300 stream-io down.
       end.
       
       for each  tt_log_erros_atualiz:
        disp ttv_des_msg_erro skip
             ttv_des_msg_ajuda skip(1).
       end.
       
    end.
    
    output close.
    
    
    procedure createAprop.
        define variable conta_ as char no-undo.
        define variable fluxo_ as char no-undo.
    
        run buscaFluxoFinanc(input string(titulo-apb.desp), output fluxo_).
        
        for first emitente where
          cod-emitente = titulo-apb.forn no-lock.
        end.
        
        assign fluxo_ = "205104".
    
        create tt_integr_apb_aprop_ctbl_pend.
        assign tt_integr_apb_aprop_ctbl_pend.ttv_rec_integr_apb_item_lote = recid(tt_integr_apb_item_lote_impl3v)
               tt_integr_apb_aprop_ctbl_pend.tta_cod_plano_cta_ctbl       = 'PLANOP'
               tt_integr_apb_aprop_ctbl_pend.tta_cod_cta_ctbl             = '91101009'
               tt_integr_apb_aprop_ctbl_pend.tta_cod_unid_negoc           = '001'
               tt_integr_apb_aprop_ctbl_pend.tta_cod_tip_fluxo_financ     = fluxo_
               tt_integr_apb_aprop_ctbl_pend.tta_val_aprop_ctbl           = titulo-apb.saldo
               tt_integr_apb_aprop_ctbl_pend.ttv_rec_antecip_pef_pend       = 0
               tt_integr_apb_aprop_ctbl_pend.ttv_rec_integr_apb_impto_pend  = 0
               tt_integr_apb_aprop_ctbl_pend.tta_cod_pais                   = "BRA"
               tt_integr_apb_aprop_ctbl_pend.tta_cod_unid_federac           = if avail emitente then emitente.estado else "".           
    end.
    
    
    /***************************************************************************************/
    procedure createLote:
        CREATE tt_integr_apb_lote_impl.
        ASSIGN tt_integr_apb_lote_impl.tta_cod_estab                = /*titulo-apb.estab*/ '101'
               tt_integr_apb_lote_impl.tta_cod_refer                = titulo-apb.refer
               tt_integr_apb_lote_impl.tta_dat_transacao            = TODAY 
               tt_integr_apb_lote_impl.tta_cod_empresa              = '1' /*2*/
               tt_integr_apb_lote_impl.tta_cod_indic_econ           = "Real"           
               tt_integr_apb_lote_impl.tta_ind_origin_tit_ap        = "APB".                                 
    end.
    
    /***************************************************************************************/
    procedure createItens:
      define variable portador_ as char.
      define variable modalidade_ as char.
    
      run buscaPortador(input titulo-apb.port, output portador_,
                        input titulo-apb.modal, output modalidade_).
    
    
      for first espec_docto where
                espec_docto.cod_espec_docto = titulo-apb.espec no-lock.
    
          if espec_docto.ind_tip_espec_docto = "Antecipação" then
            assign portador_   = ''
                   modalidade_ = ''.
      end.
      put  "1" skip.
      create tt_integr_apb_item_lote_impl3v.
      assign tt_integr_apb_item_lote_impl3v.ttv_rec_integr_apb_lote_impl = RECID (tt_integr_apb_lote_impl)
           tt_integr_apb_item_lote_impl3v.tta_num_seq_refer            = inumSeq 
           tt_integr_apb_item_lote_impl3v.tta_cdn_fornecedor           = /*titulo-apb.forne*/  9  /*  TEMPORARIO  */
           tt_integr_apb_item_lote_impl3v.tta_cod_espec_docto          = trim(titulo-apb.espec)
           tt_integr_apb_item_lote_impl3v.tta_cod_ser_docto            = trim(titulo-apb.serie)
           tt_integr_apb_item_lote_impl3v.tta_cod_tit_ap               = trim(titulo-apb.docto)
           tt_integr_apb_item_lote_impl3v.tta_cod_parcela              = trim(titulo-apb.parc)
           tt_integr_apb_item_lote_impl3v.tta_dat_emis_docto           = titulo-apb.emiss
           tt_integr_apb_item_lote_impl3v.tta_dat_vencto_tit_ap        = titulo-apb.venct
           tt_integr_apb_item_lote_impl3v.tta_dat_prev_pagto           = titulo-apb.venct
           tt_integr_apb_item_lote_impl3v.tta_cod_indic_econ           = 'real'
           tt_integr_apb_item_lote_impl3v.tta_val_tit_ap               = titulo-apb.saldo
           tt_integr_apb_item_lote_impl3v.tta_cod_portador             = portador_
           tt_integr_apb_item_lote_impl3v.tta_des_text_histor          = "MIGRACAO"
           tt_integr_apb_item_lote_impl3v.tta_cod_cart_bcia            = modalidade_.     
      assign inumSeq = inumSeq + 10.
      
      MESSAGE titulo-apb.port
      VIEW-AS ALERT-BOX INFO BUTTONS OK.
    
    end.
    
    /***************************************************************************************/
    procedure carregaTable:
      input from "c:\clientes\cliente\apb\saida.txt".
       repeat:
         create titulo-apb.
         import delimiter ";"     
            titulo-apb.estab
            titulo-apb.espec
            titulo-apb.serie
            titulo-apb.docto
            titulo-apb.parc 
            titulo-apb.forne
            titulo-apb.refer
            titulo-apb.emiss
            titulo-apb.venct
            titulo-apb.saldo
            titulo-apb.despe
            titulo-apb.port
            titulo-apb.modal.
       end.
      input close.
    end.
    
    /***************************************************************************************/
    procedure piLimpaTabelas:
        empty temp-table tt_integr_apb_abat_antecip_vouc no-error.
        empty temp-table tt_integr_apb_abat_prev_provis no-error.
        empty temp-table tt_integr_apb_aprop_ctbl_pend no-error.
        empty temp-table tt_integr_apb_aprop_relacto no-error.
        empty temp-table tt_integr_apb_impto_impl_pend no-error.
        empty temp-table tt_integr_apb_item_lote_impl3v no-error.
        empty temp-table tt_integr_apb_lote_impl no-error.
        empty temp-table tt_integr_apb_relacto_pend no-error.
        empty temp-table tt_log_erros_atualiz no-error.
        empty temp-table tt_integr_apb_item_lote_impl3v no-error.
    end.
    
    /***************************************************************************************/
    procedure piLiberaTabelas:
        release tt_integr_apb_abat_antecip_vouc.
        release tt_integr_apb_abat_prev_provis.
        release tt_integr_apb_aprop_ctbl_pend.
        release tt_integr_apb_aprop_relacto.
        release tt_integr_apb_impto_impl_pend.
        release tt_integr_apb_item_lote_impl3v.
        release tt_integr_apb_lote_impl.
        release tt_integr_apb_relacto_pend.
        release tt_log_erros_atualiz.
        release tt_integr_apb_item_lote_impl3v.
    end.
    
    /**********************************************************************************************/
    procedure buscaFluxoFinanc.
      define input parameter  fluxo-i as char.
      define output parameter fluxo-o as char.
      assign fluxo-o = "".
      for first matriz_trad_fluxo_ext where
                matriz_trad_fluxo_ext.cod_matriz_trad_fluxo_ext = 'MTZ-001',
                each trad_fluxo_ext of matriz_trad_fluxo_ext where
                trad_fluxo_ext.cod_fluxo_financ_ext = fluxo-i.  
            assign fluxo-o = trad_fluxo_ext.cod_tip_fluxo_financ.
      end.
    end.
    
    /**********************************************************************************************/
    procedure buscaPortador:
      define input parameter  portador-i as char.
      define output parameter portador-o as char.
      define input parameter  modalidade-i as char.
      define output parameter modalidade-o as char.
    
      for first matriz_trad_portad_ext where
                matriz_trad_portad_ext.cod_matriz_trad_portad_ext = 'MTZ-001',
                each trad_portad_ext of matriz_trad_portad_ext where
                     trad_portad_ext.cod_portad_ext  = portador-i and
                     trad_portad_ext.cod_modalid_ext = modalidade-i.  
            assign portador-o   = trad_portad_ext.cod_portador
                   modalidade-o = trad_portad_ext.cod_cart_bcia.  
      end.
    
    end.
    
    
    
    
    
    /***************************************************************************************/
    
    
    
    
    
    
    
  2. pedro_lemes

    pedro_lemes Membro Participativo

    Ola, @lhp.s !

    Conseguiu resolver? Poderia me passar a documentação atualizada e principalmente a definicao da tt_integr_apb_item_lote_impl3v ou até mesmo, seu programa, como exemplo?

    Grato e abs!
  3. rohis

    rohis Membro Ativo

    Olá pessoal!
    Estou com problema semelhante, porém não achei solução. É o seguinte: estou executando a api apb900zg e alimentando as temp-tables conforme documentação, porém ocorre os erros:
    1.001 Valor do Documento não foi rateado totalmente !
    799 Total rateado maior que total a ser rateado !

    procurei na documentação e não achei nada sobre rateio. Pode ajudar?

    @pedro_lemes , caso ainda tiver solução fico muito agradecida!

    Abs!
    @pedro_lemes!
  4. pedro_lemes

    pedro_lemes Membro Participativo

    rohis,

    Pode me passar o que fez até o momento e me adicionar no skype: pedro_lemes por favor? Vamos resolver isso a 4 mãos?

    Quando concluirmos, postamos aqui a solução. Topa?

    Abs!
  5. pedro_lemes

    pedro_lemes Membro Participativo

    @rohis,

    Pode me passar a sua definição de temp-tables ???

    Abs
  6. pedro_lemes

    pedro_lemes Membro Participativo

    rohis,

    Conseguiu resolver a mensagem? Estou com o mesmo problema!

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

Compartilhe esta Página