cancel
Showing results for 
Search instead for 
Did you mean: 

SPED ECD Campos VL_CTA_ULT_DRE e IND_VL_ULT_DRE do registro J150

Former Member
0 Kudos

Bom dia Senhores,

Os campos VL_CTA_ULT_DRE e IND_VL_ULT_DRE do registro J150 foram entregues pela SAP Note 2272317, porém não há lógica standard para apurar estes campos.

Segundo o Manual de Orientação da ECD, os campos realmente não são obrigatórios na Receita, porém a não entrega desse número é passível de notificação pelo CRC.

A dúvida é: a SAP vai tratar esta apuração no Standard ou temos que implementar na BADI ?

Alguém mais notou a situação?

Att.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Resolvido.

Former Member
0 Kudos

Poderia compartilhar conosco a solução? Partiu para a BAPI?

Forte abraço. Leandro Siqueira.

Former Member
0 Kudos

Bom dia Leandro,

Não, tentei pela BADI mas não deu muito certo. Precisei criar um Enhancement no final do form  PRE_FILL_J150 no programa J_1BECD_MAIN.

Neste ponto, tenho as contas contábeis e as contas de aglutinação. Então, no enhancement refiz o loop na tabela  <gts_account>, atualizando a tabela  gt_j150 com os saldos das contas no exercicio anterior, lidos na GLT0.

Att.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Good morning Reinaldo,

I opened a call in SAP to address this issue and in response I was told to use the BAdI 'BAdI_J_1BECD' in 'FILL_REGISTER_J150' method.
You mentioned that you got no result coma BAdI could tell why?
If you can share what was encoded in its enhancement would help us a lot.

thank you,

Gilberto.

Former Member
0 Kudos

Olá Gilberto,

Não foi possível utilizar o 'FILL_REGISTER_J150' devido ao fato de que este método re-processa os registros já tratados pelo standard, ou seja, quase o resultado final. No caso, para apresentar os valores do ultimo DRE, precisamos utilizar além das contas contábeis, a estrutura de aglutinação das contas e no escopo deste método, não temos nenhuma destas informações.

Então precisei criar um enhancement no FORM 'pre_fill_j150'. No SPOT de saída do form, eu adicionei a seguinte lógica: leio a estrutura de aglutinação e obtenho as contas. Busco na GLT0 os resultados do exercicio anterior e executo a aglutinação.

Não sei se é a melhor maneira, mas aqui funcionou sem problemas. segue a implementação:

   DATA: wa_cre             TYPE glt0,

         wa_deb             TYPE glt0,

         l_tot_cre          TYPE wertv8,

         l_tot_deb          TYPE wertv8,

         l_total            TYPE wertv8,

         l_gjahr_ant        TYPE glt0-ryear.

   FIELD-SYMBOLS: <fs_j150> TYPE j_1becd_j150_3_s.

   l_gjahr_ant = P_GJAHR - 1.

   IF <gts_account> IS NOT INITIAL.

      LOOP AT gt_pl_aglut_level INTO ls_aglut_level.

            SELECT SINGLE * INTO wa_cre

              FROM glt0

             WHERE bukrs = p_bukrs

               AND rldnr = '00'

               AND racct = ls_aglut_level-account_nr

               AND ryear = l_gjahr_ant

               AND rbusa = ''

               AND drcrk = 'H'.

            IF sy-subrc IS INITIAL.

               l_tot_cre = wa_cre-tsl16.

            ELSE.

               l_tot_cre = 0.

            ENDIF.

            SELECT SINGLE * INTO wa_deb

              FROM glt0

             WHERE bukrs = p_bukrs

               AND rldnr = '00'

               AND racct = ls_aglut_level-account_nr

               AND ryear = l_gjahr_ant

               AND rbusa = ''

               AND drcrk = 'S'.

            IF sy-subrc IS INITIAL.

               l_tot_deb = wa_deb-tsl16.

            ELSE.

               l_tot_deb = 0.

            ENDIF.

            l_total = l_tot_cre + l_tot_deb.

            READ TABLE gt_j150 ASSIGNING <fs_j150> WITH KEY cod_agl       = ls_aglut_level-aglut_code

                                                            nivel_agl     = ls_aglut_level-level

                                                            descr_cod_agl = ls_aglut_level-description.

            IF sy-subrc IS INITIAL.

               <fs_j150>-VL_CTA_ULT_DRE = <fs_j150>-VL_CTA_ULT_DRE + l_total.

            ELSE.

               IF l_total <> 0.

                  CLEAR ls_j150.

                  ls_j150-cod_agl        = ls_aglut_level-aglut_code.

                  ls_j150-nivel_agl      = ls_aglut_level-level.

                  ls_j150-descr_cod_agl  = ls_aglut_level-description.

                  ls_j150-vl_cta_ult_dre = l_total.

                  APPEND ls_j150 TO gt_j150.

               ENDIF.

            ENDIF.

      ENDLOOP.

   ENDIF.


