/
SAP Invoice form extensibility

SAP Invoice form extensibility

Based on official documentation: How to Extend a Custom Form Template for Billing Output with Custom Fields

Introduction

In this post we will detail how to extend a standard form to contain a new field, the case that is exposed as an example is the standard form of financial document to add a TicketBAI QR and assign it as the default form to be printed, but can be extrapolated to any standard form of SAP S4HANA Cloud.

If the objective of this guide is to implement the TicketBAI requirement for the billing form, it is necessary to include two fields: the QR and the TicketBAI code. However, this guide only addresses the implementation of the QR to simplify the process. To implement other fields, steps 2, 3 and 4 must be repeated.

Steps to follow

  1. Find the form in question and copy it.

For our case we go to the application “Change Billing Document” select a recent invoice and enter the detail. In the detail screen we go to the menu Goto > Header > Output.

image-20241009-145749.png

In the case of the example, the form is standard since it does not begin with Y or Z.

image-20241009-145806.png

Once we have found the form we go to the “Maintain Form Template” application and copy the form.

We will assign the name we want and save.

 

  1. Enlarge the invoice with the new field.

Video: Add Custom Fields to Form Templates for Billing Output , part 1: Create Custom Field and Implement Custom Logic

In the “Custom fields” application we will create a new field and we will give it the name we want to use in our case QR_TBAI. The business context is super important as it will define where the field can be used, in S4HANA, when creating a field this applies not only to a structure or a BADI, but it is enabled to be activated in any, for example with the context “Sales: Finance document” we can activate the field to appear in CDS, forms, APIS, BAPIS, emails, etc, all related to the business context.

We are going to activate the field to appear in our form, go to the “Form Templates” section and activate our form (in the case of the screenshot it is already activated). It is normal that dependent objects are activated.

  1. Modify the Form to show the new field.

From the “Install Additional Software” App we download the Adobe® LiveCycle® Designer and install it on our computer.

Download the form we created earlier from the “Maintain Form Templates” app and unzip the ZIP file on our computer.

Open Adobe® LiveCycle® Designer, select “Open Form” and select the XSD starting with YY1 that was downloaded earlier when unzipping the ZIP file. If messages appear, accept everything.

For our example we are going to add a QR, so in the “Object Library” menu on the right we select “QR Code” and drag it to the place in the form where we want it to appear.

In the case of regulations such as TicketBAI it is important to review the specification of the requirement, as it must be met “See Annex IV of ”.
Once the QR has been dragged to the form we are going to “bind” it with the field we created previously, from the Binding screen, once selected with double click the QR in the form, we select our field (not the one that ends in F).

TIP: If we want an element to be shown only when it has information we must do the following:
With the element selected, at the top of the screen we select “Show: Validate” and add the following script.

// Hide field if data is not bound or the field value is empty if (this.isNull) then this.presence = "inactive"; endif 1; //returns true for validation

Save and upload the template using the “Maintain Form Templates” application.

  1. Implement the logic so that the field is filled in when the form is generated.

In the “Custom logic” application for the business context “Sales: Billing Document” create a new implementation for the following extension point:

We publish and edit the code to implement our logic, in our case it would be to retrieve the TicketBAI URL through the journal entry associated with the finance document, save and activate!

* This method can be used to set values for output to billing document header extension fields. * Example: * * First of all assign existing extension field values to output parameter: billingdoc_extension_out = billingdoc_extension_in. billingdocdescr_extension_out = billingdocdescr_extension_in. select single url from /tbai/r_registrotp where companycode = @billingdoc-companycode and accountingdocument = @billingdoc-accountingdocument and fiscalyear = @billingdoc-fiscalyear and estbai = @abap_true into @billingdoc_extension_out-yy1_qr_tbai_bdh.
  1. Configure the form to be the default form.

Video Add Custom Fields to Form Templates for Billing Output, part 3: Final Configuration Steps and Testing

This point is a task of the functional team and varies depending on whether or not the customer has the Custom Business Configurator (CBC) activated for the system or not, we must do 2 things, register the template in the accounting document template master, and then assign it so that when the template is determined, our template appears.

From the CBC we must go to the activity “Configure Your Business Processes” (if it is not available we must talk to the functional team to do it) to “Assign Form Templates”.

You can try to access directly using the following url:
<host>/ui#IMGActivity-execute?IMGActivity=APOC_C_FORMV&CustomizingObject=APOC_C_FORMV&CustomizingObjectType=V&CustomizingProject=&CustomizingTransaction=S_ER9_68000005&Type=SSCUI

We create a new entry for our template:

To have our template determined, in the “Output Parameter Determination” application we look for the “Billing Document” table “Form Template” and change the default form for our scenario.

With this we will have made the extension of the form as well as assigning it as the default form in our system.

Avvale 2024