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: 
YatseaLi
Product and Topic Expert
Product and Topic Expert
This blog post is part of a series of technical enablement sessions on SAP BTP for Industries.Check the full calendar here to watch the recordings of past sessions and register for the upcoming ones! The replay of this session available here.


Authors: yatsea.li, amagnani, edward.neveux, jacobtan

Disclaimer: SAP notes that posts about potential uses of generative AI and large language models are merely the individual poster's ideas and opinions, and do not represent SAP's official position or future development roadmap. SAP has no legal obligation or other commitment to pursue any course of business, or develop or release any functionality, mentioned in any post or related content on this website.

Introduction


Large Language Models (LLMs) like ChatGPT and GPT-4 have gained significant popularity with emergent capabilities. In this fourth session of the series, we’ll explore the potentials of GPT in SAP ecosystem, and discuss how SAP partners can leverage this powerful AI technology in combination with SAP technologies to accelerate their solution development processes, and create more intelligent solutions on SAP Business Technology Platform (SAP BTP).

Here list the full blog post series of Exploring the potential of GPT in SAP ecosystem:









Exploring the potential of GPT in SAP ecosystem


Part 1 – GPT in SAP ecosystem

Part 2 – GPT as code assistant for SAP CAP and RAP Application development (this blog post)

Part 3 – Prompt Engineering for Advanced Text Processing on Customer Messages

Part 4 – Integrate with GPT Chat API for Advanced Text Processing

Part 5 – Integrate with GPT Embedding API for Customer Message Classification

In our previous blog about GPT in the SAP ecosystem, we have learned about the basic concepts about LLM and GPT, the storyline about SALifestyle, along with the demo of the intelligent ticketing solution.

In the following blog posts, let’s dive into the step-by-step process of building this Intelligent Ticketing System with GPT. We will begin by utilizing GPT as a code generation assistant for SAP CAP and RAP Application Development under the two personas from the SAP partner, Christine the Consultant, and Daniel the Developer.



In this blog post, we are going to implement the first solution requirement from SALifestyle.

Capturing and tracking customer communication history between the Customer and Service Agent through Customer Interaction record, which encompasses various forms of communication, including in-person conversations, phone calls, emails, live chat, and more. The purpose of customer interactions is to address customer needs, answer questions, provide support, and assist with any concerns. Each customer interaction consists of inbound customer messages and outbound service messages.

 

To fulfill this requirement, we will proceed with implementing the Ticketing Service in the architecture diagram using both SAP CAP and SAP RAP.

GPT as a code assistant for SAP CAP


Let’s see how Daniel can utilize GPT as code generation assistant to implement the ticketing service of the Intelligent Ticketing Solution with SAP CAP.

Daniel now starts his journey of SAP CAP Application Development for the intelligent ticketing solution. However, this time, he will be accompanied by the assistance of GPT throughout the entire lifecycle of SAP CAP development. He will start with jumpstarting a CAP project, followed by Domain Modeling, Defining Services, Adding Custom Logic, and finally, Adding and Fine-tuning UIs.

As a fundamental principle of CAP development, start small and grow overtime. In line with this principle, Daniel will begin by creating a basic CAP solution for the ticketing service, which will allow users to submit an inbound customer message and initiate a customer interaction. By starting with this foundational functionality, the solution can be expanded and enhanced as needed in the future.

1.Jumpstart Project


As usual, Daniel jumpstarts the project with the cds command – cds init <project name>. As a result, the project structure has been created and initialized for the intelligent ticketing solution. Please refer to SAP CAP document for more detail.

2. Domain Modeling


Next, Daniel moves on to step 2, which involves domain modelling for the intelligent ticketing solution. Let's explore how GPT can assist Daniel in domain modelling by watching the following video.



With the help of GPT, Daniel now quickly acquires the CDS model for entities such as Customer, ServiceAgent, CustomerInteraction, and more, along with the sample data.

Here you have the prompts showed in the video.















Use Case#1 Create an intelligent ticketing system with SAP CAP without any description
System Message You are an AI assistant that helps with SAP CAP application development
User Message

Help to create an intelligent ticketing solution with SAP CAP.

cds code:
















