Developer Extensibility for Document and Reporting Compliance Türkiye in SAP S/4HANA Public Cloud

Estimated read time 12 min read

This blog post introduces a recent enhancement in SAP S/4HANA Cloud Public Edition that significantly improves developer extensibility for the Document and Reporting Compliance solution in Türkiye. This change enables developers to fully utilize the SET_OUTPUT_DATA method in the EDOC_ADAPTOR_CLOUD BAdI, which is used to modify the XML files generated for an electronic document. 

Background 
In some scenarios, you would want to enhance the standard XML file generated for an electronic document – for example, to add optional fields or make changes based on specific business or legal requirements. The Document and Reporting Compliance framework provides the SET_OUTPUT_DATA method within the EDOC_ADAPTOR_CLOUD BAdI to support such enhancements. This method allows partners to tailor the generated XML output to meet their needs. This was possible in SAP S/4HANA Private Cloud; however, it was not available in SAP S/4HANA Public Cloud, which limited flexibility for partners using the public cloud edition. 

However, until now, a key limitation with the Document and Reporting Compliance Türkiye solution was that its service consumer structures were not released. As a result, accessing and modifying XML content through ABAP structures was not straightforward. These structures needed to be made available by SAP for the respective country to enable developer extensibility. Without them, enhancements through the BAdI were either restricted or not feasible. 

What’s New? 
To remove this limitation, SAP has now released all proxy objects for the Türkiye Document and Reporting Compliance solution. As a result, developers can fully utilize the SET_OUTPUT_DATA method and enhance the XML output using standard proxy structures without any restrictions. 

Prerequisites 

You must have configured developer extensibility role in your configuration environment. 
The required business role is SAP_BR_DEVELOPER. 

Implementation Steps in ABAP Development Tools (ADT): 

In your ABAP project, go to the enhancement spot ES_EDOCUMENT_CLOUD (path: package GLO-EDO > Enhancements > Enhancement Spots). Right-click ES_EDOCUMENT_CLOUD and select New BAdI Enhancement Implementation. Enter a package, name, and description. Choose Add BAdI Implementation and select for EDOC_ADAPTOR_CLOUD. Create a BAdI filter for Country (TR) and/or Generic Filter. Choose Implementing Class to create a new implementation class. The new implementation class automatically implements the interfaces “if_badi_interfaces” and “if_edoc_adaptor_cloud”. After generating the class, open the interface method and press F3 to view its parameters. To display the documentation, press F2. Activate your BAdI implementation. 

Example Implementation: 

To better illustrate how this enhancement can be used, we’ll walk through two examples, one for a Türkiye Basic eInvoice and another for a Delivery Note. 

Example 1: Türkiye Basic eInvoice 

In this example, we demonstrate how to enhance the XML output using the SET_OUTPUT_DATA method: 

We populate the <PaymentMeansCode> XML tag with a custom value. This tag is located within the <PaymentMeans> tag of the XML structure. We will also fill the <AdditionalDocumentReference> tag with custom values. 

These enhancements are made possible by leveraging the released proxy structures, allowing for seamless customization without any limitations. 

Sample Code: 

 

CLASS zcl_tr_inv_cloud_badi DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_badi_interface .
INTERFACES if_edoc_adaptor_cloud .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_tr_inv_cloud_badi IMPLEMENTATION.

METHOD if_edoc_adaptor_cloud~set_output_data.

  ASSIGN COMPONENT ’DOC_DATA’ OF STRUCTURE cs_output_data TO FIELD-SYMBOL(<lv_data>).
  IF <lv_data> IS ASSIGNED.
