Skip to Content

Introduction

In Spain a new tax related legal requirement has begun in 1st July 2017. The requirement is to inform daily to Spanish tax agency all outgoing invoices as well as incoming invoices. The Spanish tax agency created for this the so called “SII Suministro Inmediato Información”. Please check http://www.agenciatributaria.es/AEAT.internet/Inicio/La_Agencia_Tributaria/Campanas/Suministro_Inmediato_de_Informacion_en_el_IVA__SII_/Suministro_Inmediato_de_Informacion_en_el_IVA__SII_.shtml for more information.

SII can handle Invoices ID up to 60 characters long.

BKPF-XBLNR is usually the field where the Issuer Invoice Number (incoming invoice) is informed. But XBLNR is 16 characters long, which in some cases is not enough to hold the invoice number.

The aim of this post is to give a possible solution for Incoming Invoices number length greater than 16 characters.

SAP released the note 2409025 – SII Suministro Inmediato Información: Issuer invoice number – Length of reference document number (BKPF-XBLNR) is limited to 16 characters length. The “Combined solution” may meet the legal requirement, but does not meet an obvious need which is to search by Issuer Invoice Number. It also complicates the logic, since two fields have to be concatenated to build the Issuer Invoice Number.

In this post I briefly summarize the sequence of steps to give a feasible solution. The idea is to add a new ZZ field to BKPF and create the way to inform / validate it. This field will be 60 characters long and will contain full invoice number.

The target system is SAP ECC 6.0.

The target audience for this post is ABAP consultants. Code is not provided, but I provide clues which will be useful for an ABAP consultant.

Before start doing changes you should fully read and understand the post.

The business rule for this solution

For invoice length <= 16 keep using BKPF-XBLNR. Copy value from BKPF-XBLNR to added field to BKPF (let’s say ZZSII_INV).

For invoice length > 16 inform in BKPF-XBLNR the first 16 characters of the invoice and inform full invoice number in ZZSII_INV. Validate that the first 16 characters contained in ZZSII_INV are matching to BKPF-XBLNR.

With this business rule you will be able to find in all invoices the number in ZZSII_INV, so you can use this field for selects and implement any other business logic, as for example detect  duplicated invoices.

Implementation

Dictionary changes

  • In SE11 create a Data element, let’s say ZZSII_INV_DE with domain CHAR60
  • In SE11 create a Structure. Let’s say ZCI_SII with a ZZ field, let’s say ZZSII_INV type ZZSII_INV_DE
  • In SE11 create an Append structure to BKPF, including structure  ZCI_SII. This is needed to hold data in BKPF
  • In SE11 create in BKPF a proper secondary index to search by ZZSII_INV. This may need Database Adjustment (SE14) in order to have created the index in Database. Be careful with Database adjustment!.
  • In SE11 create an Append structure to VBKPF, including structure  ZCI_SII. This will be needed to hold data in VBKPF (parked documents)
  • In SE11 create an Append structure to ACCHD, including structure  ZCI_SII. This will be needed to create invoices by calling to BAPI_ACC_DOCUMENT_POST
  • In SE11 create an Append structure to INVFO, including structure  ZCI_SII. This will be needed to inform ZZSII_INV in transactions FV60 / FB60 / FBV2 / MIRO
  • In SE11 create an Append structure to RBKP, including structure  ZCI_SII. This will be needed to inform ZZSII_INV to RBKP in transaction MIRO.
  • In SE11 create an Append to database view RBKP_V, adding field ZZSII_INV. This will be needed to inform ZZSII_INV to RBKP in transaction MIRO.
  • In SE11 create an Append structure to ACMM_VENDOR_COMP, including structure  ZCI_SII. This will be needed to inform ZZSII_INV to RBKP in transaction MIRO.

Generated ABAP readjustments

  • In SE38 execute report SAPFACCG. This will re-generate the include LFACIGEN and will add to DATA P_ACC the field ZZSII_INV.
  • In SE38 display LFACIGEN and confirm that in DATA P_ACC the field ZZSII_INV has been added.
  • In SE38 execute RGUGBR00 with all checkboxes. This will regenerate ABAP code to add the field ZZSII_INV.

Steps to do if you are using (or plan to use) BAPI_ACC_DOCUMENT_POST to create Invoices

  • These adjustments provide the functionality to inform BKPF-ZZSII_INV in document creation from BAPI_ACC_DOCUMENT_POST
  • In SE18 Implement BAdI ACC_DOCUMENT. Set filter = ‘BKPFF’. In the implementation class, write the code in method IF_EX_ACC_DOCUMENT~CHANGE in order to inform in C_ACCHD-ZZSII_INV (use cl_abap_container_utilities=>read_container_c). Activate the BAdI implementation.
  • Adjust the programs calling BAPI_ACC_DOCUMENT_CHECK  / BAPI_ACC_DOCUMENT_POST by informing EXTENSION2. Use cl_abap_container_utilities=>fill_container_c to fill the table to pass to EXTENSION2.

With these changes you will be able to create documents from BAPI. Check that you can inform and save ZZSII_INV value properly.

Adjustments for FV60 / FB60 / FBV2 / FBV3 / MIRO