Att,

Reinaldo

Former Member
0 Kudos

Oi Reinaldo,

Estou passando pelo mesmo problema que você passou.
E apliquei a sua logica no enhancement no FORM 'pre_fill_j150', ativou e deu tudo certinho.

Mas o campo tsl16 da glt0 esta vindo sempre vazio, tanto para debito quanto credito.

Quando vier vazio, é para jogar vazio no sped ?

Outra coisa, reparei que nesta logica voce nao preenche o campo IND_VL_ULT_DRE, que é o indicador da situação (D, R, P ou N).

Voce fez alguma tratativa ?

Abraço

Former Member
0 Kudos

Olá Carlos,

No caso da GLT0-TSL16 estar vindo vazio, acredito que você teria que verificar as customizações da contabilidade. No meu caso, verifiquei que o valor do saldo da conta fica sempre nessa coluna. Contudo, acredito que você possa olhar também a coluna TSL12.

Outro detalhe é verificar se não está versionado. consulte na SE16n os registros da GLT0 apenas com o numero da conta e o exercicio, para verificar suas condições de leitura, que podem ser diferentes das minhas. Acredito que isto se dá devido às customizações.

Com relação ao IND_VL_ULT_DRE, realmente. tratei como enhancement também. A SAP instrui a fazer o tratamento na BADI  fill_register_j150, mas não é possível também pois a lógica necessária exige que sejam verificados as contas anteriores.

Então resolvi implementando a mesma lógica que o standard executa para a  ind_vl no SPOT de saída do form  process_reg_j150.

segue a implementação:

DESCRIBE TABLE gt_j150 LINES lv_max_tabix.

   LOOP AT gt_j150 INTO ls_j150.

     lv_current_tabix = sy-tabix.

     lv_next_tabix    = lv_current_tabix + 1.

     CLEAR ls_next_j150.

     IF lv_next_tabix <= lv_max_tabix.

       READ TABLE gt_j150 INTO ls_next_j150 INDEX lv_next_tabix.

     ENDIF.

     IF ls_j150-vl_cta_ult_dre >= 0. "Zero is considered Revenue

        IF ls_next_j150-nivel_agl > ls_j150-nivel_agl. "line with totals

           ls_j150-ind_vl_ult_dre = const_positive_subt.

        ELSE. "lower nodes at the hierarchy

           ls_j150-ind_vl_ult_dre = const_revenue.

        ENDIF.

     ELSEIF ls_j150-vl_cta_ult_dre < 0.

        IF ls_next_j150-nivel_agl > ls_j150-nivel_agl. "line with totals

           ls_j150-ind_vl_ult_dre = const_negative_subt.

        ELSE. "lower nodes at the hierarchy

           ls_j150-ind_vl_ult_dre = const_expense.

        ENDIF.

        ls_j150-vl_cta_ult_dre = - ls_j150-vl_cta_ult_dre"Always absolute value

     ENDIF.

     MODIFY gt_j150 FROM ls_j150 INDEX lv_current_tabix.

   ENDLOOP.


Att.

Reinaldo

Answers (2)

Answers (2)

Former Member
0 Kudos
Former Member
0 Kudos

Fernando, esta nota nao se aplica para o Layout 004.. Tanto é que as correções que a nota faz é tirar tudo que é 004 e colocar 003.