* Do Nothing
  ELSE.
    IF iv_edoc_type = ’TR_BINV’.
      IF iv_interface_id <> ’TR_GETSTATUS_REQ’.
        ASSIGN COMPONENT ’PARAMETERS’ OF STRUCTURE cs_output_data TO <lv_data>.
        IF <lv_data> IS ASSIGNED.
          ASSIGN cs_output_data TO <lfs_cs_doc_data>.
          IF <lfs_cs_doc_data> IS ASSIGNED.
            ASSIGN <lfs_cs_doc_data>-parameters-package-elements TO <fs_invoice_tab>.
            IF <fs_invoice_tab> IS ASSIGNED.
              LOOP AT <fs_invoice_tab> ASSIGNING <fs_invoice_el>.
                ASSIGN <fs_invoice_el>-element_list-invoice-payment_means
                   TO <fs_payment_means_tab>.
                CLEAR ls_payment_means.
                ls_payment_means-payment_means_code-base-base-content = ’31’.
                APPEND ls_payment_means TO <fs_payment_means_tab>.

                ASSIGN <fs_invoice_el>-element_list-invoice-additional_document_reference
                                TO <fs_add_doc_ref>.

                ls_issuedate = ’20250520′.

                CLEAR ls_additional_Ref.
                ls_additional_ref-id-base-base-content = ’www.sovos.com’.
                ls_additional_ref-issue_date-base-content = ls_issuedate.
                ls_additional_ref-document_type_code-base-base-content = ’EUPRWEBURI’.

                APPEND ls_additional_Ref TO <fs_add_doc_ref>.               ENDLOOP.
            ENDIF.
          ELSE.
*        elseblock
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.
ENDMETHOD.
ENDCLASS.

Result: 

When you display the XML file of the electronic document in the eDocument Cockpit(EDOC_COCKPIT), you will see that the <PaymentMeansCode> and <AdditionalDocumentReference> tag are now filled: 

Example 2: Delivery Note 

In this example, we show how to enhance the XML output for a Delivery Note document: 

We populate the <DeliveryAddress> XML tag with custom values, specifically filling the postbox and postalzone values. 

 Sample code: 

CLASS zcl_tr_inv_cloud_badi DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_badi_interface .
INTERFACES if_edoc_adaptor_cloud .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_tr_inv_cloud_badi IMPLEMENTATION.

METHOD if_edoc_adaptor_cloud~set_output_data.

  ASSIGN COMPONENT ’DOC_DATA’ OF STRUCTURE cs_output_data TO FIELD-SYMBOL(<lv_data>).
  IF <lv_data> IS ASSIGNED.
* Do Nothing
  ELSE.
    IF iv_edoc_type = ’TR_DELN’.
IF iv_interface_id <> ’TR_DELN_ENVE_STAT_REQUEST’.
      ASSIGN COMPONENT ’PACKAGE’ OF STRUCTURE cs_output_data TO <lv_data>.
      IF <lv_data> IS ASSIGNED.
        ASSIGN cs_output_data TO <lfs_cs_doc_data2>.
        IF <lfs_cs_doc_data2> IS ASSIGNED.

          READ TABLE <lfs_cs_doc_data2>-package-elements ASSIGNING <fs_element> INDEX 1.

          ls_shipment = <fs_element>-element_list-despatch_advice-shipment.
          ls_shipment-delivery-delivery_address-postbox-base-base-content = ’54321′.
          ls_shipment-delivery-delivery_address-postal_zone-base-base-content = ’54321′.
          <fs_element>-element_list-despatch_advice-shipment  = ls_shipment.
        ELSE.
*        elseblock
        ENDIF.
      ENDIF.
    ENDIF.
ENDIF.
  ENDIF.
ENDMETHOD.
ENDCLASS.

Result: 

When you display the XML file of the electronic document in the eDocument Cockpit(EDOC_COCKPIT) , you will see that the <DeliveryAddress> tag are now filled: 

Conclusion 
With recent enhancements to the Türkiye Document and Reporting Compliance solution, SAP has made it significantly easier to tailor electronic document outputs. The necessary structures are now fully available for use within the SET_OUTPUT_DATA method of the EDOC_ADAPTOR_CLOUD BAdI. This allows developers to add or adjust XML elements and populate optional fields based on specific business or legal requirements, without facing previous limitations. 

