SAP BAPI packageを使用した SAP へのデータ書き込み例
- 最終更新日2022/09/21
SAP BAPI packageを使用して bot をビルドし、SAP データベースにデータを書き込みます。
前提条件
Download the SAP Java connector and dynamic library files (.dll file for Windows automation and .dylib file for macOS automation) from the SAP portal.
このチュートリアルでは SAP デモ フライト データ アプリケーションから BAPI_FLCUST_CREATEFROMDATA を呼び出す bot をビルドします。CUSTOMER_DATA インポート パラメーターを使用して、顧客データを BAPI に渡します。実行すると、bot は、SAP データベースに新規の顧客レコードを作成し、BAPI から返された顧客番号を表示します。
このチュートリアルでは、次の操作の実行方法を紹介します。
- インポート パラメーターに値を設定するには、[構造を取得] コマンドを使用します。
- SAP のテーブルに新しいレコードを作成します。
- BAPI からの応答を受信します。
手順
-
「SAP-BAPI-CreateNewFlightCustomer」という名前の botを作成します。
- Control Room にログインします。
- 左側のペインで [オートメーション] をクリックします。
- [Bot を作成] アイコンをクリックします。
- [名前] フィールドに、「SAP-BAPI-CreateNewFlightCustomer」と入力し、[作成と編集] をクリックします。
-
To connect the bot to your SAP system, from the
Actions panel, find SAP BAPI > Connect action and add it to the Bot editor.
- In JCo: SAP Java Connector package, specify the path to the Java connector .jar file.
-
In JCo DLL/DYLIB dependency,
specify the path to the dynamic library file.
.dll for Windows automation and .dylib for macOS automation.
- Choose Custom Application Server as Connection Type.
-
In Application server host name, specify the
host name of the SAP application server.
注: As a best practice, use the Credential Vault to specify sensitive information such as host name, user name, and password.
- In System number, enter the instance number.
- In SAP instance system ID, enter the system ID.
- In Client number, enter the client number.
- In Logon language code, enter EN or the language specific to your system.
- In Router string, enter the SAP router string.
- In Username, enter your SAP username.
- In Password, enter your password.
-
Run the bot to test the connection.
If you specify the correct connection properties, the bot executes successfully.
-
関数を作成するには、[SAP BAPI] > [関数を作成] アクションを追加します。
- [関数エイリアス名] に、「createNewFlightCustomer」と入力します。
- [BAPI 名] に、「BAPI_FLCUST_CREATEFROMDATA」と入力します。
-
CUSTOMER_DATA パラメーターはタイプ構造なので、インポート パラメーターの構造を取得し、エイリアスに代入します。 これを実行するには、[SAP BAPI] > [構造を取得] アクションを実行します。
- [関数エイリアス名] に、「createNewFlightCustomer」と入力します。
- [構造名] に、「CUSTOMER_DATA」と入力します。
- 取得した構造体をエイリアスで保存するには、[送り先] で [エイリアス] タブをクリックします。
-
[構造のエイリアスを作成] に、「CustomerData」と入力します。
エイリアスを使用して、取得した構造体内のインポート フィールドに値を設定することができるようになります。
-
[CUSTNAME] フィールドに値を設定するには、[SAP BAPI] > [フィールド値を設定] アクションを実行します。
- [関数エイリアス名] に、「createNewFlightCustomer」と入力します。
- [送り元] で、[構造] タブをクリックします。
- [構造のエイリアス] に、「CustomerData」と入力します。
- [フィールド名] に、「CUSTNAME」と入力します。
- [フィールド値] に、「John Doe」と入力します。
-
ステップ 5 を繰り返し、次の各フィールドに [フィールド値を設定] アクションを追加して構成します。
フィールド名 フィールド値 STREET testStreet POSTCODE 101001 CITY testCity COUNTR US COUNTR 00000000 EMAIL test@example.com CUSTTYPE P -
BAPI_FLCUST_CREATEFROMDATA を実行するには、[SAP BAPI] > [関数を実行] アクションを追加します。
- [関数エイリアス名] に、「createNewFlightCustomer」と入力します。
注: BAPI_FLCUST_CREATEFROMDATA がデータを SAP データベースに書き込むようにする場合、シーケンスを終了 と トランザクションを確定 オプションを選択する必要があります。 [シーケンスを終了] オプションを選択する場合、[関数を作成] アクションで [シーケンスを開始] オプションを選択してください。このチュートリアルで作成したサンプル bot は、SAP BAPI packageを使用した場合の Create() BAPI の動作を説明することを目的としています。 データベースの修正については説明していません。
BAPI は、新規顧客レコードの作成後、顧客番号を付与して返します。 -
変数に数値を取り込むには、[SAP BAPI] > [フィールド値を取得] アクションを追加します。
- [関数エイリアス名] に、「createNewFlightCustomer」と入力します。
- [送り元] で、[関数] タブをクリックします。
- [フィールド名] に、「CUSTOMERNUMBER」と入力します。
- [結果を変数に保存] で、[(x)] をクリックして、「strCustomerNumber」という名前の変数を作成し、その変数を選択します。
-
顧客番号を表示するには [メッセージボックス] アクションを追加します。
- [表示するメッセージを入力] で、strCustomerNumber 変数を選択します。
- bot を保存して実行します。