Skip to content

/AWS1/IF_APC=>CREATEEXPERIMENTDEFINITION()

About CreateExperimentDefinition

Creates an experiment definition in AppConfig. An experiment definition describes the purpose, scope, and operational configuration of an experiment, including the target audience, feature flag, and treatment configurations.

Method Signature

METHODS /AWS1/IF_APC~CREATEEXPERIMENTDEFINITION
  IMPORTING
    !IV_APPLICATIONIDENTIFIER TYPE /AWS1/APCIDENTIFIER OPTIONAL
    !IV_NAME TYPE /AWS1/APCNAMEWITHRSRVDAWSPREF OPTIONAL
    !IV_CONFPROFILEIDENTIFIER TYPE /AWS1/APCIDENTIFIER OPTIONAL
    !IV_ENVIRONMENTIDENTIFIER TYPE /AWS1/APCIDENTIFIER OPTIONAL
    !IV_FLAGKEY TYPE /AWS1/APCFLAGKEY OPTIONAL
    !IT_TREATMENTS TYPE /AWS1/CL_APCTREATMENTINPUT=>TT_TREATMENTINPUTLIST OPTIONAL
    !IO_CONTROL TYPE REF TO /AWS1/CL_APCTREATMENTINPUT OPTIONAL
    !IV_AUDIENCERULE TYPE /AWS1/APCRULE OPTIONAL
    !IV_HYPOTHESIS TYPE /AWS1/APCDESCRIPTION OPTIONAL
    !IV_AUDIENCEDESCRIPTION TYPE /AWS1/APCDESCRIPTION OPTIONAL
    !IV_LAUNCHCRITERIA TYPE /AWS1/APCDESCRIPTION OPTIONAL
    !IT_TAGS TYPE /AWS1/CL_APCTAGMAP_W=>TT_TAGMAP OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_apcexperimentdefn
  RAISING
    /AWS1/CX_APCBADREQUESTEX
    /AWS1/CX_APCCONFLICTEXCEPTION
    /AWS1/CX_APCINTERNALSERVEREX
    /AWS1/CX_APCRESOURCENOTFOUNDEX
    /AWS1/CX_APCSERVICEQUOTAEXCDEX
    /AWS1/CX_APCCLIENTEXC
    /AWS1/CX_APCSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_applicationidentifier TYPE /AWS1/APCIDENTIFIER /AWS1/APCIDENTIFIER

The application ID or name.

iv_name TYPE /AWS1/APCNAMEWITHRSRVDAWSPREF /AWS1/APCNAMEWITHRSRVDAWSPREF

A name for the experiment definition.

iv_confprofileidentifier TYPE /AWS1/APCIDENTIFIER /AWS1/APCIDENTIFIER

The configuration profile ID or name that stores the feature flag.

iv_environmentidentifier TYPE /AWS1/APCIDENTIFIER /AWS1/APCIDENTIFIER

The environment ID or name where the experiment will run.

iv_flagkey TYPE /AWS1/APCFLAGKEY /AWS1/APCFLAGKEY

The key of the existing feature flag to use with the experiment.

it_treatments TYPE /AWS1/CL_APCTREATMENTINPUT=>TT_TREATMENTINPUTLIST TT_TREATMENTINPUTLIST

A list of treatments to evaluate during the experiment. Each treatment defines a distinct variation compared to the control.

io_control TYPE REF TO /AWS1/CL_APCTREATMENTINPUT /AWS1/CL_APCTREATMENTINPUT

The control treatment that represents the baseline experience for comparison.

iv_audiencerule TYPE /AWS1/APCRULE /AWS1/APCRULE

A rule that defines which users are eligible to be assigned to treatments during the experiment.

Optional arguments:

iv_hypothesis TYPE /AWS1/APCDESCRIPTION /AWS1/APCDESCRIPTION

A description of the goal or hypothesis the experiment is designed to validate.

iv_audiencedescription TYPE /AWS1/APCDESCRIPTION /AWS1/APCDESCRIPTION

A description of the intended audience for the experiment.