This improvement gives you more flexibility and helps ensure compliance with Türkiye’s legal requirements. It also speeds up development, as you no longer need to wait for SAP to release specific proxy objects. 

 

​ This blog post introduces a recent enhancement in SAP S/4HANA Cloud Public Edition that significantly improves developer extensibility for the Document and Reporting Compliance solution in Türkiye. This change enables developers to fully utilize the SET_OUTPUT_DATA method in the EDOC_ADAPTOR_CLOUD BAdI, which is used to modify the XML files generated for an electronic document. Background In some scenarios, you would want to enhance the standard XML file generated for an electronic document – for example, to add optional fields or make changes based on specific business or legal requirements. The Document and Reporting Compliance framework provides the SET_OUTPUT_DATA method within the EDOC_ADAPTOR_CLOUD BAdI to support such enhancements. This method allows partners to tailor the generated XML output to meet their needs. This was possible in SAP S/4HANA Private Cloud; however, it was not available in SAP S/4HANA Public Cloud, which limited flexibility for partners using the public cloud edition. However, until now, a key limitation with the Document and Reporting Compliance Türkiye solution was that its service consumer structures were not released. As a result, accessing and modifying XML content through ABAP structures was not straightforward. These structures needed to be made available by SAP for the respective country to enable developer extensibility. Without them, enhancements through the BAdI were either restricted or not feasible. What’s New? To remove this limitation, SAP has now released all proxy objects for the Türkiye Document and Reporting Compliance solution. As a result, developers can fully utilize the SET_OUTPUT_DATA method and enhance the XML output using standard proxy structures without any restrictions. Prerequisites You must have configured developer extensibility role in your configuration environment. The required business role is SAP_BR_DEVELOPER. Implementation Steps in ABAP Development Tools (ADT): In your ABAP project, go to the enhancement spot ES_EDOCUMENT_CLOUD (path: package GLO-EDO > Enhancements > Enhancement Spots). Right-click ES_EDOCUMENT_CLOUD and select New BAdI Enhancement Implementation. Enter a package, name, and description. Choose Add BAdI Implementation and select for EDOC_ADAPTOR_CLOUD. Create a BAdI filter for Country (TR) and/or Generic Filter. Choose Implementing Class to create a new implementation class. The new implementation class automatically implements the interfaces “if_badi_interfaces” and “if_edoc_adaptor_cloud”. After generating the class, open the interface method and press F3 to view its parameters. To display the documentation, press F2. Activate your BAdI implementation. Example Implementation: To better illustrate how this enhancement can be used, we’ll walk through two examples, one for a Türkiye Basic eInvoice and another for a Delivery Note. Example 1: Türkiye Basic eInvoice In this example, we demonstrate how to enhance the XML output using the SET_OUTPUT_DATA method: We populate the <PaymentMeansCode> XML tag with a custom value. This tag is located within the <PaymentMeans> tag of the XML structure. We will also fill the <AdditionalDocumentReference> tag with custom values. These enhancements are made possible by leveraging the released proxy structures, allowing for seamless customization without any limitations. Sample Code:  CLASS zcl_tr_inv_cloud_badi DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_badi_interface .
INTERFACES if_edoc_adaptor_cloud .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_tr_inv_cloud_badi IMPLEMENTATION.

METHOD if_edoc_adaptor_cloud~set_output_data.

  ASSIGN COMPONENT ’DOC_DATA’ OF STRUCTURE cs_output_data TO FIELD-SYMBOL(<lv_data>).
  IF <lv_data> IS ASSIGNED.