Use Case#2 Ask GPT-4 to create an intelligent ticketing system with SAP CAP with a short description of solution from Christine.
System Message Same as #1
User Message

The solution will Capture and Track Customer Communication History:

Keep a comprehensive record of all communication between end customers and service agents. Instead of using the term "ticket," let's refer to it as "customer interaction" to encompass various forms of communication, including in-person conversations, phone calls, emails, live chat, and more. The purpose of customer interactions is to address customer needs, answer questions, provide support, and assist with any concerns. Each customer interaction consists of inbound customer messages and outbound service messages.

Please generate the cds for the data model.

cds code:
















Use Case#3 Ask GPT-4 to update the cds model by adding additional fields and entities within the chat session.
System Message Same as #1
User Message

Update the cds model as below

1.Please add the additional properties to CustomerInteraction entity,
-category representing its business use case, such as Product Review, Customer Feedback, Question & Answer, Technical Support etc,
-title: A short title of the message history of a whole interaction.
-summary: A short summary of the message history of a whole interaction.
-priority, such as very high, high, medium, low etc.
-inboundMessages as an one-to-many composition of a separated entity “InboundCustomerMessage”
-outboundMessages as an one-to-many composition of a separated entity “OutboundServiceMessage”

2.Add new entities for InboundCustomerMessage OutboundServiceMessage with properties below:

InboundCustomerMessage:

An inbound customer message record the message received from customers via multiple channels, having the fields as below:
-based on aspect managed
-key sequence as integer
-key interaction: association to CustomerInteraction
-sentiment
-intent
-customer: association to Customer
-inboundTextMsg as a string of 2000 characters
-summary as a string of 200 characters
-outboundServiceMsg: association to many OutboundServiceMessage

OutboundServiceMessage
An outbound service message is in response to an inbound customer message.It has properties as below:
-key sequence as integer
-key interaction: association to CustomerInteraction
-replyTo: association to InboundCustomerMessage
-outboundTextMsg as a string of 2000 characters
-processedBy
-remark as a string of 200 characters

cds code:
















Use Case#4 Ask GPT-4 to create the csv sample data in csv for cds data model of the intelligent ticketing system.
System Message Same as #1
User Message

Generate sample data in csv format for the all the entities in the cds data model.

csv:

3.Define Services


With the cds data model and sample data, next Daniel will need to define the services of the data model, which exposes the data model as OData. Let's have a look at the demo.



With the assistance of GPT, Daniel now has the ticketing service defined, in which two custom actions summarize() and analyzeSentiment() have been added to the InboundCustomerMessage entity.

Here you have the prompts showed in the video.















Use Case#1 Ask GPT-4 to generate the CDS service within the same chat session
System Message You are an AI assistant that helps with SAP CAP application development
User Message Please generate the CDS service for the cds data model of intelligent ticketing system
















Use Case#2 Ask GPT-4 to update the CDS service by adding actions to InboundCustomerMessage within the same chat session
System Message Same as #1
User Message Update the cds ticketing service by adding the following actions definition to InboundCustomerMessage without implementation
-summarise
-analyseSentiment

4.Add Custom Logic


Next, we move on to the "Add Custom Logic" step. Let's see how GPT can assist Daniel in implementing the actions "summarize" and "analyzeSentiment" for the InboundCustomerMessage. These actions involve calling an external API to summarize and analyze the sentiment of the InboundCustomerMessage. Let's have a look at the demo.



In the generated code, we can see some place holders about the external API endpoints of summarize and analyzeSentiment, which needs to be checked and fixed by Daniel later.

Here you have the prompts showed in the video.















Use Case#1 Ask GPT-4 to implement the actions summarise and analyseSentiment on InboundCustomerMessage
System Message You are an AI assistant that helps with SAP CAP application development
User Message Implement the actions of InboundCustomerMessage in NodeJS
-summarise: Retrieve the InboundCustomerMessage by messageId from database, Call external API to summarise the inboundTextMsg of InboundCustomerMessage.
-analyseSentiment: Retrieve the InboundCustomerMessage by messageId from database, Call an external API to perform sentiment of the inboundTextMsg of InboundCustomerMessage.NodeJS:

