Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Martin-Pankraz
Active Contributor








👉🏿back to blog series or jump to GitHub repos🧑🏽‍💻

<< part 1

Hello and welcome back to your ABAP Cloud with Microsoft integration journey. Part 1 of this series got you covered with approvals for travel booking requests handled by Microsoft Teams.

Today we will be re-using the RAP concepts from last time to request a travel booking description proposal during the Fiori create experience using a private GPT model on Azure OpenAI Service. Imagine you are creating travel requests in bulk, and you want the description automatically generated for your inspiration. Anyone else in need of justifying every penny of a business trip? 😵💫

This way you don’t have to come up with boring narratives yourself – or stare at blank fields until your muse pays you a visit. I know, I know… all of you really like creating SAP short texts that people including yourself can’t comprehend 2 days later anymore 😉


Fig.1 Overview of integration flow between Fiori screen powered by ABAP Cloud and Azure OpenAI


For compliance and strong isolation, I am deploying the Azure OpenAI service next to my SAP system in a private virtual network on Azure. It is not reachable from the outside. Learn more about the private connectivity options on the Microsoft docs here.


Fig.2 Architecture view of isolated setup of private SAP S4 instance with private Azure OpenAI


The Microsoft AI SDK for SAP takes care of all Azure OpenAI API specifics on ABAP, so you can completely focus on your business logic on ADT.








🛈 To ensure the usage of the ABAP environment in “on-premises” or private edition scenarios, simply verify the ABAP language version setting on ADT is set to “ABAP for Cloud Development”.

Find the option on the Properties pane under General. Public edition or BTP ABAP environment in any flavor default to ABAP Cloud automatically. Consider defaulting the language on package level for consistency.

Generate the RAP objects on ADT


Like last time, we start our journey from the SAP developer tutorial “How to Create RAP Business Events in an On-Premise system”. Pay a closer look at the adjustments that I made per step mentioned in the tutorial:

  • Step 1: Instead of the tutorial’s bare table definition using data types that likely don’t exist in your S4 system, choose this enriched one from the GitHub repos that supports this blog series. I added the fields Category and Travel Purpose for a more meaningful request to the GPT model.



Fig.3 snippet from enhanced ABAP table definition




  • Step 2: You can skip this since the source table "/dmo/travel", that SAP references again doesn’t exist in your system 😉.


 


Fig.4 Screenshot of enhanced annotations for Booking Fiori app




  • Step 4: Publish your enhanced service and maintain your own 5 values through the Fiori preview screen. The ABAP logic is pulling up to 5 entries as “few shot learning” samples to improve the precision of the request to the GPT model.










🛈 Few-Shot Learning refers to the practice of feeding a machine learning model with a very small amount of training data to guide its predictions.

In our case travel purpose and category of our new entry and 5 already existing bookings from SAP including their descriptions. That has a tremendous influence on the results you will get!


Fig.5 Screenshot of Booking Fiori app preview with maintained values for few-shot learning




  • Skip Step 5 and 6 since we are working from the "save workflow" directly rather than publishing an event. This way we don't need to subscribe and come back for a call to check booking values but can act right away. For event driven approaches have a look at this post.


 


Fig.6 Screenshot from ADT emphasizing the SAP tutorial adjustments


Now, you are all set to run an integration test 😎

Debugging with Fiori Preview and ADT to see the AI SDK for SAP in action


Put a break point on Line 78 of the RAP BO save implementation on “ZEVENT_BP_BOOKINGTP_100” and create a new booking request via the Fiori preview. I supplied the travel purpose “Engineering Connect with SAP” and maintained “Business” as category… aaand GPT thinking of a response…drum roll 🥁


Fig.7 Overview of application flow generating SAP Booking description using Microsoft AI SDK for ABAP


-> Meeting with SAP Labs in India to shape the partnership with Microsoft. Nice one 🤩

See below an excerpt from my SAP database that underlies the RAP BO that are fed as few-shot samples on each request to Azure OpenAI.


Fig.8 Screenshot of ZBOOKING table entries underlying RAP BO from ADT SQL viewer


For a little more fun, let’s supply “Sabbatical” and “Leisure” to see what GPT thinks about that…


Fig.9 Screenshot form Fiori preview after GPT response


Not too bad either. Getting inspired is half the game in our modern tech world in my opinion.

Engineer your prompt on the Azure OpenAI studio more effectively


To figure out a prompt that fits the purpose of this blog took a couple of iterations, as you can imagine. I recommend tuning your desired prompt on the chat playground on Azure for ease of use.

This way you save the effort of always activating ABAP objects and switching between Fiori and ADT all the time.


Fig.10 Screenshot Azure AI Studio with few-shot sample for SAP booking request in Chat


Once you are happy with your prompt result, transfer the texts, parameters and settings to the Microsoft AI SDK for SAP on ABAP and you are good to go. Heard about GPT result drift?

Well, in the AI world answers from GPT models are not deterministic. On the other hand, we don’t care about that in our scenario. The generated travel-description serves to inspire the SAP Business User in his create-experience and accelerate the data entry process. The user may edit the proposal or discard entirely if not applicable.

If you are having fun doing that, because of absurd GPT responses, all the better 🤪

In case precision and reproducible answers are what you are after, you will need to go beyond few-shot learning and consider chaining GPT with a domain-specific model or traditional Machine Learning. However, creative text generation really shines with GPT.

To learn more about the tuning of GPT-enabled apps by chaining requests with another model have a look here. Also read about the concept of “grounding”, which Microsoft uses to increase the relevance/plausibility of prompts for its various Copilots.

What if I want pure ABAP without any SDKs?


Grab whatever lower-level ABAP calls you need from Microsoft AI SDK for SAP or ABAP SDK for Azure and implement from scratch if you prefer that.

The base class for http calls cl_http_client or cl_rest_http_client still require the wrapper-class approach for ABAP Cloud  with ABAP API state “C1 release” though.

From there you may use the Azure OpenAI REST interface for chat-completions to implement.

However, using the Microsoft AI SDK or even only code snippets speed up your integration effort, because it is shaped by ABAP developers on the community and Microsoft internal SAP teams working on some of the largest SAP landscapes in the world.

For event-driven approaches, see this blog post.

What else is happening around GPT with ABAP Cloud?


See the GPT for RAP series by SAP Champion yatsea.li for further inspiration.

Beyond that, I encourage you to follow our SAP+Microsoft YouTube channel 🎥 for the latest updates. It regularly features GPT cases.

Final Words


That’s a wrap 🌯you saw today how you can enhance the SAP RAP logic from the S/4HANA Cloud ABAP environment private edition to make use of generative AI via the Azure OpenAI service. It is fully private and can live right next to your SAP on Azure system to keep your sensitive data safe🔐and only be available to you and only you.

The Microsoft AI SDK for ABAP simplifies the integration by abstracting away the REST calls while supplying native ABAP objects to work with.

#Kudos to andre.fischer for speeding me up big time on RAP. Can warmly recommend his RAP posts and BO generator. And last but not least thanks to 2389233da7d647c1bb18997c0af96361 + spandanagn for showing me around the AI SDK's ins-and-outs relating to ABAP.

Find all the resources to replicate this setup on this GitHub repos. Stay tuned for the remaining parts of the steampunk series with Microsoft Integration Scenarios from my overview post.

Cheers

Martin
Labels in this area