Skip to content

Add package 10 - AI / LLM: chat and table summary against a language model - #89

Merged
oblomov-dev merged 2 commits into
mainfrom
claude/ai-ready-llm-samples
Oct 3, 2026
Merged

oblomov-dev merged 2 commits into
mainfrom
claude/ai-ready-llm-samples

Conversation

@oblomov-dev

@oblomov-dev oblomov-dev commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

No sample showed an abap2UI5 app calling a large language model. This repository is the right home: the samples need something beyond abap2UI5, namely an LLM endpoint the system can reach. This PR adds a new package, src/10, branch 10-ai-llm, runs on Cloud + Standard ≥ 7.40 SP08.

The samples

Class Shows
Z2UI5_CL_SMPS_APP_013 Settings and a connection test: provider, destination, model, token limit, request path and API key. The key is write-only and never goes back to a browser.
Z2UI5_CL_SMPS_APP_014 A chat built from FeedInput and FeedListItem. Every question goes out with the conversation so far. The answer comes back in a second roundtrip while the feed shows busy. This is the real call that Z2UI5_CL_SMP_APP_540 in abap2UI5/samples refers to.
Z2UI5_CL_SMPS_APP_015 A table of sales figures plus Summarize with AI. The answer shows in a panel. Prompt hygiene: at most 50 rows, only the needed columns (no internal key, no user name), the data placed between data tags and declared as data in the system prompt.

When no provider is configured, 014 and 015 still start. They show a warning MessageStrip saying what is missing, keep their buttons disabled and send nothing.

Design

  • The apps depend on an interface, not a provider. They know only Z2UI5_IF_SMPS_LLM (chat( system, messages )). Z2UI5_CL_SMPS_LLM_FACTORY reads the configuration and creates one of:
    • Z2UI5_CL_SMPS_LLM_CLAUDE: Anthropic Messages API. POST /v1/messages with headers x-api-key and anthropic-version: 2023-06-01, body {model, max_tokens, system, messages}. The answer is read as the first text key under content, not as content[0], because current models can return a thinking block first. I checked this against platform.claude.com/docs (messages and errors pages).
    • Z2UI5_CL_SMPS_LLM_OPENAI: OpenAI-compatible Chat Completions. POST /v1/chat/completions with Authorization: Bearer, answer from choices[0].message.content. The token limit is sent as max_completion_tokens, because current OpenAI models reject max_tokens. The field name is a constant in the class.
    • Z2UI5_CL_SMPS_LLM_ISLM: SAP ABAP AI SDK (see below).
  • No endpoint, model or key in the code.
    • The endpoint is a destination of the system.
    • Model, token limit, request path and key are one row in the new table Z2UI5_T_SMPS_LLM, maintained with Z2UI5_CL_SMPS_APP_013.
    • There is no default model anywhere.
  • One HTTP transport per stack, created by name behind Z2UI5_IF_SMPS_LLM_HTTP:
    • src/10/01 Z2UI5_CL_SMPS_LLM_SM59: cl_http_client=>create_by_destination with an SM59 destination. For Standard.
    • src/10/02 Z2UI5_CL_SMPS_LLM_CLOUD: cl_web_http_client_manager on cl_http_destination_provider=>create_by_cloud_destination, which uses the BTP destination service and communication arrangement SAP_COM_0276. For ABAP Cloud.
    • Each class activates only on its own stack. Nothing references them statically, so the classes that do activate never depend on the ones that can't.
  • JSON is written and read by hand (Z2UI5_CL_SMPS_LLM_JSON), as the abap2UI5 building-apps guide asks. /ui2/cl_json is not released for ABAP Cloud, and xco_cp_json does not exist on 7.40. The reader reads each string token whole and resolves escapes, the same idea as Z2UI5_CL_SMPS_APP_489. \uXXXX escapes are decoded only in the ASCII range, because decoding beyond it needs a codepage API that differs between the two stacks. This is documented in the class.
  • One exception, Z2UI5_CX_SMPS_LLM. Its text is written for the person fixing the setup. The package raises it through =>raise( ): at the 7.40 floor, RAISE EXCEPTION NEW does not parse, while the shared rule set asks for NEW over RAISE EXCEPTION TYPE. Raising an object created with NEW satisfies both without changing the shared rule block.

SAP ABAP AI SDK (ISLM)

Z2UI5_CL_SMPS_LLM_ISLM (src/10/03) uses these calls:

  • cl_aic_islm_compl_api_factory=>get( )->create_instance( scenario )
  • create_message_container( ), then set_system_role, add_user_message and add_assistant_message
  • get_parameter_setter( )->set_maximum_tokens( )
  • execute_for_messages( )->get_completion( )
  • catches cx_aic_api_factory and cx_aic_completion_api

I checked the class and method names against SAP's own published samples: SAP-samples/abap-cheat-sheets 30_Generative_AI.md and SAP-samples/abap-partner-reference-application tutorial 42, which agree with each other. help.sap.com and developers.sap.com were not reachable from the build environment, so the exact release that first ships the SDK is not verified. Because of that, the class header says "where the ABAP AI SDK is installed" and gives no release number. The factory creates the class by name and says so when it is missing.