5.Add/Refine UI


Next, Daniel creates a Fiori Elements application for Customer Interaction using the SAP Fiori Application Generator, which impresses Christine. However, SALifeStyle also needs to localize the UI in German for their German-speaking users. In the next video, we will see how Daniel instructs GPT to generate the i18n.properties file based on the CDS model and translate it into German for UI localization.



Here you have the prompts showed in the video.















Use Case#1 Ask GPT-4 to generate the i18n.properties for multi-lingo support
System Message You are an AI assistant that helps with SAP CAP application development
User Message Here is my cds model:
<Replace with your CDS model>Now please help to generate i18n.properties for all its fields based on the cds with rules below belowExpected format of PlainLabelName=Label,
for example:
category_code=Category Code
extRef=Ext. Ref.
sequence=Sequencei18n.properties:
















Use Case#2 Ask GPT-4 to translate the i18n.properties into German for multi-lingo support
System Message Same as #1
User Message

Please translate the i18n.properties into German.

i18n_de.properties:

GPT as a code assistant for SAP RAP


Next, let's explore whether GPT can also assist Daniel in creating the same Intelligent Ticketing Solution using SAP RAP.

We are not going to cover the entire life cycle of SAP RAP application development for the Intelligent Ticketing Solution as a managed transactional application. However, we'll show you the initial step of generating the persistent tables and CDS views for customer interaction and inbound customer message entities. Let's have a look at the demo.



Here you have the prompts showed in the video.















Use Case#1 Ask GPT-3.5 to Generate the tables
System Message You are an AI assistant that helps application development with SAP ABAP RESTful Application Programming Model (RAP)
User Message

Please generate the Persistent Database Tables below in SAP RAP

Rule of foreign key definition:
field_name : data_type with foreign key [cardinality] reference_table where field_name =  reference_table.reference_field_name
Example of foreign key definition:
"key travel_id : int4 not null

with foreign key [0..*,1] /dmo/travel_m

where travel_id = /dmo/booking_m.travel_id;"

Table /ZITS/A_CUSTOMER_INTERACTION for storing customer interaction data

The table structure includes the following fields:
-key client as type abap.clnt (client) and is marked as not null.
-key interaction_id as int4
-extRef as abap.char(8)
-category as abap.char(20)
-originChannel as abap.char(8)
-title as abap.char(100)
-summary as abap.char(200)

Table /ZITS/A_INBOUND_CUSTOMER_MESSAGE

An inbound customer message record the message received from customers via multiple channels, having the fields as below:
-key sequence as int4
-key interaction_id as int4 not null with foreign key [0..*,1] /ZITS/A_CUSTOMER_INTERACTION where interaction_id = /ZITS/A_CUSTOMER_INTERACTION.interaction_id
-sentiment as abap.char(10)
-inboundTextMsg abap.char(1000)
-summary as abap.char(100)
-channel as abap.char(5)

ABAP code for table definition:
















Use Case#2 Generate the CSV view I_INBOUND_CUSTOMER_MESSAGE based on A_INBOUND_CUSTOMER_MESSAGE
System Message Same as #1
User Message

Generate the cds view /ZITS/I_INBOUND_CUSTOMER_MESSAGE_M based on table /ZITS/A_INBOUND_CUSTOMER_MESSAGE with joining excluded

ABAP cds view code:
















Use Case#3 Generate the CSV root view entity /ZITS/I_CUSTOMER_INTERACTION_M based on /ZITS/A_CUSTOMER_INTERACTION
System Message Same as #1
User Message

Generate the cds root view entity for /ZITS/I_CUSTOMER_INTERACTION_M based on /ZITS/A_CUSTOMER_INTERACTION with [0..*] composition of /ZITS/I_INBOUND_CUSTOMER_MESSAGE

ABAP cds root view code:

Further resources



Wrap up


We have seen that GPT can be helpful in assisting SAP Application Developer on coding tasks, which can accelerate SAP Partners’ solution development processes. However, AI-generated code may have errors. As a developer, it is your responsibility to review and correct AI-generated code. Never fully delicate to GPT to create a program without human developer in the loop.  We hope you have enjoyed the reading.
1 Comment