* Do Nothing
  ELSE.
    IF iv_edoc_type = ’TR_BINV’.
      IF iv_interface_id <> ’TR_GETSTATUS_REQ’.
        ASSIGN COMPONENT ’PARAMETERS’ OF STRUCTURE cs_output_data TO <lv_data>.
        IF <lv_data> IS ASSIGNED.
          ASSIGN cs_output_data TO <lfs_cs_doc_data>.
          IF <lfs_cs_doc_data> IS ASSIGNED.
            ASSIGN <lfs_cs_doc_data>-parameters-package-elements TO <fs_invoice_tab>.
            IF <fs_invoice_tab> IS ASSIGNED.
              LOOP AT <fs_invoice_tab> ASSIGNING <fs_invoice_el>.
                ASSIGN <fs_invoice_el>-element_list-invoice-payment_means
                   TO <fs_payment_means_tab>.
                CLEAR ls_payment_means.
                ls_payment_means-payment_means_code-base-base-content = ’31’.
                APPEND ls_payment_means TO <fs_payment_means_tab>.

                ASSIGN <fs_invoice_el>-element_list-invoice-additional_document_reference
                                TO <fs_add_doc_ref>.

                ls_issuedate = ’20250520′.

                CLEAR ls_additional_Ref.
                ls_additional_ref-id-base-base-content = ’www.sovos.com’.
                ls_additional_ref-issue_date-base-content = ls_issuedate.
                ls_additional_ref-document_type_code-base-base-content = ’EUPRWEBURI’.

                APPEND ls_additional_Ref TO <fs_add_doc_ref>.               ENDLOOP.
            ENDIF.
          ELSE.
*        elseblock
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.
ENDMETHOD.
ENDCLASS. Result: When you display the XML file of the electronic document in the eDocument Cockpit (EDOC_COCKPIT), you will see that the <PaymentMeansCode> and <AdditionalDocumentReference> tag are now filled: Example 2: Delivery Note In this example, we show how to enhance the XML output for a Delivery Note document: We populate the <DeliveryAddress> XML tag with custom values, specifically filling the postbox and postalzone values.  Sample code: CLASS zcl_tr_inv_cloud_badi DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_badi_interface .
INTERFACES if_edoc_adaptor_cloud .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_tr_inv_cloud_badi IMPLEMENTATION.

METHOD if_edoc_adaptor_cloud~set_output_data.

  ASSIGN COMPONENT ’DOC_DATA’ OF STRUCTURE cs_output_data TO FIELD-SYMBOL(<lv_data>).
  IF <lv_data> IS ASSIGNED.
* Do Nothing
  ELSE.
    IF iv_edoc_type = ’TR_DELN’.
IF iv_interface_id <> ’TR_DELN_ENVE_STAT_REQUEST’.
      ASSIGN COMPONENT ’PACKAGE’ OF STRUCTURE cs_output_data TO <lv_data>.
      IF <lv_data> IS ASSIGNED.
        ASSIGN cs_output_data TO <lfs_cs_doc_data2>.
        IF <lfs_cs_doc_data2> IS ASSIGNED.

          READ TABLE <lfs_cs_doc_data2>-package-elements ASSIGNING <fs_element> INDEX 1.

          ls_shipment = <fs_element>-element_list-despatch_advice-shipment.
          ls_shipment-delivery-delivery_address-postbox-base-base-content = ’54321′.
          ls_shipment-delivery-delivery_address-postal_zone-base-base-content = ’54321′.
          <fs_element>-element_list-despatch_advice-shipment  = ls_shipment.
        ELSE.
*        elseblock
        ENDIF.
      ENDIF.
    ENDIF.
ENDIF.
  ENDIF.
ENDMETHOD.
ENDCLASS. Result: When you display the XML file of the electronic document in the eDocument Cockpit (EDOC_COCKPIT) , you will see that the <DeliveryAddress> tag are now filled: Conclusion With recent enhancements to the Türkiye Document and Reporting Compliance solution, SAP has made it significantly easier to tailor electronic document outputs. The necessary structures are now fully available for use within the SET_OUTPUT_DATA method of the EDOC_ADAPTOR_CLOUD BAdI. This allows developers to add or adjust XML elements and populate optional fields based on specific business or legal requirements, without facing previous limitations. This improvement gives you more flexibility and helps ensure compliance with Türkiye’s legal requirements. It also speeds up development, as you no longer need to wait for SAP to release specific proxy objects.    Read More Technology Blog Posts by SAP articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author