Follow-up: check Z2UI5_CL_SMPS_LLM_ISLM on a system with the SDK, including the parameter type of create_instance (passed with CONV #( )), and add the release floor to the package README.

Release floor and lint version

.github/packages.json declares runsOn "Cloud + Standard ≥ 7.40 SP08" but syntax v751:

  • At v740sp08, everything except src/10/02 parses cleanly (I checked this locally).
  • The cloud transport uses released enums (if_web_http_client=>post, if_a4c_cp_service=>service_specific), which need 7.51 syntax.
  • The note field explains this, and it is printed into the generated branch README.

Other changes

  • Overview app: new section "10 - AI / LLM".
  • Root README: rows in all three tables, plus a paragraph on the per-stack client.
  • build-package-branch.mjs now derives the package count from packages.json.
  • "nine" changed to "ten" where it was a live count.
  • SAMPLES.md, catalogue.json and catalogue-derived.json regenerated.
  • Every app's @keywords line includes ai llm chat.

Gates run locally

npm ci, then npm run check. All passed:

  • check:pin
  • abaplint: 0 issues, 189 files
  • check:abap2ui5: 35 files, findings none, render gate 40 documents
  • check:overview
  • check:keywords
  • check:abapdoc
  • check:samples-md
  • check:catalogue, including the contract check
  • check:app-rules
  • check:atc
  • check:prose
  • check:derived

I also simulated the branch build: build-package-branch.mjs 10-ai-llm plus abaplint at v751 plus check-overview, and the same for 09-launchpad. Both passed.

Not verified on a real system

  • No live call was made against any LLM endpoint.
  • No SAP system was available, so none of the following has been confirmed at runtime:
    • activation on 7.40, on a current on-premise release or on BTP
    • the INT4 field in the TABL sidecar, which was written by hand following the existing tables
    • SM59/STRUST TLS behaviour
    • create_by_cloud_destination with a NoAuthentication destination
    • the ISLM SDK calls

Cross-links and AI-ready pointer

  • Z2UI5_CL_SMPS_APP_014 already named Z2UI5_CL_SMP_APP_540 in its header. It now links that class's source on samples main as well. Z2UI5_CL_SMPS_APP_015 now names Z2UI5_CL_SMP_APP_541 (explain this data, with a local deterministic provider) as its counterpart, in the header and in the src/10 README table. The links go live when Add two AI samples: chat assistant and explain-this-data panel samples#871 is merged. The root prose that check-prose-names reads names neither class, so CI does not depend on the order the two pull requests are merged in.
  • README: the AI-ready badge and paragraph samples-controls carries (README: AI-ready badge and a pointer to the agent setup samples-controls#248). It points to the AI page of the documentation, gives the MCP one-liner and lists the two Claude Code plugin commands.
  • After running npm run samples:md, npm run catalogue and npm run derived, no files changed. npm run check passed (exit 0).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Dx9qDRBfuVKdBr8EXrKNXf


Generated by Claude Code

claude added 2 commits October 3, 2026 01:16
…model

Three samples that call a large language model from an abap2UI5 app, in a
new package src/10 (branch 10-ai-llm, Cloud + Standard >= 7.40 SP08):

- Z2UI5_CL_SMPS_APP_013 - settings and connection test: provider,
  destination, model, token limit, request path, API key (write-only)
- Z2UI5_CL_SMPS_APP_014 - chat with FeedInput / FeedListItem, the
  conversation sent with every question, the answer in a second roundtrip
- Z2UI5_CL_SMPS_APP_015 - a table of sales figures summarized with AI,
  with prompt hygiene (row cap, needed columns only, data fenced off)

Provider-neutral: the apps know Z2UI5_IF_SMPS_LLM only, the factory picks
Z2UI5_CL_SMPS_LLM_CLAUDE (Anthropic Messages API), Z2UI5_CL_SMPS_LLM_OPENAI
(OpenAI-compatible Chat Completions) or Z2UI5_CL_SMPS_LLM_ISLM (SAP ABAP AI
SDK) from the configuration table Z2UI5_T_SMPS_LLM. No endpoint, model or
key is in the code.

The HTTP transport exists once per stack and is created by name:
Z2UI5_CL_SMPS_LLM_SM59 (cl_http_client on an SM59 destination, Standard)
and Z2UI5_CL_SMPS_LLM_CLOUD (cl_web_http_client_manager on a BTP
destination, ABAP Cloud). The branch is linted at v751 because the cloud
transport's released enums need it; everything else parses at 7.40 SP08.

Overview app, README tables, packages.json, SAMPLES.md, catalogue.json and
catalogue-derived.json updated; package counts nine -> ten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dx9qDRBfuVKdBr8EXrKNXf
…dy pointer

Z2UI5_CL_SMPS_APP_014 already named Z2UI5_CL_SMP_APP_540 as the screen it
puts a real model behind; it now links its source too. Z2UI5_CL_SMPS_APP_015
names Z2UI5_CL_SMP_APP_541 (explain this data, with a local deterministic
provider) as its counterpart, in the class header and in the package README.

The README gets the AI-ready badge and paragraph samples-controls carries:
the AI page of the documentation, the MCP one-liner and the two Claude Code
plugin commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dx9qDRBfuVKdBr8EXrKNXf
@oblomov-dev
oblomov-dev merged commit 63cc416 into main Oct 3, 2026
24 checks passed
@oblomov-dev
oblomov-dev deleted the claude/ai-ready-llm-samples branch October 3, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants