There are more AWS SDK examples available in the AWS Doc SDK Examples
Systems Manager examples using SDK for SAP ABAP
The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for SAP ABAP with Systems Manager.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use CreateDocument.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. lo_ssm->createdocument( iv_name = iv_name iv_content = iv_content iv_documenttype = 'Command' ). MESSAGE 'Document created.' TYPE 'I'. CATCH /aws1/cx_ssmdocalreadyexists. MESSAGE 'Document already exists.' TYPE 'I'. CATCH /aws1/cx_ssminvaliddoccontent. MESSAGE 'Invalid document content.' TYPE 'I'. ENDTRY.-
For API details, see CreateDocument in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use CreateMaintenanceWindow.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. oo_result = lo_ssm->createmaintenancewindow( iv_name = iv_name iv_schedule = iv_schedule iv_duration = iv_duration iv_cutoff = iv_cutoff iv_allowunassociatedtargets = iv_allow_unassociated_targets ). MESSAGE 'Maintenance window created.' TYPE 'I'. CATCH /aws1/cx_ssmresrclimitexcdex. MESSAGE 'Resource limit exceeded.' TYPE 'I'. ENDTRY.-
For API details, see CreateMaintenanceWindow in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use CreateOpsItem.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. oo_result = lo_ssm->createopsitem( iv_title = iv_title iv_source = iv_source iv_category = iv_category iv_severity = iv_severity iv_description = iv_description ). MESSAGE 'OpsItem created.' TYPE 'I'. CATCH /aws1/cx_ssmopsitemlimitexcdex. MESSAGE 'You have exceeded your open OpsItem limit.' TYPE 'I'. CATCH /aws1/cx_ssmopsitemalrdyexex. MESSAGE 'OpsItem already exists.' TYPE 'I'. ENDTRY.-
For API details, see CreateOpsItem in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use DeleteDocument.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. lo_ssm->deletedocument( iv_name = iv_name ). MESSAGE 'Document deleted.' TYPE 'I'. CATCH /aws1/cx_ssminvaliddocument. MESSAGE 'Invalid document.' TYPE 'I'. CATCH /aws1/cx_ssmassocdinstances. MESSAGE 'Document has associated instances.' TYPE 'I'. ENDTRY.-
For API details, see DeleteDocument in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use DeleteMaintenanceWindow.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. lo_ssm->deletemaintenancewindow( iv_windowid = iv_window_id ). MESSAGE 'Maintenance window deleted.' TYPE 'I'. CATCH /aws1/cx_ssminternalservererr. MESSAGE 'Internal server error occurred.' TYPE 'I'. ENDTRY.-
For API details, see DeleteMaintenanceWindow in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use DeleteOpsItem.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. lo_ssm->deleteopsitem( iv_opsitemid = iv_ops_item_id ). MESSAGE 'OpsItem deleted.' TYPE 'I'. CATCH /aws1/cx_ssmopsiteminvparamex. MESSAGE 'Invalid OpsItem parameter.' TYPE 'I'. ENDTRY.-
For API details, see DeleteOpsItem in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use DescribeDocument.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. DATA(lo_result) = lo_ssm->describedocument( iv_name = iv_name ). DATA(lo_document) = lo_result->get_document( ). IF lo_document IS BOUND. rv_status = lo_document->get_status( ). MESSAGE |Document status: { rv_status }| TYPE 'I'. ENDIF. CATCH /aws1/cx_ssminvaliddocument. MESSAGE 'Invalid document.' TYPE 'I'. ENDTRY.-
For API details, see DescribeDocument in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use DescribeOpsItems.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. " Create filter for OpsItem ID DATA(lt_filters) = VALUE /aws1/cl_ssmopsitemfilter=>tt_opsitemfilters( ( NEW /aws1/cl_ssmopsitemfilter( iv_key = 'OpsItemId' it_values = VALUE /aws1/cl_ssmopsitemfiltvals_w=>tt_opsitemfiltervalues( ( NEW /aws1/cl_ssmopsitemfiltvals_w( iv_value = iv_ops_item_id ) ) ) iv_operator = 'Equal' ) ) ). " Use paginator to get all results DATA(lo_paginator) = lo_ssm->get_paginator( ). DATA(lo_iterator) = lo_paginator->describeopsitems( it_opsitemfilters = lt_filters ). rv_found = abap_false. WHILE lo_iterator->has_next( ). DATA(lo_result) = CAST /aws1/cl_ssmdescropsitemsrsp( lo_iterator->get_next( ) ). LOOP AT lo_result->get_opsitemsummaries( ) INTO DATA(lo_item). DATA(lv_title) = lo_item->get_title( ). DATA(lv_status) = lo_item->get_status( ). MESSAGE |The OpsItem title is { lv_title } and the status is { lv_status }| TYPE 'I'. rv_found = abap_true. ENDLOOP. ENDWHILE. CATCH /aws1/cx_ssminternalservererr. MESSAGE 'Internal server error occurred.' TYPE 'I'. ENDTRY.-
For API details, see DescribeOpsItems in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use ListCommandInvocations.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. " Use paginator to get all results DATA(lo_paginator) = lo_ssm->get_paginator( ). DATA(lo_iterator) = lo_paginator->listcommandinvocations( iv_instanceid = iv_instance_id ). DATA lv_count TYPE i VALUE 0. WHILE lo_iterator->has_next( ). DATA(lo_result) = CAST /aws1/cl_ssmlistcmdinvcsresult( lo_iterator->get_next( ) ). LOOP AT lo_result->get_commandinvocations( ) INTO DATA(lo_invocation). lv_count = lv_count + 1. DATA(lv_requested_datetime) = lo_invocation->get_requesteddatetime( ). MESSAGE |Command invocation requested at: { lv_requested_datetime }| TYPE 'I'. ENDLOOP. ENDWHILE. MESSAGE |{ lv_count } command invocation(s) found for instance { iv_instance_id }.| TYPE 'I'. CATCH /aws1/cx_ssminvalidinstanceid. MESSAGE 'Invalid instance ID.' TYPE 'I'. CATCH /aws1/cx_ssminvalidcommandid. MESSAGE 'Invalid command ID.' TYPE 'I'. ENDTRY.-
For API details, see ListCommandInvocations in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use SendCommand.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. DATA(lo_result) = lo_ssm->sendcommand( it_instanceids = it_instance_ids iv_documentname = iv_document_name iv_timeoutseconds = 3600 ). DATA(lo_command) = lo_result->get_command( ). IF lo_command IS BOUND. rv_command_id = lo_command->get_commandid( ). MESSAGE 'Command sent successfully.' TYPE 'I'. ENDIF. CATCH /aws1/cx_ssminvaliddocument. MESSAGE 'Invalid document.' TYPE 'I'. CATCH /aws1/cx_ssminvalidinstanceid. MESSAGE 'Invalid instance ID.' TYPE 'I'. ENDTRY.-
For API details, see SendCommand in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use UpdateMaintenanceWindow.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. lo_ssm->updatemaintenancewindow( iv_windowid = iv_window_id iv_name = iv_name iv_enabled = iv_enabled iv_schedule = iv_schedule iv_duration = iv_duration iv_cutoff = iv_cutoff iv_allowunassociatedtargets = iv_allow_unassociated_targets ). MESSAGE 'Maintenance window updated.' TYPE 'I'. CATCH /aws1/cx_ssmdoesnotexistex. MESSAGE 'Maintenance window does not exist.' TYPE 'I'. ENDTRY.-
For API details, see UpdateMaintenanceWindow in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use UpdateOpsItem.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. lo_ssm->updateopsitem( iv_opsitemid = iv_ops_item_id iv_title = iv_title iv_description = iv_description iv_status = iv_status ). MESSAGE 'OpsItem updated.' TYPE 'I'. CATCH /aws1/cx_ssmopsitemnotfoundex. MESSAGE 'OpsItem not found.' TYPE 'I'. CATCH /aws1/cx_ssmopsiteminvparamex. MESSAGE 'Invalid OpsItem parameter.' TYPE 'I'. ENDTRY.-
For API details, see UpdateOpsItem in AWS SDK for SAP ABAP API reference.
-