Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
JoeyLi
Product and Topic Expert
Product and Topic Expert
This is a PoC in customer system for embedded analytics, especially embedded SAC. S/4HANA Cloud Embedded SAP Analytics Cloud can enhance the analysis function of the current system and can better help customers analyze business related data. In this blog, the successful PoC of Embedded SAC on Sales Gross Profit Analysis will be shared to readers to show its powerful functions and to introduce the key steps to implement it in detail.

What’s customer’s request?

According to the customer's business scenario, the customer wants to monitor the up-to-date gross profit information. The company needs the sales quantity, price, tax, cost to be collected into one screen to provide a wholistic view about gross profit of each material for each its customer and different amounts to be converted to transaction currency, company code currency as well as group currency. What’s more, the company needs the Currency Conversion for price and sales amount to be evaluated at the time of pricing while the Currency Conversion for cost to be evaluated at the month-end of the reporting period.

In the standard content, Delivery Line item Information (such as customer, product, unit, quantity, transaction currency, etc.), pricing information (net price, tax amount, pricing currency) for sales and inter-company purchasing as well material cost information are delivered in different CDS View and the standard content only exists in standalone version. In conclusion, the standard content can hardly satisfy the customer requirements.

Therefore, embedded SAC has been introduced to the customer to customize the Sales Gross Profit Analysis which can provide the information that the customer wants.

The following table illustrates the basic expectation of the final output according to the customer’s request:














Customer



Customer Name



Material



Material Name



Unit



Quantity Sold



Transaction Currency (TC)



Unit Price


(CC)


















Amount (TC)



Amount (CC)



Amount (GC)



Tax Amount


(CC)



Amount


w/ Tax (CC)



Unit Cost (CC)



Cost (CC)



Gross Profit



Gross Profit Rate



How to solve the problem?

There are four main steps to implement Embedded SAC: creating Custom CDS View, creating Custom Analytical Query, creating Story and creating an Application. The specific steps will be described in detail below. To protect customer sensitive data, some of the screenshots come from dummy test system.

I. Creating Custom CDS Views

In this story, 3 CDS views need to be created. The first one is Interface View YY1_SalesAnaBaseDelivDoc, which can expose the relevant fields (esp. the external keys) from I_DeliveryDocumentITEM and its associations.

Navigate to Custom CDS View APP, create a new CDS view, fill the name and select “Standard CDS View” for the scenario. Add I_DeliveryDocumentITEM as the Primary Datasource and then add parameters.



Add Elements.



Add calculations if necessary, for example, edit the formula of the element “Customer” to select the customers whose DeliveryDocumentType is “LF” & “LR”. The formula is as follows.







case when


I_DeliveryDocumentItem._DeliveryDocument.DeliveryDocumentType = 'LF'


ORI_DeliveryDocumentItem._DeliveryDocument.DeliveryDocumentType = 'LR'


then I_DeliveryDocumentItem._DeliveryDocument.SoldToParty


else I_DeliveryDocumentItem._DeliveryDocument.ShipToParty


end



Then maintain element properties.



Add a filter to improve the performance of reports.



Save and publish the view.

Then create the composite View YY1_SalesAnaBase2. Create a new CDS View and add YY1_SalesAnaBaseDelivDoc as the primary data source, I_InventoryPriceByKeyDate, I_SalesDocItemPricingElement, YY1_POItmPricingElement2, YY1_POItmPricingElement2, and I_SalesDocItemPricingElement as the associated data source. Maintain the join condition and map the association parameter with the view parameter.

Add necessary elements from the primary data sources and associations.



Add Calculations, for example add a formula to calculate the amount without tax.







cast(


case when


YY1_SalesAnaBaseDelivDoc.DeliveryDocumentType = 'LF'


or


YY1_SalesAnaBaseDelivDoc.DeliveryDocumentType = 'LR'


then


cast( YY1_SalesAnaBaseDelivDoc.Sign as ABAP.DEC(1,0) ) *


division(


division(


cast( YY1_SalesAnaBaseDelivDoc.ActualDeliveredQtyInBaseUnit as ABAP.DEC(13,5)) *


cast( _I_SO_GrossPrice.ConditionRateValue as ABAP.DEC(13,5)),


_I_SO_GrossPrice.ConditionQuantity,


5


),


1 + division( coalesce( _I_SO_TaxRate.ConditionRateValue , 0 ), 100, 5 ),


5


)


else


cast( YY1_SalesAnaBaseDelivDoc.Sign as ABAP.DEC(1,0) ) *


division(


cast( YY1_SalesAnaBaseDelivDoc.ActualDeliveredQtyInBaseUnit as ABAP.DEC(13,5)) *


cast( _I_PO_GrossPrice.ConditionRateValue as ABAP.DEC(13,5)),


_I_PO_GrossPrice.ConditionQuantity,


5


) -


_I_PO_Tax.ConditionRateValue


end


as ABAP.CURR( 26, 5 ) )



Maintain Element Properties and then publish it.

Then create Cube View YY1_YY1_SalesAnaCube. Create a new CDS View and choose the “the standard CDS View” for the scenario. Add YY1_SalesAnaBase2 as Primary Datasource and I_ProductText as Associated Datasource. Maintain join condition and parameters. Then Add elements.



Add calculations, for example add formula to calculate Amount (Company Code Currency).







case when YY1_SalesAnaBase2.ConditionCurrency =