These adjustments provide the functionality to inform / display BKPF-ZZSII_INV in document creation / edition FV60, FB60, FBV2, FBV3, MIRO.

  • In SE38 create a Z program with a dynpro containing the field ZZSII_INV
  • In SE18 locate a free BAdI (Not implemented by SAP): BADI_FDCB_SUBBAS01 to BADI_FDCB_SUBBAS05. In my case I choose BADI_FDCB_SUBBAS05. In subscreen tab inform Z program and Dynpro containing the field ZZSII_INV. In implementation class write code in methods IF_EX_BADI_FDCB_SUBBAS05~GET_DATA_FROM_SCREEN_OBJECT and IF_EX_BADI_FDCB_SUBBAS05~PUT_DATA_TO_SCREEN_OBJECT to communicate the value of INVFO-ZZSII_INV.
  • In SE38 include LMRMPF0I create an enhancement point at the end of form ACCHD_AUFBAUEN. Update TE_ACCHD-ZZSII_INV, copying the value from I_RBKPV-ZZSII_INVFR. This will transfer ZZSII_INV from logistic invoice to FI document.

With these changes you will see in Basic Data tab of transactions FV60 / FB60 / FBV2 / FBV3 / MIRO the added field ZZSII_INV and it will be informed in BKPF (and RBKP in case of MIRO). Check that you can inform and save the value properly.

Adjustments for MR8M

  • In SE37 FM MRM_INVOICE_CANCEL_PERFORM create an enhancement point at the end of function module. Transfer ZZSII_INV from rbkpv to st_rbkpv. This will transfer ZZSII_INV to the reversal document.

Adjustments for FB01 / FB02 / FB03 (SAPMF05A, SAPMF05L)

In you needed to inform / see the value ZZSII_INV in FB01 / FB02 / FB03. Here I propose a solution.

  • Create a Function Group containing a Function Module (let’s say ZSII_INV_POPUP) and a Screen with field ZZSII_INV. Write the logic to implement a POPUP to show ZZSII_INV. This Popup will be later called from SAPMF05A and SAPMF05L.

Adjustments for FB01 (SAPMF05A)

These adjustments provide the functionality to inform BKPF-ZZSII_INV in document creation from FB01 (SAPMF05A).

  • In SE38 include MF05AI00_BELEGKOPF_SPEICHERN create an enhancement point at the beginning of form PAI_BELEGKOPF_SPEICHERN. Call in this enhancement point to the FM containing Popup (ZSII_INV_POPUP). This will add functionality to Dynpro 100 of SAPMF05A. Write value to BKPF-ZZSII_INV.
  • In SE38 include MF05AI00_BELEGKOPF_AENDERN create an enhancement point at the beginning of form PAI_BELEGKOPF_AENDERN. Call in this enhancement point to the FM containing Popup (ZSII_INV_POPUP). This will add functionality to Dynpro 700 of SAPMF05A. Write value to BKPF-ZZSII_INV.

Adjustments for FB02 / FB03 (SAPMF05L)

These adjustments provide the functionality to update / display BKPF-ZZSII_INV in FB012 / FB03 (SAPMF05L).

  • In SE38 include MF05LI00 create an enhancement point at the beginning of form PAI_KOPF_AENDERN. Call in this enhancement point to the FM containing Popup (ZSII_INV_POPUP). This will add functionality to Dynpro 1710 of SAPMF05L. Write value to BKPF-ZZSII_INV.
  • In SE38 include LKKBLF90 crate an enhancement point at the end of form USER_COMMAND_NEW. Call in this enhancement point to the FM containing Popup (ZSII_INV_POPUP). This is only for displaying purposes when XBLNR is double clicked (filter by l_ucomm = ‘DETA’  and ls_selfield-sel_tab_field = ‘BKPF-XBLNR’). This will add functionality to Document Overview.
  • In order to have BKPF-ZZSII_INV updated another enhancement point must be created. In SE38 include LF007F01 create an enhancement point at the end of form BELEGKOPF_SCHREIBEN. Add:
  UPDATE bkpf
      SET zzsii_inv = bkpf-zzsii_inv
   WHERE bukrs = bkpf-bukrs
     AND gjahr = bkpf-gjahr
     AND belnr = bkpf-belnr.

Substitution XBLNR -> ZZSII_INV

  • In transaction GGB1 create a step for “Financial Accounting” in “Complete document”. Create an exit. Code In the exit the substitution by copying the value of XBLNR to ZZSII_INV in case ZZSII_INV is initial.

Validation XBLNR <-> ZZSII_INV

  • In transaction GGB0 create a step for “Financial Accounting” in “Complete document”. Create an exit. Code in the exit the validation rule:  BKPF-XBLNR is equal to BKPF-ZZSII_INV(16).

Mapping of BKPF-ZZSII_INV to AEAT Webservice

Here I don’t give details, as several solutions are available to present the information to Spanish Tax Agency (AEAT). You should map BKPF-ZZSII_INV to the Webservice.

Transport changes to Quality / Production

As during the transport (Quality / Production) a Database adjustment will be done for BKPF I recommend to create a restore point before transporting.

After the transport:

  • In SE38 execute report SAPFACCG. This will re-generate the include LFACIGEN and will add to DATA P_ACC the field ZZSII_INV.
  • In SE38 display LFACIGEN and confirm that in DATA P_ACC the field ZZSII_INV has been added.
  • In SE38 execute RGUGBR00 with all checkboxes. This will regenerate ABAP code to add the field ZZSII_INV.
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