SAP の連携ツールである SAP Integration Suite を使用して SAP Datasphere からデータを抽出するには、以下の2つの方法があります。本ブログでは①の方法について紹介します。
① SAP Datasphere の OData サービスを利用したデータ抽出(本ブログ)
② SAP Datasphere データベースユーザでの JDBCを利用したデータ抽出(別ブログにて記載)
今回は下記のバージョンで検証を行いました。
SAP Datasphere : バージョン2024.16.46
SAP Integration Suite : バージョン 3.66.0
SAP Datasphere で OAuth クライアントを作成する
ポイント
ここから具体的な方法を紹介します。
1.SAP Datasphere にログインします
2.トップページのナビゲーションバーから システム > 管理 を選択します
3.[アプリ統合] タブをクリックします
4.OAuth クライアント の [+ 新規 OAuth クライアントを追加] をクリックします
5.以下の情報を入力し、[追加] ボタンをクリックして OAuth クライアントを作成します
参考: OAuth 2.0 Authorization Code Grant
6.[シークレットコードをコピー] ボタンをクリックしてクリップボードにコピーしたクライアントシークレットをメモ帳などにコピーしておきます
7.併せて “OAuth クライアント ID” もメモ帳などにコピーしておきます
8.[アプリ統合] タブの OAuth クライアントに表示されている “権限 URL” と “トークン URL” もメモ帳などにコピーしておきます
1.SAP Integration Suite にログインします
2.Monitor > Integrations and APIs をクリックします
3.Security Material のタイルをクリックします
4.[Create] をクリックして表示されるコンテキストメニューから [OAuth2 Authorization Code] を選択します
5.Create OAuth2 Authorization Code ダイアログで以下の情報を入力し、[Deploy] ボタンをクリックします
作成した OAuth2 Authorization Code の Status が Unauthorized になっているので、認証をおこないます
6.作成した OAuth2 Authorization Code の [More] ボタン( ... )をクリックして表示されるコンテキストメニューから [Authorize] を選択します
7.Information ダイアログで内容を確認し、[OK] ボタンをクリックします
8.SAP Datasphere のログオン画面で、ユーザ名とパスワードを入力して [ログオン] ボタンをクリックします
9.認証成功のメッセージを確認します
10.OAuth2 Authorization Code の Status が Deployed になっていることを確認します
1.SAP Integration Suite のホームページから Design > Integrations and APIs をクリックします
2.[Create] ボタンをクリックしてコンテンツパッケージを作成します
3.以下の情報を入力して [Save] ボタンをクリックします
4.Artifacts タブに移動します
5.Add をクリックして表示されるコンテキストメニューから [Integration Flow] を選択します
6.Add Integration Flow ダイアログで以下の情報を入力し、[Add] ボタンをクリックします
デプロイ時に一回だけ起動し、SAP Datasphere からデータを取得する Integration Flow を作成します
7.Artifacts から追加した Integration Flow を選択します
8.右のような Integration Flow を作成します
9.Groovy Script の Processing タブをクリックします
10.Script File の [Select] ボタンをクリックします
11.Select Resource ダイアログで、Local Resources タブをクリックして、[Upload from File System] ボタンをクリックします
12.次のコードが記述されている Groovy Script ファイルをアップロードします(エディタ上で直接コードを記述することも可能です)
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.securestore.SecureStoreService;
import com.sap.it.api.securestore.AccessTokenAndUser;
import com.sap.it.api.securestore.exception.SecureStoreException;
import com.sap.it.api.ITApiFactory;
def Message processData(Message message) {
SecureStoreService secureStoreService = ITApiFactory.getService(SecureStoreService.class, null);
AccessTokenAndUser accessTokenAndUser = secureStoreService.getAccesTokenForOauth2AuthorizationCodeCredential(“Datasphere_AuthCode");
String token = accessTokenAndUser.getAccessToken();
message.setHeader("Content-Type", "application/json");
message.setHeader("Authorization", "Bearer "+token);
def messageLog = messageLogFactory.getMessageLog(message);
if (messageLog != null) {
messageLog.setStringProperty("logging#1", "accessTokenAndUser=" + accessTokenAndUser.toString());
messageLog.setStringProperty("logging#2", "token=" + token);
}
return message;
}
13.HTTP の Connection タブをクリックし、以下の情報を入力します
※データを取得する SAP Datasphere の OData API については、こちらのヘルプページをご参照ください。今回はアクセス可能なスペースを一覧で取得するOData APIを利用したため、 https://<tenant_url>/api/v1/dwc/catalog/assets としています。
1.[Save] ボタンをクリックします
2.[Deploy] ボタンをクリックします
3.Confirmation ダイアログで Runtime Profile でCloud Integrationを選択して、[Yes] ボタンをクリックします
4.Deployment ダイアログで [OK] ボタンをクリックします
5.Deployment Status タブをクリックし、Deployment Status と Runtime Status を確認します
6.Navigate to Manage Integration Content リンクをクリックします
7.Manage Integration Content 画面で実行状態を確認します
8.Integration Flow の実行をトレースするためにLog Configuration の Log Level を Trace に変更します
9.Integration Flow の Edit 画面で再度 [Deploy] ボタンをクリックし、Integration Flow をデプロイします
1.Monitor > Integrations and APIs をクリックします
2.Monitor Message Processing の All Artifacts タイルをクリックします
3.作成・デプロイした Integration Flow を選択します
4.Logs タブをクリックし、Log Level の Trace リンクをクリックします
5.Run Steps の End をクリックします
6.Message Content をクリックします
7.Payload タブをクリックして、データが取得できていることを確認します(JSON 形式)
以上ですべての手順が完了しました。最後までお読みいただきありがとうございました。
Special thanks to Ikeguchi Daisuke-san!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
61 | |
21 | |
13 | |
11 | |
11 | |
8 | |
8 | |
8 | |
6 | |
6 |