Skip to content

harshlm15/service_ticket_LLM2SAP_ABAP_codebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

service_Ticket_LLM2SAP

πŸ€– LLM + SAP RAP Integration Demo

A beginner-friendly demonstration project showing how Large Language Models (LLMs) can be integrated into enterprise applications using:

  • 🧠 OpenRouter (LLM API access layer)
  • 🐍 Python (backend orchestration)
  • 🌐 Streamlit (UI layer)
  • 🏒 SAP RAP (RESTful ABAP Programming Model)
  • πŸ”— OData V2 Web API (SAP communication layer)

This project is designed for non-AI engineers, SAP developers, and beginners in LLM applications who want to understand how modern AI systems connect with enterprise backend systems.


🎯 Purpose of this Demo

Modern enterprise systems are evolving from traditional transactional systems into AI-assisted decision platforms.

This demo shows:

  • How a user can input raw text (incident / issue)
  • How an LLM converts it into structured business data
  • How SAP RAP persists that data in a backend system
  • How OData acts as the bridge between frontend and backend

🧠 High-Level Concept (Simple Explanation)

Think of this system like a pipeline:

User Input β†’ LLM Processing β†’ Structured JSON β†’ SAP OData β†’ RAP Backend β†’ Database

In simple terms:

A user writes something in English β†’ AI understands it β†’ converts it into structured SAP data β†’ SAP stores it


πŸ—οΈ System Architecture

                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚   Streamlit UI     β”‚
                β”‚ (Frontend Layer)   β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚ Python Backend     β”‚
                β”‚ (Orchestration)    β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό               β–Ό                β–Ό
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚ OpenRouter   β”‚  β”‚ JSON Mapper  β”‚  β”‚ SAP OData V2 β”‚
 β”‚ (LLM API)    β”‚  β”‚ Formatter    β”‚  β”‚ Web Service  β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                            β”‚
                                            β–Ό
                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                β”‚ SAP RAP Backend    β”‚
                                β”‚ (ABAP Layer)       β”‚
                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β–Ό
                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                β”‚ Database Table     β”‚
                                β”‚ (ZAI_INCIDENT)     β”‚
                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧩 Components Explained

1. πŸ–₯️ Streamlit (UI Layer)

Streamlit is used to create a simple web interface where users can:

  • Enter raw text (incident description)
  • Click submit
  • View AI-generated structured output

Why Streamlit?

  • Very fast to build UI
  • No frontend framework needed
  • Ideal for prototypes and demos

2. 🐍 Python Backend

Python acts as the brain orchestrator:

It handles:

  • Sending user input to LLM
  • Receiving structured JSON response
  • Cleaning / validating JSON
  • Sending data to SAP via OData

3. 🧠 OpenRouter (LLM Layer)

OpenRouter is used to access LLM models via API.

What it does here:

  • Takes raw user text
  • Converts it into structured JSON

Example:

Input:

User: "SM30 table not allowing new entries"

LLM Output:

{
  "raw_input": "SM30 table not allowing new entries",
  "business_summary": "User cannot add entries via SM30",
  "technical_summary": "Table maintenance view issue or missing authorization",
  "priority": "Medium",
  "sap_module": "ABAP"
}

4. πŸ”„ JSON Processing Layer

Before sending data to SAP:

  • JSON is validated
  • Missing fields are handled
  • Default values are inserted if required

This ensures SAP always receives clean structured data.


5. πŸ”— SAP OData V2 Web API

This is the communication bridge between Python and SAP.

Responsibilities:

  • Accept POST requests from Python
  • Trigger RAP behavior implementation
  • Persist data into ABAP table
  • Return response (201 Created)

6. 🏒 SAP RAP (Backend Layer)

RAP handles:

  • Business logic
  • Data validation
  • UUID generation
  • Default field population
  • Persistence to database

Key responsibilities:

  • Auto-generate incident_id
  • Set created_at
  • Set created_by
  • Enforce status rules

7. πŸ—„οΈ Database Layer

Table: ZAI_INCIDENT

Stores final structured output:

  • Incident details
  • AI-generated summaries
  • Metadata

πŸ”„ End-to-End Flow

Step-by-step execution:

  1. User enters text in Streamlit UI
  2. Python sends request to OpenRouter
  3. LLM returns structured JSON
  4. Python formats and validates JSON
  5. Python sends POST request to SAP OData API
  6. SAP RAP processes request
  7. RAP fills missing fields (UUID, timestamps)
  8. Data is saved in database
  9. SAP returns HTTP 201 Created
  10. Streamlit displays success response

πŸ“¦ Example Request Flow

Input (User)

SM30 is not allowing me to create entries in ZBILL table

LLM Output

{
  "raw_input": "SM30 issue",
  "business_summary": "User cannot create entries in ZBILL via SM30",
  "technical_summary": "Missing table maintenance configuration",
  "priority": "High",
  "sap_module": "ABAP"
}

SAP Response

{
  "d": {
    "incident_id": "generated-uuid",
    "status": "PROCESSED",
    "created_at": "timestamp",
    "created_by": "SAPUSER"
  }
}

βš™οΈ Key Technologies Used

Layer Technology
UI Streamlit
Backend Python
LLM API OpenRouter
SAP Interface OData V2
SAP Backend RAP (ABAP)
Database SAP HANA / Z Table

🚨 Common Issues in This Architecture

1. Missing UUID

  • Usually caused by incorrect RAP numbering configuration

2. 200 instead of 201

  • Happens when update is triggered instead of create

3. Empty fields in response

  • Determination not executed correctly

4. Authentication errors

  • SAP BTP session expiry or incorrect service binding

πŸ’‘ Why This Architecture is Powerful

This system demonstrates:

  • AI transforming unstructured text β†’ structured business data
  • Seamless integration between modern AI APIs and SAP systems
  • Enterprise-grade backend processing with RAP

🧠 Learning Outcome

After understanding this demo, you will know:

  • How LLMs are used in real enterprise systems
  • How SAP RAP handles business logic
  • How APIs connect AI systems with ERP
  • How modern full-stack AI applications are built

πŸ“Œ Summary

This project is a bridge between AI and enterprise SAP systems, showing how:

Natural language β†’ AI β†’ structured data β†’ SAP persistence


Snapshots of the application

Start the application by rough input

image

LLM categorizes based on prompt

image

Further output image


image

You can see it appended in your table in ADT - Eclipse image


Video

Recording.2026-05-10.223153.mp4

OpenRouter Usage (very cheap)

image

About

This is ABAP code base - which handles the streamlit UI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors