The Sky’s the Limit with ABAP Cloud in Sales Billing – How We Used Developer Extensibility to Build a Custom App for Manual Invoicing
Giving themselves just two weeks, an ambitious group of SAP S/4HAHA Cloud developers working in Sales Billing recently set out to showcase how quickly they could build a simple (but viable!) custom business solution in an ABAP Cloud development landscape.
The idea was to create a simple app with a highly streamlined UI, based on the ABAP Restful Application Programming Model (RAP), that leverages the business object interfaces (BOIs) recently published for Sales Billing in SAP S/4HANA Cloud, public edition.
Our vision was to enable users to quickly and easily create “manual” customer invoices (that is, invoices without a preceding sales or delivery document) on demand in SAP S/4HANA Cloud, public edition, while sidestepping the usual dependencies that commonly slow down invoice creation. Entering only the customer and the product sold should ideally be sufficient input to create the required invoice.
Read on below for a summary of our insights and results.
For a brief demo of the app in action, see the following video:
The business story driving our selected use case comes from the direct sales scenario, which enables companies to “spontaneously” sell goods (for example, discounted factory rejects) without running through the standard sell-from-stock process and the associated SD document chain, inventory postings, and so on. This scenario demands the capability to quickly create customer invoices on demand, so that they can be presented to customers and posted to financial accounting.
Our technical vision required a new custom business object that enables flexible, draft-based persistence of the billing data that the user enters for their invoice. Looking for a name for both this new object and the project itself, we landed on “Manual Invoice Request” (MIR).
Implementation and Realization
While some developers in the group had prior experience with ABAP Cloud development and the creation of new RAP business objects, other were stepping into a completely new world.
Guided by this official RAP tutorial, we were able to realize the first version of our UI in only two days. Apart from the definition of database tables for the header and items of the new MIR object, the rest was basically provided “out of the box” by the predefined RAP model, including draft handling!
The following graphic provides a high-level overview of the components required for our app.
To keep it simple, our new business object consists of only two entities, representing header and item level of the manual invoice request. The customer’s name and product description were pulled from the relevant back-end master data via associations.
Of course, creating a customer invoice requires additional data beyond just the IDs of the customer and the product sold. We therefore introduced the concept of a “billing unit” to provide this information. The billing unit comprises the sales unit and plant, and, for simplicity, also the document currency to be used. Billing units were assigned to each employee via a second custom table.
To fetch business data such net and tax amounts from the SAP S/4HANA Cloud backend, we chose to implement a mandatory “Prepare Invoice” step that the user triggers manually. This step passes the user-entered data of the manual invoice request, together with the custom table for the billing unit, to the Billing Document Request BOI in the form of an EML (Entity Manipulation Language) request.
The system responds by creating a billing document request in the background, which later serves as an (to the user) invisible preceding document of the customer invoice. The initial response enables us to establish (and later update) the business data and processing status of the manual invoice request.
The following code snippet provides an example of such an EML request to the Billing Document Request BOI:
MODIFY ENTITIES OF I_BillingDocumentRequestTP ENTITY BillingDocumentRequest EXECUTE CreateFromExternalData AUTO FILL CID WITH VALUE #( ( %param = VALUE #( ReferenceLogicalSystem = 'REF_SYSTEM' _billabledocument = VALUE #( ( ReferenceDocument = 'REFDOC01' _item = VALUE #( ( ReferenceDocumentItem = '000010' SalesDocumentType = 'EO01' SalesDocumentItemCategory = 'ED01' BillingDocumentRequestType = 'BDR1' SalesOrganization = '1010' DistributionChannel = '10' Division = '00' TransactionCurrency = 'EUR' Product = 'TG11' Plant = '1010' SoldToParty = '0010100001' BillingQuantity = '2' %control = VALUE #( = if_abap_behv=>mk-on SalesDocumentType = if_abap_behv=>mk-on SalesDocumentItemCategory = if_abap_behv=>mk-on BillingDocumentRequestType = if_abap_behv=>mk-on SalesOrganization = if_abap_behv=>mk-on DistributionChannel = if_abap_behv=>mk-on Division = if_abap_behv=>mk-on TransactionCurrency = if_abap_behv=>mk-on Product = if_abap_behv=>mk-on Plant = if_abap_behv=>mk-on SoldToParty = if_abap_behv=>mk-on BillingQuantity = if_abap_behv=>mk-on ) ) ) %control = VALUE #( ReferenceDocument = if_abap_behv=>mk-on _item = if_abap_behv=>mk-on ) ) ) %control = VALUE #( referencelogicalsystem = if_abap_behv=>mk-on _billabledocument = if_abap_behv=>mk-on ) ) ) ) RESULT DATA(lt_result) FAILED DATA(ls_failed_modify) REPORTED DATA(ls_reported_modify).
After the “Prepare Invoice” step, the end user can decide whether to continue editing (for example, changing a quantity or adding an item) or to trigger invoice creation via the “Create Invoice” button, which creates an actual billing document from the billing document request via the Billing Document BOI.
The following code snippet is an example of such a request to the Billing Document BOI:
MODIFY ENTITIES OF I_BillingDocumentTP ENTITY BillingDocument EXECUTE CreateFromSDDocument AUTO FILL CID WITH VALUE #( ( %param = VALUE #( _reference = VALUE #( ( SDDocument = '1000010877' %control = VALUE #( SDDocument = if_abap_behv=>mk-on ) ) ) %control = VALUE #( _reference = if_abap_behv=>mk-on ) ) ) ) RESULT DATA(lt_result_modify) FAILED DATA(ls_failed_modify) REPORTED DATA(ls_reported_modify).
Results and Outlook
With our custom-built app Manage Manual Invoice Requests (shown below), it’s now possible to create customer invoices in SAP S/4HANA Cloud, public edition, in a lean and simplified way. Note that this is just an SAP-internal proof-of-concept solution and not part of SAP S/4HANA Cloud, public edition.
We hope this blog post provides you with some motivation, and a glimpse of the endless possibilities enabled by combining Developer Extensibility with the business object interfaces (BOIs) of Sales Billing in SAP S/4HANA Cloud, public edition.
Intended as a basic showcase for ABAP Cloud and the ABAP Restful Programming Model, this project was of course based on simplified assumptions and can only provide initial insights and ideas.
To fully support a realistic, end-to-end business process, additional adaptations, improvements, and integrations would be necessary. A very wide range of additional features could be embedded in these kinds of custom apps. This includes event handling, direct navigation to relevant standard apps in the system, inventory stock management, custom field extensibility, and much more.
Nevertheless, we think this simple project should serve as a nice inspiration for what is and will be possible. As additional features are developed for the BOIs in Sales Billing in future, they will increasingly support you in building and running your own custom processes, helping you fulfill your specific business requirements exactly as needed.
For more information about developer extensibility, see SAP Help Portal.
For more information about the released business object interfaces, see SAP Business Accelerator Hub.