Using the Code List feature, the content developers can easily create value helps for various fields. For example, to fetch the list of valid partner roles for a consumer when they want to enter a partner role. For this, the content developer needs to first identify the source of the list of valid partner roles, and then by using the Code List feature fetch them for the consumer.
Currently the Code List feature supports:
Value helps fetched from Domains with fixed values
Value helps for BAPI parameters
Value helps for fetched from the QueryCodeList ESA service for codes modeled in ESR
Once the source of the value help is identified the content developer should create an Entity Data Provider Class that inherits the abstract Code List Entity Provider class:
/IWCNT/CL_CLST_EPRRQ_ABS
This class registers the appropriate BOPs based on the source of the value help. The content developer need to override the SET_VALUE_HELP_SOURCE method of the Entity Provider class in order to specify the technical details of the source of the value help.
If the value help is fetched from the fixed values of a domain then the following two public static variables need to be set:
MV_SOURCE_NAME = ‘DOMAIN’
MV_DOMAIN_NAME = Name of the domain
If the value help is fetched for a BAPI Parameter then the following eight public static variable of the class need to be set:
MV_SOURCE_NAME = BAPI
MV_BAPI_OBJ_TYPE = BAPI Object Type
MV_BAPI_OBJ_NAME = BAPI Object Name
MV_BAPI_METHOD_NAME = BAPI Method Name
MV_BAPI_PARAM_NAME = BAPI Parameter Name
MV_BAPI_FIELD_NAME = BAPI Field Name
MV_BAPI_CODE_DESC_TABLE = BAPI Code description table
MV_BAPI_CODE_DESC_FIELD = BAPI Code description table field
If the value help is fetched from QueryCodeList ESA service, then the following four public static variables need to be set:
MV_SOURCE_NAME = 'ESA'
MV_ESA_CODE_NAME = ESA Code Name
MV_ESA_CODE_TYPE = ESA Code Type
MV_ESA_URI_NAMESPACE = ESA URI Namespace
For Partner Roles, the Entity Provider Class can be named as:
IWCNT/CL_CLST_EPRRQ_PROLES
The mv_domain_name variable of this class can be set to:
/SAPTRX/EV_PARROL
And the mv_value_help_source_category variable can be set to:
02
This indicates that the domain with fixed values will be used to fetch the code list in the:
SET_VALUE_HELP_SOURCE method of the class
This domain name would be used in order to fetch the value help for Partner Roles.
Value Help Source is Domain
In order to fetch the list of valid values for Partner Roles, the following values need to be set in the SET_VALUE_HELP_SOURCE method of the class.
MV_VALUE_HELP_SOURCE_CATEGORY = '02'
MV_DOMAIN_NAME = ‘/SAPTRX/EV_PARROL’
Value Help Source is BAPI Parameter
In order to fetch the list of values for title codes from the value help defined for a BAPI Parameter, the following values need to be set in the SET_VALUE_HELP_SOURCE method of the class.
MV_VALUE_HELP_SOURCE_CATEGORY = '01'
MV_BAPI_OBJTYP = 'BUS1006'
MV_BAPI_OBJECT_NAME = 'GETCENTRALDETAIL'
MV_BAPI_METHOD = 'GETADDRESSDETAIL'
MV_BAPI_PARAM = 'CENTRALDATA'
MV_BAPI_FIELD = 'TITLE_KEY'
MV_CODE_DESC_TABLE = 'TSAD3T'
MV_CODE_DESC_FIELD = 'TITLE_MEDI'
Value Help Source is from QueryCodeList- ESA service
MV_VALUE_HELP_SOURCE_CATEGORY = '03'
MV_ESA_NAME = 'CountryCode'
MV_ESA_TYPE = 'CountryCode'
MV_ESA_NAMESPACE = 'http://sap.com/xi/APPL'
Code List offers two backend connectivity APIs in order to fetch Code List from a domain with fixed values and from a BAPI parameter respectively:
/iwcnt/cl_clst_bec_dom
/iwcnt/cl_clst_bec_bapi
The content developer needs to register instances of these APIs as customer BOPs in the REGISTER_MAPPING_SPECIALISTS method of the Entity Provider Class of the entity for which the Code List needs to be fetched. Once registered, the Code List fetched by the backend connectivity API will be available in IT_PROCESSED_BE_DATA parameter of the mapping specialist classes.
Registering Backend Connectivity API for fetching Code List for Gender from a Domain with fixed values
Implement the following code in the Entity Provider Class:
DATA: ls_mapping_specialist_attr TYPE LINE OF gtyt_map_specialist_attributes. DATA: lo_clst_bec_dom TYPE REF TO /iwcnt/cl_clst_bec_dom. ls_mapping_specialist_attr-execution_mode = /iwcnt/if_common_c=>gc_execution_mode_q. ls_mapping_specialist_attr-bop_type = /iwfnd/if_mgw_bec_bop=>gc_bop_type_custom. CREATE OBJECT lo_clst_bec_dom EXPORTING iv_code_name = 'Gender' iv_domain_name = 'AD_SEX'. ls_mapping_specialist_attr-be_api_ref ?= lo_clst_bec_dom. APPEND ls_mapping_specialist_attr TO et_mapping_specialist_attr.
Once the backend API has been registered, the Code List can be accessed via the IT_PROCESSED_BE_DATA parameter in the respective mapping specialists.
DATA: ls_processed_be_data LIKE LINE OF it_processed_be_data, lt_gender_codes TYPE /iwcnt/t_clst_attr. FIELD-SYMBOLS:<ls_processed_be_value> Type any. READ TABLE it_processed_be_data INTO ls_processed_be_data WITH KEY name = 'Gender'. IF sy-subrc = 0. ASSIGN ls_processed_be_data-value->* TO <ls_processed_be_value>. lt_gender_codes[] = <ls_processed_be_value> ENDIF.
The internal tablelt_gender_codes [][] will now contain the gender codes fetched from the fixed values associated with the domain AD_SEX.
Registering Backend Connectivity API for fetching Code List from a BAPI Parameter.
Implement the following code to register the Backend Connectivity API for fetching Code List from a BAPI parameter in the REGISTER_MAPPING_SPECIALISTS method of the entity provider class.
DATA: ls_mapping_specialist_attr TYPE LINE OF gtyt_map_specialist_attributes. DATA: lo_clst_bec_bapi TYPE REF TO /iwcnt/cl_clst_bec_bapi. ls_mapping_specialist_attr-execution_mode = /iwcnt/if_common_c=>gc_execution_mode_q ls_mapping_specialist_attr-bop_type = /iwfnd/if_mgw_bec_bop=>gc_bop_type_custom. CREATE OBJECT lo_clst_bec_bapi EXPORTING iv_code_name = 'TitleCode' iv_bapi_obj_type = 'BUS4001' iv_bapi_obj_name ='ADDRESSORG' iv_bapi_method = 'FindDetail' iv_bapi_param = 'BAPIAD1VL' iv_code_desc_field = 'TITLE_MEDI' iv_code_desc_table = 'TSAD3T' iv_bapi_field = 'TITLE' ls_mapping_specialist_attr-be_api_ref ?= lo_clst_bec_bapi. APPEND ls_mapping_specialist_attr TO et_mapping_specialist_attr.
Once the backend API are registered, Code List can be accessed via the IT_PROCESSED_BE_DATA parameter in the respective mapping specialists.
DATA: ls_processed_be_data LIKE LINE OF it_processed_be_data, lt_gender_codes TYPE /iwcnt/t_clst_attr. FIELD-SYMBOLS:<ls_processed_be_value> Type any. READ TABLE it_processed_be_data INTO ls_processed_be_data WITH KEY name = 'TitleCode'. IF sy-subrc = 0. ASSIGN ls_processed_be_data-value->* TO <ls_processed_be_value>. lt_title_codes[] = <ls_processed_be_value> ENDIF.
The internal table lt_title_codes[] will now contain the Title codes fetched from the value help associated with the BAPI parameter.
The Code List PS model is a very simple model that has two properties namely Code and Text. The property Code is marked as the key of the model and is also the only filterable property of the model. The PS model created for Code List is:
/IWCNT/MGW_CODE LIST _0001_PS
Once the source of the value help has been specified in the Entity Provider class, the content developer should create a SAP Gateway UC data model based on /IWCNT/MGW_CODE LIST _0001_PS
A UC model for Partner roles can be named /IWCNT/PARTNER_ROLES_0001_UC and this model would be created with reference to /IWCNT/MGW_CODE LIST _0001_PS.
The Entity Provider Class /IWCNT/CL_CLST_EPRRQ_PROLES and the SAP Gateway Consumption model /IWCNT/PARTNER_ROLES_0001_UC is then registered in the transaction:
SPRO
.Additional customizing in order to assign the system alias and the GSDO group would also need to be done. See Customizing the SAP Gateway System for more information.
To create a Data Model based on the Code List PS Model proceed as follows:
Logon to the SAP Gateway system.
Open Object Navigator (transaction se80).
Choose SAP GW Data Model from the drop-down list.
Enter a name for the SAP GW Data Model.
The SAP GW Data Model name should follow the convention “<namespace><name>_<version>_UC”
The version must be 4 characters long with leading zeros.
/IWCNT/PARTNER_ROLES_0001_UC
Click Display and choose Yes in the Create Data Model window.
Choose Existing Data Model in the Create From pane.
Enter the following information for the model:
Name as/IWCNT/MGW_CODE LIST
Type as PS
Version as 0001
Set labels, external names, descriptions for the fields in the SAP Gateway Data Model.
To create SAP Gateway Consumption Model based on the SAP Gateway Data Model:
Logon to the SAP Gateway system.
Open Object Navigator (transaction se80).
Choose SAP GW Consumption Model from the drop down list.
Enter the name of an existing SAP Gateway Consumption Model.
Right click the SAP Gateway Consumption Model and choose Add SAP GW Data Model.
Specify the SAP Gateway Data Model created in the Creating SAP Gateway Data Model based on the Code List PS model.
Now the Code List collection for the specific code will be added to the existing SAP Gateway Consumption model
The above steps should be performed for each code.