iv_launchcriteria TYPE /AWS1/APCDESCRIPTION /AWS1/APCDESCRIPTION

Information about the conditions under which you would launch the winning treatment.

it_tags TYPE /AWS1/CL_APCTAGMAP_W=>TT_TAGMAP TT_TAGMAP

The tags to assign to the experiment definition. Tags help organize and categorize your AppConfig resources.

RETURNING

oo_output TYPE REF TO /aws1/cl_apcexperimentdefn /AWS1/CL_APCEXPERIMENTDEFN

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->createexperimentdefinition(
  io_control = new /aws1/cl_apctreatmentinput(
    io_flagvalue = new /aws1/cl_apcflagvalue(
      it_attributevalues = VALUE /aws1/cl_apcattributevalue=>tt_attributevaluemap(
        (
          VALUE /aws1/cl_apcattributevalue=>ts_attributevaluemap_maprow(
            key = |string|
            value = new /aws1/cl_apcattributevalue(
              it_numberarray = VALUE /aws1/cl_apcnumberlist_w=>tt_numberlist(
                ( new /aws1/cl_apcnumberlist_w( |0.1| ) )
              )
              it_stringarray = VALUE /aws1/cl_apcstringlist_w=>tt_stringlist(
                ( new /aws1/cl_apcstringlist_w( |string| ) )
              )
              iv_booleanvalue = ABAP_TRUE
              iv_numbervalue = '0.1'
              iv_stringvalue = |string|
            )
          )
        )
      )
      iv_enabled = ABAP_TRUE
    )
    iv_description = |string|
    iv_weight = '0.1'
  )
  it_tags = VALUE /aws1/cl_apctagmap_w=>tt_tagmap(
    (
      VALUE /aws1/cl_apctagmap_w=>ts_tagmap_maprow(
        key = |string|
        value = new /aws1/cl_apctagmap_w( |string| )
      )
    )
  )
  it_treatments = VALUE /aws1/cl_apctreatmentinput=>tt_treatmentinputlist(
    (
      new /aws1/cl_apctreatmentinput(
        io_flagvalue = new /aws1/cl_apcflagvalue(
          it_attributevalues = VALUE /aws1/cl_apcattributevalue=>tt_attributevaluemap(
            (
              VALUE /aws1/cl_apcattributevalue=>ts_attributevaluemap_maprow(
                key = |string|
                value = new /aws1/cl_apcattributevalue(
                  it_numberarray = VALUE /aws1/cl_apcnumberlist_w=>tt_numberlist(
                    ( new /aws1/cl_apcnumberlist_w( |0.1| ) )
                  )
                  it_stringarray = VALUE /aws1/cl_apcstringlist_w=>tt_stringlist(
                    ( new /aws1/cl_apcstringlist_w( |string| ) )
                  )
                  iv_booleanvalue = ABAP_TRUE
                  iv_numbervalue = '0.1'
                  iv_stringvalue = |string|
                )
              )
            )
          )
          iv_enabled = ABAP_TRUE
        )
        iv_description = |string|
        iv_weight = '0.1'
      )
    )
  )
  iv_applicationidentifier = |string|
  iv_audiencedescription = |string|
  iv_audiencerule = |string|
  iv_confprofileidentifier = |string|
  iv_environmentidentifier = |string|
  iv_flagkey = |string|
  iv_hypothesis = |string|
  iv_launchcriteria = |string|
  iv_name = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_id = lo_result->get_applicationid( ).
  lv_id = lo_result->get_id( ).
  lv_name = lo_result->get_name( ).
  lv_description = lo_result->get_hypothesis( ).
  lv_experimentdefinitionsta = lo_result->get_status( ).
  lv_id = lo_result->get_configurationprofileid( ).
  lv_id = lo_result->get_environmentid( ).
  lv_flagkey = lo_result->get_flagkey( ).
  lv_rule = lo_result->get_audiencerule( ).
  lv_description = lo_result->get_audiencedescription( ).
  lv_description = lo_result->get_launchcriteria( ).
  LOOP AT lo_result->get_treatments( ) into lo_row.
    lo_row_1 = lo_row.
    IF lo_row_1 IS NOT INITIAL.
      lv_treatmentkey = lo_row_1->get_key( ).
      lv_weight = lo_row_1->get_weight( ).
      lv_description = lo_row_1->get_description( ).
      lo_flagvalue = lo_row_1->get_flagvalue( ).
      IF lo_flagvalue IS NOT INITIAL.
        lv_boolean = lo_flagvalue->get_enabled( ).
        LOOP AT lo_flagvalue->get_attributevalues( ) into ls_row_2.
          lv_key = ls_row_2-key.
          lo_value = ls_row_2-value.
          IF lo_value IS NOT INITIAL.
            lv_attributestring = lo_value->get_stringvalue( ).
            lv_double = lo_value->get_numbervalue( ).
            lv_boolean = lo_value->get_booleanvalue( ).
            LOOP AT lo_value->get_stringarray( ) into lo_row_3.
              lo_row_4 = lo_row_3.
              IF lo_row_4 IS NOT INITIAL.
                lv_attributestring = lo_row_4->get_value( ).
              ENDIF.
            ENDLOOP.
            LOOP AT lo_value->get_numberarray( ) into lo_row_5.
              lo_row_6 = lo_row_5.
              IF lo_row_6 IS NOT INITIAL.
                lv_double = lo_row_6->get_value( ).
              ENDIF.
            ENDLOOP.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDIF.
  ENDLOOP.
  lo_treatment = lo_result->get_control( ).
  IF lo_treatment IS NOT INITIAL.
    lv_treatmentkey = lo_treatment->get_key( ).
    lv_weight = lo_treatment->get_weight( ).
    lv_description = lo_treatment->get_description( ).
    lo_flagvalue = lo_treatment->get_flagvalue( ).
    IF lo_flagvalue IS NOT INITIAL.
      lv_boolean = lo_flagvalue->get_enabled( ).
      LOOP AT lo_flagvalue->get_attributevalues( ) into ls_row_2.
        lv_key = ls_row_2-key.
        lo_value = ls_row_2-value.
        IF lo_value IS NOT INITIAL.
          lv_attributestring = lo_value->get_stringvalue( ).
          lv_double = lo_value->get_numbervalue( ).
          lv_boolean = lo_value->get_booleanvalue( ).
          LOOP AT lo_value->get_stringarray( ) into lo_row_3.
            lo_row_4 = lo_row_3.
            IF lo_row_4 IS NOT INITIAL.
              lv_attributestring = lo_row_4->get_value( ).
            ENDIF.
          ENDLOOP.
          LOOP AT lo_value->get_numberarray( ) into lo_row_5.
            lo_row_6 = lo_row_5.
            IF lo_row_6 IS NOT INITIAL.
              lv_double = lo_row_6->get_value( ).
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDIF.
  lv_iso8601datetime = lo_result->get_createdat( ).
  lv_iso8601datetime = lo_result->get_updatedat( ).
  lv_kmskeyidentifier = lo_result->get_kmskeyidentifier( ).
ENDIF.

To create an experiment definition

The following CreateExperimentDefinition example creates an experiment definition that tests a feature flag with a 50/50 traffic split.

DATA(lo_result) = lo_client->createexperimentdefinition(
  io_control = new /aws1/cl_apctreatmentinput(
    io_flagvalue = new /aws1/cl_apcflagvalue( iv_enabled = ABAP_FALSE )
    iv_weight = '50'
  )
  it_treatments = VALUE /aws1/cl_apctreatmentinput=>tt_treatmentinputlist(
    (
      new /aws1/cl_apctreatmentinput(
        io_flagvalue = new /aws1/cl_apcflagvalue( iv_enabled = ABAP_TRUE )
        iv_weight = '50'
      )
    )
  )
  iv_applicationidentifier = |339ohji|
  iv_audiencerule = |(eq $country "US")|
  iv_confprofileidentifier = |ur8hx2f|
  iv_environmentidentifier = |54j1r29|
  iv_flagkey = |my-feature-flag|
  iv_name = |Example-Experiment-Definition|
).