Former Member
0 Kudos

Boa tarde Reinaldo,

Obrigado pelo retorno, analisando o que você encaminhou percebemos a necessidade de incluir as linhas que continham saldo no exercício anterior, porém no exercício atual o standard não inseri a linha se a conta não tem saldo.

Fizemos aqui dois enhancement point para ajustar o registro J150, “ZSPED_ANO_ANTERIOR” foi criado no programa J_1BECD_MAIN_PRE_BLJ (final do subprograma PRE_FILL_J150). Segue o código fonte do mesmo.

Incio do 1º enhancement

Código:

ENHANCEMENT ZSPED_ANO_ANTERIOR

ENHANCEMENT ZSPED_ANO_ANTERIOR.    "active version
data: lv_gjahr     type gjahr,
lv_tabix    
type sytabix,
lv_next     
type sytabix,
lv_stufe    
type stufe_f02e,
lv_stop     
type c,
lv_nrec     
type i,
lw_next_j150
type j_1becd_j150_3_s,
lt_glt0     
type table of glt0             with header line,
lt_i011z    
type table of rf011z           with header line,
lt_x011p    
type table of rf011p           with header line,
lt_x011p_aux
type table of rf011p           with header line,
lt_x011s    
type table of rf011s           with header line,
lt_x011v    
type table of rf011v           with header line,
lt_x011f    
type table of rf011f           with header line,
t_j150      
type table of j_1becd_j150_3_s with header line.
ranges: lr_racct for glt0-racct.

* Limpando objetos
clear: lv_gjahr, lt_glt0, lt_glt0[], lt_i011z, lt_i011z[], lt_x011p, lt_x011p, lt_x011p[],
lt_x011s
, lt_x011s[], lt_x011v, lt_x011v[], lt_x011f, lt_x011f[], lr_racct, lr_racct[],
lv_tabix
, lt_x011p_aux, lt_x011p_aux[], lv_nrec, t_j150, t_j150[], lv_stufe,
lw_next_j150
, lv_next, lv_stop.

* Obtendo exercício anterior
lv_gjahr
= p_gjahr - 1.

* Obtendo estrutura de contas referente à transação OB58
call function 'FI_IMPORT_BALANCE_SHEET_POS'
exporting
version                
= 'SPED'
tables
i011z                  
= lt_i011z
x011p                  
= lt_x011p
x011s                  
= lt_x011s
x011v                  
= lt_x011v
x011f                  
= lt_x011f
exceptions
new_balance_sheet      
= 1
others                  = 2.
if sy-subrc is initial.

* Preenchendo ranges
loop at lt_i011z.
lr_racct
-sign   = 'I'.
lr_racct
-option = 'BT'.
lr_racct
-low    = lt_i011z-vonkt.
lr_racct
-high   = lt_i011z-bilkt.
append lr_racct. clear lr_racct.
endloop.

* Preenchendo tabela auxiliar de hierarquia
lt_x011p_aux[]
= lt_x011p[].

endif.

* Obtendo movimentações no período (Mestre da Conta do Razão)
select * into table lt_glt0 from glt0 where rldnr = '00'
and rrcty = '0'
and bukrs = p_bukrs
and ryear = lv_gjahr
and racct in lr_racct.
if sy-subrc is initial.

* Ordenando por conta
sort: lt_glt0  by racct,
lt_i011z
by ergso.

* Associando valores para os nós que estão nas extremidades da árvore (filhos)
loop at gt_j150 into gs_j150.

lv_tabix
= sy-tabix.

loop at lt_i011z where ergso = gs_j150-cod_agl(10).

loop at lt_glt0 where racct >= lt_i011z-vonkt
and racct <= lt_i011z-bilkt.

add: lt_glt0-tsl01 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl02 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl03 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl04 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl05 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl06 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl07 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl08 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl09 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl10 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl11 to gs_j150-vl_cta_ult_dre,
lt_glt0
-tsl12 to gs_j150-vl_cta_ult_dre.

endloop.

modify gt_j150 from gs_j150 index lv_tabix transporting vl_cta_ult_dre.

