LoginSignup
6
0

More than 3 years have passed since last update.

ABAPレポートプログラムにchatbot(SAP Conversational AI)を実装する

Posted at

ゴール

ABAPで作成したアドオンプログラムに、SAP Conversational AIで作成したchatbotを実装する。
ABAPからCAI.gif

ステップ

  1. SAP Conversational AIでchatbot作成
  2. ABAPプログラムにchatbot実装(こちらが本題)

SAP Conversational AIでchatbot作成

こちらは、以下を参照(ステップ2)
SAPUI5アプリケーションにchatbot(SAP Conversational AI)を実装する

ABAPプログラムにchatbot実装

キッカケは以下のSAP Community Blogでした。
How to Integrate a SAP Conversational AI Chatbot with SAP GUI

cl_demo_outputを使用してchatbotを呼び出すだけなので、入力された値をABAP内で使用して、、とかはないです。
ソースコードはこんな感じ(ABAPのハイライトはうまく表示されないみたい)

REPORT y_test_cai.

* Webchat scriptの値
CONSTANTS src       TYPE string VALUE '<srcの値>'.
CONSTANTS channelid TYPE string VALUE '<channelidの値>'.
CONSTANTS token     TYPE string VALUE '<tokenの値>'.
CONSTANTS id        TYPE string VALUE '<idの値>'.

* 画面にボタン表示
SELECTION-SCREEN PUSHBUTTON 1(12) TEXT-b01 USER-COMMAND cai.

* 選択画面イベント
AT SELECTION-SCREEN.

  CASE sy-ucomm.
*   ボタン押下時
    WHEN 'CAI'.
      DATA(html) = |<script src="{ src }" channelId="{ channelid }" token="{ token }" id="{ id }"></script>'|.
      cl_demo_output=>display_html( html ).
    WHEN OTHERS.
  ENDCASE.

※src、channelid、token、idの値は、CAIのWebchat scriptを設定する
image.png

※channelidとかは、TVARVCなどで管理がよいのかも
※cl_demo_outputなのでお遊び的な使い方です

6
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
0