SAP Document and Reporting Compliance Belgium: Electronic Invoice in Utilities using Extensibility

Estimated read time 8 min read

You want to enable your system to create electronic documents for invoices posted in Utilities using SAP Document and Reporting Compliance. In this blog, we’ll show you an example on how this can be achieved using extensibility.Ā Ā 

Before you begin ensure that you have implemented the SAP Notes listed inĀ 2424886 – Electronic Document Processing for Belgium: Implementation Overview.Ā You can also refer the SAP Help Portal for more information, see Electronic Document Processing.
Ensure you have also implemented the SAP Notes listed inĀ 2736880 – eDocument EU PEPPOL: Overview note for IS-U.

Steps to Create Electronic Documents

Create eDocument Class
1. Create ‘ZCL_EDOCUMENT_BE_ISU’ eDocument class by inheritingĀ CL_EDOCUMENT_EU_ISU class.
2. Add the CONSTRUCTOR method in the ZCL_EDOCUMENT_BE_ISU eDocument class to map theĀ ‘Z’Ā eDocument IS-U class name to the field ms_edocument-edocument_class. 
3. Redefine the method DETERMINE_PROCESS to assign the processes BEINV and BEINVIN.
4. Use the tableĀ TFK003EDOCĀ to configure eDocument type against the accounting document type.
Example:

Country/RegionĀ 

Application AreaĀ 

Document TypeĀ 

eDocument TypeĀ 

INĀ 

Utility CompanyĀ 

FAĀ 

BE_INVĀ 

 5. Add the class CL_EDOC_PROCESS as Friends of ‘ZCL_EDOCUMENT_BE_ISU’ eDocument class. 

Sample Code for CONSTRUCTOR and DETERMINE_PROCESS method:Ā Ā 
Constructor method signature:Ā 

METHOD constructor.
super->constructor( io_source_data = io_source_data
iv_edoc_guid = iv_edoc_guid
iv_land = iv_land
iv_update_task = iv_update_task
iv_generic_badi_filter_adaptor = iv_generic_badi_filter_adaptor
iv_simulate_for_email_option = iv_simulate_for_email_option ).

ms_edocument-land = ‘BE’.
ms_edocument-edocument_class = ‘ZCL_EDOCUMENT_BE_ISU’.
ENDMETHOD.
METHOD determine_process.
CASE ms_edocument-edoc_type.
WHEN ‘BE_INVIN’.
ms_edocument-process = ‘BEINVIN’.
ms_edocument-process_version = ‘0001’.
WHEN OTHERS.
CASE ms_edocument-interface_type.
WHEN ‘AIF_PROXY’ OR ‘STANDARD’.
ms_edocument-process = ‘BEINV’.
* reference process is ‘EUINV’
ms_edocument-process_version = ‘0001’.
WHEN OTHERS.
MESSAGE e162(edocument) INTO gv_error_txt.
raise_edoc_exception( ).
ENDCASE.
ENDCASE.
ENDMETHOD.

Ā 

Create Factory Class
1. CreateĀ a ‘Z’ factory classĀ to get the instance of eDocument IS-U classĀ by inheriting CL_EDOC_FACTORYĀ classĀ and redefineĀ itsĀ method CREATE_EDOC_INSTANCE.Ā 
Example:Ā ZCL_EDOC_FACTORY_BE_ISU
2. Configure this ‘Z’ eDocument factory class in the viewĀ EDOFACTORYVĀ using the transaction SM30.

Source Type  

Factory Class  

ISU_INVOIC  

ā€˜Z’ factory class name (your factory class that you just created)  

Sample Code:
METHOD create_edoc_instances.

DATA: lv_land_iso TYPE edoc_land,
lv_error_txt TYPE string,
ls_source_header TYPE edoc_src_header,
lo_edocument TYPE REF TO zcl_edocument_be_isu.

CLEAR: lv_land_iso,
lv_error_txt,
ls_source_header,
lo_edocument,
et_edocument_obj.