YY1_SalesAnaBase2.CompanyCodeCurrency


then


YY1_SalesAnaBase2.AmountWithoutTax


else


currency_conversion(


amount => YY1_SalesAnaBase2.AmountWithoutTax ,


source_currency => YY1_SalesAnaBase2.ConditionCurrency,


target_currency => YY1_SalesAnaBase2.CompanyCodeCurrency,


exchange_rate_date => YY1_SalesAnaBase2.PricingDate,


exchange_rate_type => 'M',


error_handling => 'FAIL_ON_ERROR',


round => 'true',


decimal_shift => 'true',


decimal_shift_back => 'true'


)


end



Maintain element properties.



Save and publish the view.

In the previous steps, the logic of currency conversion is based on the followings.

Condition currency->Company currency

Condition currency->Group currency

If you want to change the logic to Condition currency->Company currency->Group currency, the models should be changed accordingly. Another CDS view Composite View (YY1_SalesAnaBase3) need to be created and select YY1_SalesAnaBase2 as primary datasource and all the parameters and elements. Add calculations in YY1_SalesAnaBase3 as same as the ones in previous YY1_SalesAnaCube, but eliminate calculation AmountWithoutTaxInGC.

Then rebuild YY1_SalesAnaCube. Select primary datasource YY1_SalesAnaBase3, and add associations and all the elements. Add the following calculations in YY1_SalesAnaCube.







case when YY1_SalesAnaBase3.Currency = YY1_SalesAnaBase3.GroupCurrency


then


YY1_SalesAnaBase3.AmountWithoutTax


else


currency_conversion(


amount => YY1_SalesAnaBase3.AmountWithoutTax,


source_currency => YY1_SalesAnaBase3.CompanyCodeCurrency,


target_currency => YY1_SalesAnaBase3.GroupCurrency,


exchange_rate_date => YY1_SalesAnaBase3.PricingDate,


exchange_rate_type => 'M',


error_handling => 'FAIL_ON_ERROR',


round => 'true',


decimal_shift => 'true',


decimal_shift_back => 'true'


)


end



So far the logic has been changed and all the views have been created.

II.Creating Custom Analytical Queries

Choose “Custom Analytical Queries” app from menu Query Design. Create a query and select YY1_YY1_SalesAnaCube as data source. Fill the name (YY1_SALESANAQRY) and label (Sales Overview Query) of the query. Select the field.



Add calculated measure.



Add a mandatory single-value prompt on CompanyCode field.



Then save and publish the query.

III.Creating Story

The Create Story page allows customers to define SAP Analytic Cloud story for a selected data source. Customers can create different visualizations to the data source. Multiple data sources can be added to the story and users can design interactive dashboards, create new pages, and add visualization such as charts, tables, and other graphics to visualize the data. The items on the page such as chart are arranged as tiles that can be moved around, resized, and styled to your liking.

Therefore, we have defined an SAP Analytic Cloud story for the new created data source to visualize the data that the customer wants to show on the page.

Firstly, navigate to KPI Design group in the Fiori Launchpad (FLP).

Choose “Stories” tab from the Manage KPIs and Reports app page and create a custom story.

The Create Story page appears. In the Definition tab, enter the title in the Header section and description in Business Information section. Then go to Configuration tab to define the story. A pre-defined template will be loaded.

Select a query from the list to build the story. Here we choose YY1_SalesAnaQry As Primary Data Source then you can design layout as you prefer.

When the query prompt pops up, enable “Automatically open prompt when story opens” so that end user will be prompted to enter the report period and company code when the story is opened.



Insert Image or Shape as Company Logo,arbitrary text as Report Title or element label(if you prefer). Then insert charts to show data. E.g. Numeric Point Chart to highlight KPI.



Insert Bar Chart with Ranking to Show the Top Customers / Products by Sales Amount.



Then Insert the main Table. Enable Row and Column Header Freeze to facilitate table scrolling.



Add Story Filter to allow end-user to restrict the data set to display.



Activate (Save) the story when the report is completed.



IV.Creating an Application

To create an application (aka FLP Tile) to launch the story, choose Applications > Add Tile. Choose a Tile Type format from the various options.

Fill out all the details and click on “Save and Publish “.


After successful save of the tile, it will navigate to “Custom Catalog Extension” app to publish a tile in the desired catalog.

In “Custom Catalog Extension” App, add a catalog to publish the tile.

Conclusion

In this blog, we show how to create a custom SAP Analytics Cloud Story or Dashboard via S/4HANA Cloud and embed it in S/4HANA Cloud Fiori Launchpad. The customized Sales Gross Profit Analysis can provide all the information the customer required, which fully meets their business needs. By using the S/4HANA Cloud embedded SAP Analytics Cloud, it becomes efficient to help customers solve problems with its powerful function. In the future, we will continue to share more successful stories of embedded analytics to readers.

For more information on SAP S/4HANA Cloud embedded analytics with SAP Analytics Cloud, check out the following links:

· Customer use case of Embedded SAC: how to create custom SAC story and the dashboard in S/4HANA Cloud: click here

· A Customer Use Case of Embedded Analytics in S/4HANA Cloud – Extend the Possibility:click here

· Customer use case of Embedded SAC on Material Stock Analysis: click here

· Customer use case of Embedded SAC on Inventory Aging Report: click here

· Customer use case of Embedded SAC on Inventory Aging Report (Enhanced): click here
4 Comments