Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
ThomasSchneider
Product and Topic Expert
Product and Topic Expert

In this document, I will outline how to create a partner application with SAP Business ByDesign Studio and integrate it with SAP Business ByDesign Financials.

Why is this important? To my believe Financials is one of the silver bullets for SAP in the OnDemand market. In his inspiring blogCan Financials People Love the Cloud Jim Daddario elaborated the precondition for an OnDemand Financials solution. Who can fulfill these requirements better than SAP? On the other hand an OnDemand Financials solution asks for integration. Nobody can clerks expect to enter financials data manually into the system – not even in an SME company. There are three ways how data may flow into the Financials:

  1. By using a business suite (ByDesign) that is closely integrated with Financials  
  2. By using APIs from Financial, for example for uploading invoices or point of sales data
  3. By partner “micro-vertical” applications (add-on solution) integrated with Financials

In this blog, I will outline the third option. Here is the use case: Ann Snyder, assistant  to the management of the event agency “Global Concerts“ is responsible for the maintenance of the event schedule, which is the basis for ticket ordering over the internet. Ann updates the schedule every evening on her iPhone using an Event Management application, which is provided by an SAP partner. SAP partner Systematics  identified the market opportunity for an Event Management mobile application for the SAP OnDemand platform. Walter Baumann, managing director of Systematics, calls the developer Bernd Keller and asks for a prototype that can be shown to a prospect the next day. Walter mentions that the prospect is already using ByDesign Financials and that he would like to convince the prospect of a tight integration of an Event Management mobile application with their Financials application. So, Bernd starts SAP Business ByDesign  studio, and … here our demo starts.

Figure 1 shows the business object model. We will create two custom business objects called Event Series and Event. For example the event management organizes a series of events of the opera Aida. The business objects are mirrored in Financials: the event series is mirrored by a cost object business object (full name Financials Accounting View Of Cost Object) and the event is mirrored by the Financials Notification business object.

Figure 1: Sceanrio Overview

Here we go. The complete prototype takes about 30 minutes.

1. First, I will define the business object EventSeries in ByDesign studio, save and activate it:

import AP.Common.GDT as apCommonGDT;
import AP.FinancialAccounting.Global;

businessobject EventSeries {

             [AlternativeKey] element ID : ID;
             element Name : LANGUAGEINDEPENDENT_LONG_Name;
             element StartDate : Date;
             element EndDate : Date;

             element CostObjectTypeCode : CostObjectTypeCode;
             element CompanyID : OrganisationalCentreID;
             element ProfitCentreID : OrganisationalCentreID;
             element SalesUnitID :  OrganisationalCentreID;
             element DebtorID : BusinessPartnerID;
             element ProcessingStatusCode : ProcessingStatusCode;

            association ToCostObject to FinancialAccountingViewOfCostObject;

            action PostToFinancials;
}

2. On top of the EventSeries custom business object, I will create a UI (work center view with object work list and quick activity) for creation and editing. The UI for the prototype is completely generated. So, I just have to select the business object, select Create screens from the context menu and choose Create scenario in the dialog box. The system creates work center (view), object work list and a quick activity (figure 2). I can immediately start the UI from the studio and enter the data for the first event AIDA_2012 and save the data. Later, I will open the UIs in the UI Designer tool and do the fine-tuning for the UI, for example by adding object value selectors to input fields for company, profit center, and so on.

Figure 2: UI: Object Work List and Quick Activity

3. I will then I will define the Event business object in ByDesign studio, save and activate it:

import AP.Common.GDT as apCommonGDT;
import AP.FinancialAccounting.Global;

businessobject Event {

            [AlternativeKey] element ID : ID;
             element Name : LANGUAGEINDEPENDENT_LONG_Name;
             element Date : Date;
             element Amount : Amount;
             element EventSeriesID : ID;
             element EventSeriesName : LANGUAGEINDEPENDENT_LONG_Name;
             element CostObjectTypeCode : CostObjectTypeCode;
             element CompanyID : OrganisationalCentreID;
             element ProfitCentreID : OrganisationalCentreID;
             element SalesUnitID :  OrganisationalCentreID;
             element DebtorID :BusinessPartnerID;
             element ProcessingStatusCode : ProcessingStatusCode;

             action PostToFinancials;
}

4. On top of the Event custom business object, I will create a UI (work center view with object work list and quick activity) for creation and editing. This is pretty the same as for the EventSeries business object.

Now I will implement the business logic. For a minimal prototype I have to implement three events/actions: (1) the AfterModify event for the Event business object, (2) the PostToFinancials action of the EventSeries business object and (3) the PostToFinancials action of the Event business object.

5. I select the EventSeries business object and select Create script files from the context menu and choose the PostToFinancials action in the dialog box. The system creates a script file called PostToFinancials. In this script file I want to create the mirror of the Aida event series as cost object in Financials. How do I start with this? Fortunately, as of FP3.5, ByDesign studio has included a documentation for all business object that include example script coding. So I start the Microsoft Help Viewer in the studio (Help -> View Help) and, I enter the search string “cost object”. A number of hits is displayed and one the first hits is FinancialAccountingViewOfCostObject. When opening it, I scroll down to the following example code, as shown in Figure 3.