* Country
ls_source_header = io_source->get_header( ).
CALL FUNCTION ‘COUNTRY_CODE_SAP_TO_ISO’
EXPORTING
sap_code = ls_source_header-land
IMPORTING
iso_code = lv_land_iso
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e881(b1) WITH ls_source_header-land INTO lv_error_txt.
ENDIF.
IF lv_land_iso <> ‘BE’.
RETURN.
ENDIF.

CREATE OBJECT lo_edocument
EXPORTING
io_source_data = io_source
iv_update_task = iv_update_task.

APPEND lo_edocument TO et_edocument_obj.

ENDMETHOD.

Mapping Class
1. We have a generic mapping class CL_EDOC_MAP_UBL_ISU. If you need to enhance the mapping logic, you can use the EDOC_ADAPTOR BAdI’s method SET_OUTPUT_DATA. For more details, refer to Enhancements for Electronic Documents.
Alternatively, you can implement your own custom mapping class.Ā 
2. ConfigureĀ your mapping class in the viewĀ EDOMAPCLASSDETVĀ using the transaction SM30. 
Example:

eDocument ProcessĀ 

VersionĀ 

Interface IDĀ 

eDocument TypeĀ 

Source TypeĀ 

Mapping ClassĀ 

EUINVĀ 

1Ā 

UBL_INVOICE_TRANSM

BE_INVĀ 

ISU_INVOICĀ 

<Your Z mapping class or CL_EDOC_MAP_UBL_ISU>Ā 

Ā 

MaintainĀ the Required Customizations
Apart from maintainingĀ Master Data,Ā CustomizingĀ and IntegrationĀ as explained in the SAP Help Portal, you must also configure the company code for the following IS-U source type.

1.Ā Ā ActivateĀ company code for ISU_INVOIC source type in the viewĀ EDOCOMPANYACTIVĀ for eDocument creation.
Example:

Company Code  

Source Type  

Application Active  

<Your company code>  

ISU_INVOICE  

X  


By followingĀ these steps, you can efficiently create electronic documents for invoices in the utilities sector, ensuring compliance and enhancing operational efficiency.Ā 

Don’t forget to test it thoroughly.Ā 

We hope this blog post was useful for you! You can leave a comment here or continue browsing our community for more blog posts on SAP Document and Reporting Compliance topics.Ā 

Looking forward to seeing you here again!Ā 

Ā 

​ You want to enable your system to create electronic documents for invoices posted in Utilities using SAP Document and Reporting Compliance. In this blog, we’ll show you an example on how this can be achieved using extensibility.Ā Ā Before you begin ensure that you have implemented the SAP Notes listed inĀ 2424886 – Electronic Document Processing for Belgium: Implementation Overview.Ā You can also refer the SAP Help Portal for more information, see Electronic Document Processing.Ensure you have also implemented the SAP Notes listed inĀ 2736880 – eDocument EU PEPPOL: Overview note for IS-U.Steps to Create Electronic DocumentsCreate eDocument Class1. Create ‘ZCL_EDOCUMENT_BE_ISU’ eDocument class by inheritingĀ CL_EDOCUMENT_EU_ISU class.2. Add the CONSTRUCTOR method in the ZCL_EDOCUMENT_BE_ISU eDocument class to map theĀ ‘Z’Ā eDocument IS-U class name to the field ms_edocument-edocument_class. 3. Redefine the method DETERMINE_PROCESS to assign the processes BEINV and BEINVIN.4. Use the tableĀ TFK003EDOCĀ to configure eDocument type against the accounting document type.Example:Country/RegionĀ Application AreaĀ Document TypeĀ eDocument TypeĀ INĀ Utility CompanyĀ FAĀ BE_INV  5. Add the class CL_EDOC_PROCESS as Friends of ‘ZCL_EDOCUMENT_BE_ISU’ eDocument class. Sample Code for CONSTRUCTOR and DETERMINE_PROCESS method:Ā Ā Constructor method signature:Ā METHOD constructor.
super->constructor( io_source_data = io_source_data
iv_edoc_guid = iv_edoc_guid
iv_land = iv_land
iv_update_task = iv_update_task
iv_generic_badi_filter_adaptor = iv_generic_badi_filter_adaptor
iv_simulate_for_email_option = iv_simulate_for_email_option ).

