/AWS1/IF_CEX=>GETCOSTANDUSAGEWITHRESOURCES()¶
About GetCostAndUsageWithResources¶
Retrieves cost and usage metrics with resources for your account. You can specify which
cost and usage-related metric, such as BlendedCosts or
UsageQuantity, that you want the request to return. You can also filter and group
your data by various dimensions, such as SERVICE or AZ, in a
specific time range. For a complete list of valid dimensions, see the GetDimensionValues operation. Management account in an organization in Organizations have access to all member accounts.
Hourly granularity is only available for EC2-Instances (Elastic Compute Cloud) resource-level data. All other resource-level data is available at daily granularity.
This is an opt-in only feature. You can enable this feature from the Cost Explorer Settings page. For information about how to access the Settings page, see Controlling Access for Cost Explorer in the Billing and Cost Management User Guide.
Method Signature¶
METHODS /AWS1/IF_CEX~GETCOSTANDUSAGEWITHRESOURCES
IMPORTING
!IO_TIMEPERIOD TYPE REF TO /AWS1/CL_CEXDATEINTERVAL OPTIONAL
!IV_GRANULARITY TYPE /AWS1/CEXGRANULARITY OPTIONAL
!IO_FILTER TYPE REF TO /AWS1/CL_CEXEXPRESSION OPTIONAL
!IT_METRICS TYPE /AWS1/CL_CEXMETRICNAMES_W=>TT_METRICNAMES OPTIONAL
!IT_GROUPBY TYPE /AWS1/CL_CEXGROUPDEFINITION=>TT_GROUPDEFINITIONS OPTIONAL
!IV_BILLINGVIEWARN TYPE /AWS1/CEXBILLINGVIEWARN OPTIONAL
!IV_NEXTPAGETOKEN TYPE /AWS1/CEXNEXTPAGETOKEN OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_cexgetcostandusagew01
RAISING
/AWS1/CX_CEXBILLEXPIREXCEPTION
/AWS1/CX_CEXBLLVIEWHLTHSTATEX
/AWS1/CX_CEXDATAUNAVAILEX
/AWS1/CX_CEXINVALIDNEXTTOKENEX
/AWS1/CX_CEXLIMITEXCEEDEDEX
/AWS1/CX_CEXREQUESTCHANGEDEX
/AWS1/CX_CEXRESOURCENOTFOUNDEX
/AWS1/CX_CEXCLIENTEXC
/AWS1/CX_CEXSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
io_timeperiod TYPE REF TO /AWS1/CL_CEXDATEINTERVAL /AWS1/CL_CEXDATEINTERVAL¶
Sets the start and end dates for retrieving Amazon Web Services costs. The range must be within the last 14 days (the start date cannot be earlier than 14 days ago). The start date is inclusive, but the end date is exclusive. For example, if
startis2017-01-01andendis2017-05-01, then the cost and usage data is retrieved from2017-01-01up to and including2017-04-30but not including2017-05-01.
iv_granularity TYPE /AWS1/CEXGRANULARITY /AWS1/CEXGRANULARITY¶
Sets the Amazon Web Services cost granularity to
MONTHLY,DAILY, orHOURLY. IfGranularityisn't set, the response object doesn't include theGranularity,MONTHLY,DAILY, orHOURLY.
io_filter TYPE REF TO /AWS1/CL_CEXEXPRESSION /AWS1/CL_CEXEXPRESSION¶
Filters Amazon Web Services costs by different dimensions. For example, you can specify
SERVICEandLINKED_ACCOUNTand get the costs that are associated with that account's usage of that service. You can nestExpressionobjects to define any combination of dimension filters. For more information, see Expression.Valid values for
MatchOptionsforDimensionsareEQUALSandCASE_SENSITIVE.Valid values for
MatchOptionsforCostCategoriesandTagsareEQUALS,ABSENT, andCASE_SENSITIVE. Default values areEQUALSandCASE_SENSITIVE.
Optional arguments:¶
it_metrics TYPE /AWS1/CL_CEXMETRICNAMES_W=>TT_METRICNAMES TT_METRICNAMES¶
Which metrics are returned in the query. For more information about blended and unblended rates, see Why does the "blended" annotation appear on some line items in my bill?.
Valid values are
AmortizedCost,BlendedCost,NetAmortizedCost,NetUnblendedCost,NormalizedUsageAmount,UnblendedCost, andUsageQuantity.If you return the
UsageQuantitymetric, the service aggregates all usage numbers without taking the units into account. For example, if you aggregateusageQuantityacross all of Amazon EC2, the results aren't meaningful because Amazon EC2 compute hours and data transfer are measured in different units (for example, hour or GB). To get more meaningfulUsageQuantitymetrics, filter byUsageTypeorUsageTypeGroups.
Metricsis required forGetCostAndUsageWithResourcesrequests.
it_groupby TYPE /AWS1/CL_CEXGROUPDEFINITION=>TT_GROUPDEFINITIONS TT_GROUPDEFINITIONS¶
You can group Amazon Web Services costs using up to two different groups:
DIMENSION,TAG,COST_CATEGORY.
iv_billingviewarn TYPE /AWS1/CEXBILLINGVIEWARN /AWS1/CEXBILLINGVIEWARN¶
The Amazon Resource Name (ARN) that uniquely identifies a specific billing view. The ARN is used to specify which particular billing view you want to interact with or retrieve information from when making API calls related to Amazon Web Services Billing and Cost Management features. The BillingViewArn can be retrieved by calling the ListBillingViews API.
iv_nextpagetoken TYPE /AWS1/CEXNEXTPAGETOKEN /AWS1/CEXNEXTPAGETOKEN¶
The token to retrieve the next set of results. Amazon Web Services provides the token when the response from a previous call has more results than the maximum page size.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_cexgetcostandusagew01 /AWS1/CL_CEXGETCOSTANDUSAGEW01¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->getcostandusagewithresources(
io_filter = new /aws1/cl_cexexpression(
io_costcategories = new /aws1/cl_cexcostcategoryvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_dimensions = new /aws1/cl_cexdimensionvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_not = new /aws1/cl_cexexpression(
io_costcategories = new /aws1/cl_cexcostcategoryvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_dimensions = new /aws1/cl_cexdimensionvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_tags = new /aws1/cl_cextagvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
it_and = VALUE /aws1/cl_cexexpression=>tt_expressions(
(
new /aws1/cl_cexexpression(
io_costcategories = new /aws1/cl_cexcostcategoryvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_dimensions = new /aws1/cl_cexdimensionvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_tags = new /aws1/cl_cextagvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
it_or = VALUE /aws1/cl_cexexpression=>tt_expressions(
)
)
)
)
it_or = VALUE /aws1/cl_cexexpression=>tt_expressions(
(
new /aws1/cl_cexexpression(
io_costcategories = new /aws1/cl_cexcostcategoryvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_dimensions = new /aws1/cl_cexdimensionvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_tags = new /aws1/cl_cextagvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
it_and = VALUE /aws1/cl_cexexpression=>tt_expressions(
)
)
)
)
)
io_tags = new /aws1/cl_cextagvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
it_and = VALUE /aws1/cl_cexexpression=>tt_expressions(
(
new /aws1/cl_cexexpression(
io_costcategories = new /aws1/cl_cexcostcategoryvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_dimensions = new /aws1/cl_cexdimensionvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_not = new /aws1/cl_cexexpression(
io_costcategories = new /aws1/cl_cexcostcategoryvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_dimensions = new /aws1/cl_cexdimensionvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_tags = new /aws1/cl_cextagvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
it_or = VALUE /aws1/cl_cexexpression=>tt_expressions(
)
)
io_tags = new /aws1/cl_cextagvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
it_or = VALUE /aws1/cl_cexexpression=>tt_expressions(
)
)
)
)
it_or = VALUE /aws1/cl_cexexpression=>tt_expressions(
(
new /aws1/cl_cexexpression(
io_costcategories = new /aws1/cl_cexcostcategoryvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_dimensions = new /aws1/cl_cexdimensionvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_not = new /aws1/cl_cexexpression(
io_costcategories = new /aws1/cl_cexcostcategoryvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_dimensions = new /aws1/cl_cexdimensionvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
io_tags = new /aws1/cl_cextagvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
it_and = VALUE /aws1/cl_cexexpression=>tt_expressions(
)
)
io_tags = new /aws1/cl_cextagvalues(
it_matchoptions = VALUE /aws1/cl_cexmatchoptions_w=>tt_matchoptions(
( new /aws1/cl_cexmatchoptions_w( |string| ) )
)
it_values = VALUE /aws1/cl_cexvalues_w=>tt_values(
( new /aws1/cl_cexvalues_w( |string| ) )
)
iv_key = |string|
)
it_and = VALUE /aws1/cl_cexexpression=>tt_expressions(
)
)
)
)
)
io_timeperiod = new /aws1/cl_cexdateinterval(
iv_end = |string|
iv_start = |string|
)
it_groupby = VALUE /aws1/cl_cexgroupdefinition=>tt_groupdefinitions(
(
new /aws1/cl_cexgroupdefinition(
iv_key = |string|
iv_type = |string|
)
)
)
it_metrics = VALUE /aws1/cl_cexmetricnames_w=>tt_metricnames(
( new /aws1/cl_cexmetricnames_w( |string| ) )
)
iv_billingviewarn = |string|
iv_granularity = |string|
iv_nextpagetoken = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_nextpagetoken = lo_result->get_nextpagetoken( ).
LOOP AT lo_result->get_groupdefinitions( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lv_groupdefinitiontype = lo_row_1->get_type( ).
lv_groupdefinitionkey = lo_row_1->get_key( ).
ENDIF.
ENDLOOP.
LOOP AT lo_result->get_resultsbytime( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lo_dateinterval = lo_row_3->get_timeperiod( ).
IF lo_dateinterval IS NOT INITIAL.
lv_yearmonthday = lo_dateinterval->get_start( ).
lv_yearmonthday = lo_dateinterval->get_end( ).
ENDIF.
LOOP AT lo_row_3->get_total( ) into ls_row_4.
lv_key = ls_row_4-key.
lo_value = ls_row_4-value.
IF lo_value IS NOT INITIAL.
lv_metricamount = lo_value->get_amount( ).
lv_metricunit = lo_value->get_unit( ).
ENDIF.
ENDLOOP.
LOOP AT lo_row_3->get_groups( ) into lo_row_5.
lo_row_6 = lo_row_5.
IF lo_row_6 IS NOT INITIAL.
LOOP AT lo_row_6->get_keys( ) into lo_row_7.
lo_row_8 = lo_row_7.
IF lo_row_8 IS NOT INITIAL.
lv_key_1 = lo_row_8->get_value( ).
ENDIF.
ENDLOOP.
LOOP AT lo_row_6->get_metrics( ) into ls_row_4.
lv_key = ls_row_4-key.
lo_value = ls_row_4-value.
IF lo_value IS NOT INITIAL.
lv_metricamount = lo_value->get_amount( ).
lv_metricunit = lo_value->get_unit( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
lv_estimated = lo_row_3->get_estimated( ).
ENDIF.
ENDLOOP.
LOOP AT lo_result->get_dimensionvalueattributes( ) into lo_row_9.
lo_row_10 = lo_row_9.
IF lo_row_10 IS NOT INITIAL.
lv_value_1 = lo_row_10->get_value( ).
LOOP AT lo_row_10->get_attributes( ) into ls_row_11.
lv_key_2 = ls_row_11-key.
lo_value_2 = ls_row_11-value.
IF lo_value_2 IS NOT INITIAL.
lv_attributevalue = lo_value_2->get_value( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.