Figure 3: Documentation of the FinancialAccountingViewOfCostObject business object

I copy the code to my script file and adopt it to my business object so that it looks like (not completely printed here):

import ABSL;
import AP.FinancialAccounting.Global;

//Create a new Cost Object instance with the specified values
var instFAVOCO_Root = FinancialAccountingViewOfCostObject.Create();

//Cost Object ID - needs to be unique
instFAVOCO_Root.CostObjectID = this.ID;

//Set Cost Object Type Code
instFAVOCO_Root.CostObjectTypeCode = this.CostObjectTypeCode;

//Company ID
instFAVOCO_Root.CompanyID = this.CompanyID;

//Set the referenced BusinessObject to the partner BusinessObject (this-reference)
instFAVOCO_Root.CostObjectReference.ObjectTypeCode = this.GetObjectNodeReference().ObjectTypeCode;
instFAVOCO_Root.CostObjectReference.UUID = this.GetObjectNodeReference().UUID;

6. I select the Event business object and select Create script files from the context menu and choose the PostToFinancials action and the AfterModify event in the dialog box. The system creates a script file called PostToFinancials and a script file called AfterModify. In the script file PostToFinancials I want to create the mirror of the Aida event at a specific date as posting in Financials. The procedure is pretty the similar to the step before. This time, I search for “financials notification”. The example coding is a bit longer, because I have to post a document header and two items (a Sales Item and a Debitor Item, for example so that the resulting balance in Financials is always zero!).

7. The third event I will implement for my prototype is the AfterModify event of the Event business object. Here is the coding:

var eventSeries;
eventSeries = EventSeries.Retrieve(this.EventSeriesID);
if (eventSeries.IsSet()) {
       this.EventSeriesNameeventSeries.Name;
       this.CompanyID = eventSeries.CompanyID;
       this.ProfitCentreID = eventSeries.ProfitCentreID;
       this.SalesUnitID = eventSeries.SalesUnitID;
       this.DebtorID = eventSeries.DebtorID;
       this.CostObjectTypeCode = eventSeries.CostObjectTypeCode;

}
       else {
       this.EventSeriesID.Clear();
       this.EventSeriesName.Clear();
       this.CompanyID.Clear();
       this.ProfitCentreID.Clear();
       this.SalesUnitID.Clear();
       this.DebtorID.Clear();
       this.CostObjectTypeCode.Clear();
}

What does the coding do? It validates the element EventSeriesID that is exposed as input field on the Event UI. If the user enters a valid entry (supported by the object value selector, which can be attached to the input field), it successfully retrieves an instance of the EventSeries business object and reads the data like name, company ID, etc. from it. If the retrieve is not successful, it clears the respective elements of the Event business object.

I shall not forget to save and activate the script files!

8. There is one last step that I have to do before I can test the complete scenario – I have to configure a cost object type in Financials. For different types of events, I may configure different cost object types, for example “Operas”, “Concerts”, and so on. To do so, I select in ByDesign studio Business Configuration -> Create a Business Configuration Set. I select Use SAP Business Configuraiton Object and select Cost Object Type. I create a cost object type “Operas” by giving it a code and description. There is a second configuration that I need to do in Financials for a configuration object called BusinessTransactionDocumentItemLink. I have to activate the two configuration entries and deploy them to the tenant (Business Configuration -> Deploy Business Configuration). At this point, it is time to get a coffee 😉

9. Now, finally I will test the UIs. First I open the Event Series OWL from the studio, open the event series that I created before with the Edit button enter valid data cost object type, company and so on, and click PostToFinancial. The business objects action creates the cost object in Financials. I click the save button to complete the transaction. Then, I open the Event UI, enter an event, enter the event series ID of the previously created event series. The UI will trigger the AfterModify event and read the data from the event series. Then I click PostToFinancial and Save. Now, the event is posted to Financials. The result is visible in the ByDesign Financials General Ledger work center in the Journal Entries view.

Figure: ByDesign Financials General Ledger work center - Journal Entries view Created from the Custom Application

Let me summarize:

  • The creation of the custom BOs, the generation of the UIs, the implementation of the business logic and the configuration of a new cost object type in Financials takes us about 30 minutes for a quick prototype
  • ByDesign Financials is open for integration of partner apps. More integration capabilities to come … based on the partners demand
  • In FP2.6 and FP3.0 partners had a hard time with ByDesign studio one major issue was the missing documentation. In FP3.5 we documented numerous business objects including example coding for create, read, …  This of course includes full text search, ... 

You will understand, this blog is rather an appetizer than a step by step guide. But you can see it live at DKOM 2012 in Karlsruhe together some more features, for example mobile UI (of course, we cannot show a demo without mobile app). Visit us in Karlsruhe at our demo pod! 

5 Comments