ms_edocument-land = ‘BE’.
ms_edocument-edocument_class = ‘ZCL_EDOCUMENT_BE_ISU’.
ENDMETHOD.
METHOD determine_process.
CASE ms_edocument-edoc_type.
WHEN ‘BE_INVIN’.
ms_edocument-process = ‘BEINVIN’.
ms_edocument-process_version = ‘0001’.
WHEN OTHERS.
CASE ms_edocument-interface_type.
WHEN ‘AIF_PROXY’ OR ‘STANDARD’.
ms_edocument-process = ‘BEINV’.
* reference process is ‘EUINV’
ms_edocument-process_version = ‘0001’.
WHEN OTHERS.
MESSAGE e162(edocument) INTO gv_error_txt.
raise_edoc_exception( ).
ENDCASE.
ENDCASE.
ENDMETHOD.Ā Create Factory Class1. CreateĀ a ‘Z’ factory classĀ to get the instance of eDocument IS-U classĀ by inheriting CL_EDOC_FACTORYĀ classĀ and redefineĀ itsĀ method CREATE_EDOC_INSTANCE.Ā Example:Ā ZCL_EDOC_FACTORY_BE_ISU2. Configure this ‘Z’ eDocument factory class in the viewĀ EDOFACTORYVĀ using the transaction SM30.Source Type  Factory Class  ISU_INVOICā€ÆĀ ā€˜Z’ factory class name (your factory class that you just created)  Sample Code:METHOD create_edoc_instances.

DATA: lv_land_iso TYPE edoc_land,
lv_error_txt TYPE string,
ls_source_header TYPE edoc_src_header,
lo_edocument TYPE REF TO zcl_edocument_be_isu.

CLEAR: lv_land_iso,
lv_error_txt,
ls_source_header,
lo_edocument,
et_edocument_obj.

* Country
ls_source_header = io_source->get_header( ).
CALL FUNCTION ‘COUNTRY_CODE_SAP_TO_ISO’
EXPORTING
sap_code = ls_source_header-land
IMPORTING
iso_code = lv_land_iso
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e881(b1) WITH ls_source_header-land INTO lv_error_txt.
ENDIF.
IF lv_land_iso <> ‘BE’.
RETURN.
ENDIF.

CREATE OBJECT lo_edocument
EXPORTING
io_source_data = io_source
iv_update_task = iv_update_task.

APPEND lo_edocument TO et_edocument_obj.

ENDMETHOD.Mapping Class1. We have a generic mapping class CL_EDOC_MAP_UBL_ISU. If you need to enhance the mapping logic, you can use the EDOC_ADAPTOR BAdI’s method SET_OUTPUT_DATA. For more details, refer to Enhancements for Electronic Documents.Alternatively, you can implement your own custom mapping class.Ā 2. ConfigureĀ your mapping class in the viewĀ EDOMAPCLASSDETVĀ using the transaction SM30. Example:eDocument ProcessĀ VersionĀ Interface IDĀ eDocument TypeĀ Source TypeĀ Mapping ClassĀ EUINVĀ 1Ā UBL_INVOICE_TRANSMBE_INVĀ ISU_INVOICĀ <Your Z mapping class or CL_EDOC_MAP_UBL_ISU>Ā Ā MaintainĀ the Required CustomizationsApart from maintainingĀ Master Data,Ā CustomizingĀ and IntegrationĀ as explained in the SAP Help Portal, you must also configure the company code for the following IS-U source type.1.Ā Ā ActivateĀ company code for ISU_INVOIC source type in the viewĀ EDOCOMPANYACTIVĀ for eDocument creation.Example: Company Code  Source Type  Application Active  <Your company code>  ISU_INVOICE  X  By followingĀ these steps, you can efficiently create electronic documents for invoices in the utilities sector, ensuring compliance and enhancing operational efficiency.Ā Don’t forget to test it thoroughly.Ā We hope this blog post was useful for you! You can leave a comment here or continue browsing our community for more blog posts on SAP Document and Reporting Compliance topics.Ā Looking forward to seeing you here again!Ā Ā Ā Ā Read MoreĀ Technology Blog Posts by SAP articlesĀ 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author