endloop.

endloop.

* Obtendo tabela auxiliar da GT_J150 (t_j150)
t_j150[]
= gt_j150[].

* Associando valores aos nós pais
describe table lt_x011p lines lv_nrec.

while lv_nrec >= 1.

read table lt_x011p index lv_nrec.
if sy-subrc is initial.

read table gt_j150 into gs_j150 with key cod_agl(10) = lt_x011p-ergsl.
if sy-subrc is initial.

lv_tabix
= sy-tabix.

lv_stufe
= lt_x011p-stufe + 1.
clear lv_stop.
loop at lt_x011p_aux.
if sy-tabix > lv_nrec and lt_x011p_aux-stufe < lv_stufe.
lv_stop
= 'X'.
endif.
check sy-tabix > lv_nrec and lt_x011p_aux-stufe = lv_stufe and lv_stop is initial.
read table t_j150 with key cod_agl(10) = lt_x011p_aux-ergsl.
if sy-subrc is initial.
add t_j150-vl_cta_ult_dre to gs_j150-vl_cta_ult_dre.
modify gt_j150 from gs_j150 index lv_tabix transporting vl_cta_ult_dre.
endif.
endloop.

clear t_j150.
read table t_j150 index lv_tabix.
if sy-subrc is initial.
t_j150
-vl_cta_ult_dre = gs_j150-vl_cta_ult_dre.
modify t_j150 index lv_tabix transporting vl_cta_ult_dre.
endif.

endif.

endif.

subtract 1 from lv_nrec.

endwhile.

* Tirando os valores negativos do exercício anterior
describe table gt_j150 lines lv_nrec.
loop at gt_j150 into gs_j150.

lv_tabix
= sy-tabix.

clear: lw_next_j150, lv_next.
lv_next
= lv_tabix + 1.
if lv_next <= lv_nrec.
read table gt_j150 into lw_next_j150 index lv_next.
endif.

if gs_j150-vl_cta_ult_dre >= 0. "zero é considerado receita
if lw_next_j150-nivel_agl > gs_j150-nivel_agl. "linha com totais
gs_j150
-ind_vl_ult_dre = const_positive_subt.
else. "menor nó na hierarquia
gs_j150
-ind_vl_ult_dre = const_revenue.
endif.
elseif gs_j150-vl_cta_ult_dre < 0.
if lw_next_j150-nivel_agl > gs_j150-nivel_agl. "linha com totais
gs_j150
-ind_vl_ult_dre = const_negative_subt.
else. "menor nó na hierarquia
gs_j150
-ind_vl_ult_dre = const_expense.
endif.
gs_j150
-vl_cta_ult_dre = - gs_j150-vl_cta_ult_dre"sempre valor absoluto
endif.
modify gt_j150 from gs_j150 index lv_tabix.

endloop.

endif.
ENDENHANCEMENT.

Incio do 2º enhancement

Código:

ENHANCEMENT ZSPED_ANO_ANTERIOR.    "active version

ENHANCEMENT 2  ZSPED_ANO_ANTERIOR

ENHANCEMENT ZSPED_ANO_ANTERIOR.    "active version
data: lv_tabix type sytabix.

clear: lv_tabix.

if <gts_account> is not initial.

loop at gt_pl_aglut_level into ls_aglut_level.

read table gt_j150 into ls_j150 with key cod_agl       = ls_aglut_level-aglut_code
nivel_agl    
= ls_aglut_level-level
descr_cod_agl
= ls_aglut_level-description.
if sy-subrc is not initial.

add 1 to lv_tabix.

clear ls_j150.
ls_j150
-cod_agl       = ls_aglut_level-aglut_code.
ls_j150
-nivel_agl     = ls_aglut_level-level.
ls_j150
-descr_cod_agl = ls_aglut_level-description.
insert ls_j150 into gt_j150 index lv_tabix.

else.

lv_tabix
= sy-tabix.

endif.

endloop.

endif.
ENDENHANCEMENT.

Desta forma gerou o registro J150 de acordo com a estrutura de balanço criada para o Sped na OB58.

Att,

Gilberto