Google Cloud Platform (GCP) offers a wide range of Artificial Intelligence (AI) and Machine Learning (ML) Products which can help businesses to automate tasks, improve decision-making, and personalize experiences. One such GCP offering is BigQuery Machine Learning (ML) models that support a variety of use cases such as Running Predictions and Demand Forecasting . In this blog post, we will explore how customers can natively consume predictions of BigQuery ML models from their SAP landscape by using ABAP SDK for Google Cloud, a new addition to Google Cloud SDK.
A new online retailer uses SAP to enter and process customer orders. The retailer wants to optimize and streamline the order fulfillment process. Specifically, the retailer wants to select the most cost efficient “Order Routing” option among:
The decision depends on a variety of factors such as:
Imagine an order handling specialist sifting through multiple datasets and running complex queries to decide the optimal order routing. This would be a cumbersome process, often leading to errors, increased operational costs, and unhappy customers.
In the below sections, we will explore how the retailer can solve this problem by using BigQuery ML and ABAP SDK for Google Cloud.
By implementing the below solution using ABAP SDK for Google Cloud, the retailer can achieve the following efficiencies.
If you are new to BigQuery, please take a moment to familiarize yourself with:
Once the dataset is created and is ready, data can be loaded to BigQuery. Then, with just 2 SQL commands, the retailer can create and train a ML model, and run “Order Routing Predictions” on their dataset. As new data gets loaded to BigQuery, the model is continuously trained to provide better predictions.
After setting up a BigQuery ML model in GCP, the retailer’s ABAP Developers can use ABAP SDK for Google Cloud to:
All from within the SAP landscape and using the programming language they are familiar with — SAP ABAP.
In the sections below, we will dive deep into various steps in GCP and SAP.
Let’s take a look at some key configurations that should be completed on GCP and SAP.
CREATE OR REPLACE MODEL `bqml.zorder_routing`
OPTIONS (model_type='linear_reg',
input_label_cols=['delivery']) AS
SELECT * FROM `ORDER_ROUTING_DEMO.zrouting_sap_data`
WHERE delivery IS NOT NULL
SELECT * FROM
ML.PREDICT (
MODEL`bqml.zorder_routing`,
(SELECT * FROM`ORDER_ROUTING_DEMO.zrouting_sap_data`
WHERE delivery IS NOT NULL))
Note: Above are sample commands. Refer to the documentation for detailed instructions on how to implement BigQuery ML models based on your needs.
Now that the configuration steps are complete, it’s time for an ABAP Developer to implement the solution in SAP by using ABAP SDK for Google Cloud.
First, SAP Outbound delivery data is published to a Pub/Sub topic by using ABAP SDK Pub/Sub API Client Stub class /GOOG/CL_PUBSUB_V1 within the implementation of SAP Outbound Delivery BADI LE_SHP_DELIVERY_PROC. The data published to Pub/Sub is replicated to BigQuery in real time, thanks to the subscription that was set up in GCP.
DATA:
ls_input_sap TYPE /goog/cl_pubsub_v1=>ty_023.
LOOP AT it_xlips REFERENCE INTO DATA(ls_lips).
DATA(lv_json_obj_sap) =
/ui2/cl_json=>serialize(
data = VALUE t_payload_sap(
delivery = ls_lips->vbeln
* ......... other attributes
item = ls_lips->posnr )
pretty_name = /ui2/cl_json=>pretty_mode-low_case ).
APPEND VALUE #(
data = cl_http_utility=>encode_base64( lv_json_obj_sap ) )
TO ls_input_sap-messages.
ENDLOOP.
TRY.
DATA: lo_client TYPE REF TO /goog/cl_pubsub_v1.
CREATE OBJECT lo_client
EXPORTING
iv_key_name = 'DEMO_PUBSUB'.
CALL METHOD lo_client->publish_topics
EXPORTING
iv_p_projects_id = CONV #( lo_client->gv_project_id )
iv_p_topics_id = 'DEMO_ORDER_DATA_SAP'
is_input = ls_input_sap
IMPORTING
ev_ret_code = DATA(lv_ret_code)
ev_err_text = DATA(lv_err_text).
CATCH /goog/cx_sdk INTO DATA(lo_exception).
"Appropriate Error Handling
ENDTRY.
Below flow shows how data from SAP application lands in the BigQuery table.
The BigQuery ML model then predicts the routing with a certain level of accuracy, which is read directly from SAP by using ABAP SDK.
Below UI5 application provides a better visualization of the routing predictions from BigQuery ML Model.
This UI5 application can be used for “human in the loop” scenarios such as Ad Hoc validation of ML results or when the prediction accuracy percent is lower than a certain threshold. The user can override the routing based on their judgment and upon saving, routing value will be sent back to BigQuery via Pub/Sub. This process will continuously train the BigQuery ML model to provide more accurate predictions for future datasets.
These BigQuery ML Models can also be managed directly in Google Vertex AI Platform and what’s more, the inferences of Vertex AI models can be read from SAP by using the Vertex AI API Client Stub class /GOOG/CL_VERTEXAI_V1.
As demonstrated in this use case, ABAP SDK for Google Cloud provides capabilities to use real-time inferences and continuously tune models, right from the SAP landscape.
Ready to start using ABAP SDK for Google Cloud?
Bookmark What’s new with the ABAP SDK for Google Cloud for the latest announcements and follow installation and configuration instructions.
Check out these blog posts to get started with ABAP SDK for Google Cloud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |