Skip to Content

Hello,

For Spain, there is a standard transaction that allow you generate the monthly declaration called M340.

The standard transaction is S_E4A_94000356 – Report RFIDESM340

This transaction generates a report that is not totally complete, because the Interval columns are not populated, due to an absence of a counter dependent on the client business requirements.

to be able to populate the interval columns :

Step 1 : Implement OSS Note 1392825 – Modification of Exit LGL_RPT_EXIT_GET_ACC_INTERVAL.

Step 2 : Once Exit activated, you can start coding to populate the interval columns :

bellow the example used :

=============================

*&———————————————————————*

*&  Include           ZEXITM340

*&———————————————————————*

*types declaration

TYPES : BEGIN OF t_counter,

          belnr      LIKE tax_line_input-belnr,

          mwskz      LIKE tax_line_input-mwskz,

          fcount(3)  TYPE n,

          lcount(3)  TYPE n,

        END OF t_counter.

*******************************************

* data declaration

DATA lw_counter(3) TYPE n.

DATA lt_bseg       TYPE STANDARD TABLE OF bseg.

DATA ls_bseg       TYPE bseg.

DATA lw_belnr      LIKE tax_line_input-belnr.

DATA lt_counter     TYPE TABLE OF t_counter.

DATA ls_counter      TYPE t_counter.

*********************************************

IMPORT lt_counter FROM MEMORY ID ‘ZEXITM340_Zcounter’.

lw_counter  =  1.

SELECT * FROM bseg INTO TABLE lt_bseg WHERE belnr = tax_line_input-belnr

                                        AND hkont = tax_line_input-hkont

                                        AND gjahr = tax_line_input-gjahr.

SORT lt_counter BY belnr lcount DESCENDING.

  READ TABLE lt_counter INTO ls_counter WITH KEY belnr = tax_line_input-belnr

                                             mwskz = tax_line_input-mwskz.

  IF sy-subrc = 0.

    CONCATENATE tax_line_input-belnr ls_counter-fcount INTO acc_int_first .

    CONCATENATE tax_line_input-belnr ls_counter-lcount INTO acc_int_last .

  ELSE.

    READ TABLE lt_counter INTO ls_counter WITH KEY belnr = tax_line_input-belnr.

    IF sy-subrc = 0 .

      MOVE  ls_counter-lcount TO lw_counter.

      ADD 1 TO lw_counter.

    ENDIF.

    CONCATENATE tax_line_input-belnr lw_counter INTO acc_int_first .

    SUBTRACT 1 FROM lw_counter.

    LOOP AT lt_bseg INTO ls_bseg

    WHERE mwskz  = tax_line_input-mwskz

      AND hkont BETWEEN 0070000000 AND 0070099999.

      lw_counter  =  lw_counter + 1.

    ENDLOOP.

    IF lw_counter = acc_int_first+10(3) .

      ADD 1 TO lw_counter.

    ENDIF.

* sometimes the lw_counter is 000 witch is due to bad selection of G/L Account in (TAX_LINE_INPUT = wa_tax_item)

* so the objectif is to correct this error hard coded way

    if lw_counter = 000.

      add 2 to lw_counter.

    endif.

    CONCATENATE tax_line_input-belnr lw_counter INTO acc_int_last .

    ls_counter-belnr   = tax_line_input-belnr.

    ls_counter-mwskz   = tax_line_input-mwskz.

    ls_counter-fcount  =  acc_int_first .

    ls_counter-lcount  =  acc_int_last .

    APPEND ls_counter TO lt_counter.

  ENDIF.

*export global data for counter

EXPORT lt_counter  TO MEMORY ID ‘ZEXITM340_Zcounter’.

==========================

Of course you need to adapt the Exit depending on the client business requirement,

there is some new OSS notes regarding the modelo 340 for Spain, so do not hesitate to check and update your modelo

Enjoy!


To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply