Amazon Pinpoint SMS and Voice API examples using SDK for SAP ABAP
The following code examples show you how to perform actions and implement common scenarios by using the Amazon SDK for SAP ABAP with Amazon Pinpoint SMS and Voice API.
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 CreateConfigurationSet.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. " Create a new configuration set lo_pps->createconfigurationset( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' ). MESSAGE 'Configuration set created successfully.' TYPE 'I'. CATCH /aws1/cx_ppsalreadyexistsex INTO DATA(lo_already_exists_ex). MESSAGE lo_already_exists_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_already_exists_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppslimitexceededex INTO DATA(lo_limit_exceeded_ex). MESSAGE lo_limit_exceeded_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_limit_exceeded_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.-
For API details, see CreateConfigurationSet in Amazon SDK for SAP ABAP API reference.
-
The following code example shows how to use CreateConfigurationSetEventDestination.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. " Create event destination for the configuration set lo_pps->createconfseteventdst( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' iv_eventdestinationname = iv_event_destination_name " e.g., 'my-event-dest' io_eventdestination = io_event_destination ). MESSAGE 'Event destination created successfully.' TYPE 'I'. CATCH /aws1/cx_ppsalreadyexistsex INTO DATA(lo_already_exists_ex). MESSAGE lo_already_exists_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_already_exists_ex. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppslimitexceededex INTO DATA(lo_limit_exceeded_ex). MESSAGE lo_limit_exceeded_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_limit_exceeded_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.-
For API details, see CreateConfigurationSetEventDestination in Amazon SDK for SAP ABAP API reference.
-
The following code example shows how to use DeleteConfigurationSet.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. " Delete the configuration set lo_pps->deleteconfigurationset( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' ). MESSAGE 'Configuration set deleted successfully.' TYPE 'I'. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.-
For API details, see DeleteConfigurationSet in Amazon SDK for SAP ABAP API reference.
-
The following code example shows how to use DeleteConfigurationSetEventDestination.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. " Delete the event destination lo_pps->deleteconfseteventdst( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' iv_eventdestinationname = iv_event_destination_name " e.g., 'my-event-dest' ). MESSAGE 'Event destination deleted successfully.' TYPE 'I'. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.-
For API details, see DeleteConfigurationSetEventDestination in Amazon SDK for SAP ABAP API reference.
-
The following code example shows how to use GetConfigurationSetEventDestinations.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. " Get event destinations for the configuration set oo_result = lo_pps->getconfseteventdestinations( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' ). " Process the event destinations LOOP AT oo_result->get_eventdestinations( ) INTO DATA(lo_event_dest). DATA(lv_dest_name) = lo_event_dest->get_name( ). DATA(lv_enabled) = lo_event_dest->get_enabled( ). MESSAGE |Event destination: { lv_dest_name }, Enabled: { lv_enabled }| TYPE 'I'. " Check for CloudWatch Logs destination DATA(lo_cloudwatch_dest) = lo_event_dest->get_cloudwatchlogsdst( ). IF lo_cloudwatch_dest IS NOT INITIAL. DATA(lv_log_group_arn) = lo_cloudwatch_dest->get_loggrouparn( ). MESSAGE | CloudWatch Logs destination: { lv_log_group_arn }| TYPE 'I'. ENDIF. " Check for Kinesis Firehose destination DATA(lo_firehose_dest) = lo_event_dest->get_kinesisfirehosedst( ). IF lo_firehose_dest IS NOT INITIAL. DATA(lv_delivery_stream) = lo_firehose_dest->get_deliverystreamarn( ). MESSAGE | Kinesis Firehose destination: { lv_delivery_stream }| TYPE 'I'. ENDIF. " Check for SNS destination DATA(lo_sns_dest) = lo_event_dest->get_snsdestination( ). IF lo_sns_dest IS NOT INITIAL. DATA(lv_topic_arn) = lo_sns_dest->get_topicarn( ). MESSAGE | SNS destination: { lv_topic_arn }| TYPE 'I'. ENDIF. ENDLOOP. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.-
For API details, see GetConfigurationSetEventDestinations in Amazon SDK for SAP ABAP API reference.
-
The following code example shows how to use ListConfigurationSets.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. " List all configuration sets oo_result = lo_pps->listconfigurationsets( iv_nexttoken = iv_next_token " Optional: Token for pagination iv_pagesize = iv_page_size " Optional: Number of results per page, e.g., '10' ). " Process the configuration sets LOOP AT oo_result->get_configurationsets( ) INTO DATA(lo_config_set). DATA(lv_config_set_name) = lo_config_set->get_value( ). MESSAGE |Configuration set: { lv_config_set_name }| TYPE 'I'. ENDLOOP. " Check if there are more results DATA(lv_next_token) = oo_result->get_nexttoken( ). IF lv_next_token IS NOT INITIAL. MESSAGE |More results available. Next token: { lv_next_token }| TYPE 'I'. ENDIF. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.-
For API details, see ListConfigurationSets in Amazon SDK for SAP ABAP API reference.
-
The following code example shows how to use SendVoiceMessage.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. " Create SSML message type object with voice parameters DATA(lo_ssml_message) = NEW /aws1/cl_ppsssmlmessagetype( iv_languagecode = iv_language_code " e.g., 'en-US' iv_voiceid = iv_voice_id " e.g., 'Matthew' iv_text = iv_ssml_message " SSML formatted message text ). " Create voice message content with the SSML message DATA(lo_content) = NEW /aws1/cl_ppsvoicemessagecont( io_ssmlmessage = lo_ssml_message ). " Send the voice message DATA(lo_result) = lo_pps->sendvoicemessage( iv_originationphonenumber = iv_origination_number " e.g., '+12065550110' iv_callerid = iv_caller_id " e.g., '+12065550199' iv_destinationphonenumber = iv_destination_number " e.g., '+12065550142' io_content = lo_content ). " Retrieve the message ID from the response ov_message_id = lo_result->get_messageid( ). MESSAGE 'Voice message sent successfully.' TYPE 'I'. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.-
For API details, see SendVoiceMessage in Amazon SDK for SAP ABAP API reference.
-
The following code example shows how to use UpdateConfigurationSetEventDestination.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. " Update the event destination lo_pps->updateconfseteventdst( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' iv_eventdestinationname = iv_event_destination_name " e.g., 'my-event-dest' io_eventdestination = io_event_destination ). MESSAGE 'Event destination updated successfully.' TYPE 'I'. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.-
For API details, see UpdateConfigurationSetEventDestination in Amazon SDK for SAP ABAP API reference.
-