Skip to content

/AWS1/IF_CWS=>LISTSERVICESTATES()

About ListServiceStates

Retrieves the current state information for services monitored by Application Signals. Service states include health status, recent change events, and other operational metadata.

You can filter results by time range, AWS account, and service attributes to focus on specific services or time periods. This operation supports pagination and can include data from linked accounts.

Method Signature

METHODS /AWS1/IF_CWS~LISTSERVICESTATES
  IMPORTING
    !IV_STARTTIME TYPE /AWS1/CWSTIMESTAMP OPTIONAL
    !IV_ENDTIME TYPE /AWS1/CWSTIMESTAMP OPTIONAL
    !IV_MAXRESULTS TYPE /AWS1/CWSLISTSVCSTATESMAXRSLTS OPTIONAL
    !IV_NEXTTOKEN TYPE /AWS1/CWSNEXTTOKEN OPTIONAL
    !IV_INCLUDELINKEDACCOUNTS TYPE /AWS1/CWSBOOLEAN OPTIONAL
    !IV_AWSACCOUNTID TYPE /AWS1/CWSAWSACCOUNTID OPTIONAL
    !IT_ATTRIBUTEFILTERS TYPE /AWS1/CL_CWSATTRIBUTEFILTER=>TT_ATTRIBUTEFILTERS OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_cwslistsvcstatesout
  RAISING
    /AWS1/CX_CWSTHROTTLINGEX
    /AWS1/CX_CWSVALIDATIONEX
    /AWS1/CX_CWSCLIENTEXC
    /AWS1/CX_CWSSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_starttime TYPE /AWS1/CWSTIMESTAMP /AWS1/CWSTIMESTAMP

The start time for the service states query. Only service states from this time onward will be included. Specify the time as the number of milliseconds since January 1, 1970, 00:00:00 UTC.

iv_endtime TYPE /AWS1/CWSTIMESTAMP /AWS1/CWSTIMESTAMP

The end time for the service states query. Only service states before this time will be included. Specify the time as the number of milliseconds since January 1, 1970, 00:00:00 UTC.

Optional arguments:

iv_maxresults TYPE /AWS1/CWSLISTSVCSTATESMAXRSLTS /AWS1/CWSLISTSVCSTATESMAXRSLTS

The maximum number of service states to return in a single request. Valid range is 1 to 100. If not specified, defaults to 50.

iv_nexttoken TYPE /AWS1/CWSNEXTTOKEN /AWS1/CWSNEXTTOKEN

The token for the next set of results. Use this token to retrieve additional pages of service states when the result set is large.

iv_includelinkedaccounts TYPE /AWS1/CWSBOOLEAN /AWS1/CWSBOOLEAN

Specifies whether to include service states from linked AWS accounts in the results. Set to true to include linked accounts, or false to only include the current account. Defaults to false.

iv_awsaccountid TYPE /AWS1/CWSAWSACCOUNTID /AWS1/CWSAWSACCOUNTID

The AWS account ID to filter service states. If specified, only service states from this account will be returned. If not specified, service states from the current account (and linked accounts if enabled) are returned.

it_attributefilters TYPE /AWS1/CL_CWSATTRIBUTEFILTER=>TT_ATTRIBUTEFILTERS TT_ATTRIBUTEFILTERS

An array of attribute filters to narrow down the service states returned. Each filter specifies an attribute name and the values to match against.

RETURNING

oo_output TYPE REF TO /aws1/cl_cwslistsvcstatesout /AWS1/CL_CWSLISTSVCSTATESOUT

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->listservicestates(
  it_attributefilters = VALUE /aws1/cl_cwsattributefilter=>tt_attributefilters(
    (
      new /aws1/cl_cwsattributefilter(
        it_attributefiltervalues = VALUE /aws1/cl_cwsattrfiltervalues_w=>tt_attributefiltervalues(
          ( new /aws1/cl_cwsattrfiltervalues_w( |string| ) )
        )
        iv_attributefiltername = |string|
      )
    )
  )
  iv_awsaccountid = |string|
  iv_endtime = '20150101000000.0000000'
  iv_includelinkedaccounts = ABAP_TRUE
  iv_maxresults = 123
  iv_nexttoken = |string|
  iv_starttime = '20150101000000.0000000'
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_timestamp = lo_result->get_starttime( ).
  lv_timestamp = lo_result->get_endtime( ).
  LOOP AT lo_result->get_servicestates( ) into lo_row.
    lo_row_1 = lo_row.
    IF lo_row_1 IS NOT INITIAL.
      LOOP AT lo_row_1->get_attributefilters( ) into lo_row_2.
        lo_row_3 = lo_row_2.
        IF lo_row_3 IS NOT INITIAL.
          lv_attributefiltername = lo_row_3->get_attributefiltername( ).
          LOOP AT lo_row_3->get_attributefiltervalues( ) into lo_row_4.
            lo_row_5 = lo_row_4.
            IF lo_row_5 IS NOT INITIAL.
              lv_attributefiltervalue = lo_row_5->get_value( ).
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDLOOP.
      LOOP AT lo_row_1->get_service( ) into ls_row_6.
        lv_key = ls_row_6-key.
        lo_value = ls_row_6-value.
        IF lo_value IS NOT INITIAL.
          lv_keyattributevalue = lo_value->get_value( ).
        ENDIF.
      ENDLOOP.
      LOOP AT lo_row_1->get_latestchangeevents( ) into lo_row_7.
        lo_row_8 = lo_row_7.
        IF lo_row_8 IS NOT INITIAL.
          lv_timestamp = lo_row_8->get_timestamp( ).
          lv_awsaccountid = lo_row_8->get_accountid( ).
          lv_string = lo_row_8->get_region( ).
          LOOP AT lo_row_8->get_entity( ) into ls_row_6.
            lv_key = ls_row_6-key.
            lo_value = ls_row_6-value.
            IF lo_value IS NOT INITIAL.
              lv_keyattributevalue = lo_value->get_value( ).
            ENDIF.
          ENDLOOP.
          lv_changeeventtype = lo_row_8->get_changeeventtype( ).
          lv_string = lo_row_8->get_eventid( ).
          lv_string = lo_row_8->get_username( ).
          lv_string = lo_row_8->get_eventname( ).
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDLOOP.
  lv_nexttoken = lo_result->get_nexttoken( ).
ENDIF.