CloudFront examples using SDK for SAP ABAP - Amazon SDK for SAP ABAP
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

CloudFront 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 CloudFront.

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 ListDistributions.

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. oo_result = lo_fnt->listdistributions( ). " oo_result is returned for testing purposes. " MESSAGE 'Retrieved list of CloudFront distributions.' TYPE 'I'. CATCH /aws1/cx_fntinvalidargument. MESSAGE 'Invalid argument provided.' TYPE 'E'. ENDTRY.

The following code example shows how to use UpdateDistribution.

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 the current distribution configuration and ETag " DATA(lo_distribution_config_result) = lo_fnt->getdistributionconfig( iv_id = iv_distribution_id ). DATA(lo_old_config) = lo_distribution_config_result->get_distributionconfig( ). DATA(lv_etag) = lo_distribution_config_result->get_etag( ). " Create a new distribution config with the updated comment " " Since the config object is immutable, we need to create a new one with all existing values " DATA(lo_new_config) = NEW /aws1/cl_fntdistributionconfig( iv_callerreference = lo_old_config->get_callerreference( ) io_aliases = lo_old_config->get_aliases( ) iv_defaultrootobject = lo_old_config->get_defaultrootobject( ) io_origins = lo_old_config->get_origins( ) io_origingroups = lo_old_config->get_origingroups( ) io_defaultcachebehavior = lo_old_config->get_defaultcachebehavior( ) io_cachebehaviors = lo_old_config->get_cachebehaviors( ) io_customerrorresponses = lo_old_config->get_customerrorresponses( ) iv_comment = iv_comment io_logging = lo_old_config->get_logging( ) iv_priceclass = lo_old_config->get_priceclass( ) iv_enabled = lo_old_config->get_enabled( ) io_viewercertificate = lo_old_config->get_viewercertificate( ) io_restrictions = lo_old_config->get_restrictions( ) iv_webaclid = lo_old_config->get_webaclid( ) iv_httpversion = lo_old_config->get_httpversion( ) iv_isipv6enabled = lo_old_config->get_isipv6enabled( ) ). " Update the distribution with the modified configuration " lo_fnt->updatedistribution( io_distributionconfig = lo_new_config iv_id = iv_distribution_id iv_ifmatch = lv_etag ). MESSAGE 'CloudFront distribution updated successfully.' TYPE 'I'. CATCH /aws1/cx_fntnosuchdistribution. MESSAGE 'Distribution does not exist.' TYPE 'E'. CATCH /aws1/cx_fntpreconditionfailed. MESSAGE 'Precondition failed - ETag mismatch.' TYPE 'E'. CATCH /aws1/cx_fntinvalidifmatchvrs. MESSAGE 'Invalid If-Match version.' TYPE 'E'. ENDTRY.