文件 AWS SDK 範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用適用於 SAP ABAP 的 SDK 的組織範例
下列程式碼範例示範如何使用 AWS SDK for SAP ABAP with Organizations 來執行動作和實作常見案例。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。
每個範例均包含完整原始碼的連結,您可在連結中找到如何設定和執行內容中程式碼的相關指示。
主題
動作
以下程式碼範例顯示如何使用 AttachPolicy。
- 適用於 SAP ABAP 的開發套件
-
注意
GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 TRY. lo_org->attachpolicy( iv_policyid = iv_policy_id iv_targetid = iv_target_id ). MESSAGE 'Policy attached to target.' TYPE 'I'. CATCH /aws1/cx_orgaccessdeniedex. MESSAGE 'You do not have permission to attach the policy.' TYPE 'E'. CATCH /aws1/cx_orgpolicynotfoundex. MESSAGE 'The specified policy does not exist.' TYPE 'E'. CATCH /aws1/cx_orgtargetnotfoundex. MESSAGE 'The specified target does not exist.' TYPE 'E'. CATCH /aws1/cx_orgduplicateplyatta00. MESSAGE 'The policy is already attached to the target.' TYPE 'E'. ENDTRY.-
如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 AttachPolicy。
-
以下程式碼範例顯示如何使用 CreatePolicy。
- 適用於 SAP ABAP 的開發套件
-
注意
GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 TRY. oo_result = lo_org->createpolicy( " oo_result is returned for testing purposes. " iv_name = iv_policy_name iv_description = iv_policy_description iv_content = iv_policy_content iv_type = iv_policy_type ). MESSAGE 'Policy created.' TYPE 'I'. CATCH /aws1/cx_orgaccessdeniedex. MESSAGE 'You do not have permission to create a policy.' TYPE 'E'. CATCH /aws1/cx_orgduplicatepolicyex. MESSAGE 'A policy with this name already exists.' TYPE 'E'. CATCH /aws1/cx_orgmalformedplydocex. MESSAGE 'The policy content is malformed.' TYPE 'E'. ENDTRY.-
如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 CreatePolicy。
-
以下程式碼範例顯示如何使用 DeletePolicy。
- 適用於 SAP ABAP 的開發套件
-
注意
GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 TRY. lo_org->deletepolicy( iv_policyid = iv_policy_id ). MESSAGE 'Policy deleted.' TYPE 'I'. CATCH /aws1/cx_orgaccessdeniedex. MESSAGE 'You do not have permission to delete the policy.' TYPE 'E'. CATCH /aws1/cx_orgpolicynotfoundex. MESSAGE 'The specified policy does not exist.' TYPE 'E'. CATCH /aws1/cx_orgpolicyinuseex. MESSAGE 'The policy is still attached to one or more targets.' TYPE 'E'. ENDTRY.-
如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 DeletePolicy。
-
以下程式碼範例顯示如何使用 DescribePolicy。
- 適用於 SAP ABAP 的開發套件
-
注意
GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 TRY. oo_result = lo_org->describepolicy( " oo_result is returned for testing purposes. " iv_policyid = iv_policy_id ). DATA(lo_policy) = oo_result->get_policy( ). MESSAGE 'Retrieved policy details.' TYPE 'I'. CATCH /aws1/cx_orgaccessdeniedex. MESSAGE 'You do not have permission to describe the policy.' TYPE 'E'. CATCH /aws1/cx_orgpolicynotfoundex. MESSAGE 'The specified policy does not exist.' TYPE 'E'. ENDTRY.-
如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 DescribePolicy。
-
以下程式碼範例顯示如何使用 DetachPolicy。
- 適用於 SAP ABAP 的開發套件
-
注意
GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 TRY. lo_org->detachpolicy( iv_policyid = iv_policy_id iv_targetid = iv_target_id ). MESSAGE 'Policy detached from target.' TYPE 'I'. CATCH /aws1/cx_orgaccessdeniedex. MESSAGE 'You do not have permission to detach the policy.' TYPE 'E'. CATCH /aws1/cx_orgpolicynotfoundex. MESSAGE 'The specified policy does not exist.' TYPE 'E'. CATCH /aws1/cx_orgtargetnotfoundex. MESSAGE 'The specified target does not exist.' TYPE 'E'. CATCH /aws1/cx_orgpolicynotattex. MESSAGE 'The policy is not attached to the target.' TYPE 'E'. ENDTRY.-
如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 DetachPolicy。
-
以下程式碼範例顯示如何使用 ListPolicies。
- 適用於 SAP ABAP 的開發套件
-
注意
GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 TRY. oo_result = lo_org->listpolicies( " oo_result is returned for testing purposes. " iv_filter = iv_filter ). DATA(lt_policies) = oo_result->get_policies( ). MESSAGE 'Retrieved list of policies.' TYPE 'I'. CATCH /aws1/cx_orgaccessdeniedex. MESSAGE 'You do not have permission to list policies.' TYPE 'E'. CATCH /aws1/cx_orgawsorgsnotinuseex. MESSAGE 'Your account is not a member of an organization.' TYPE 'E'. ENDTRY.-
如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 ListPolicies。
-