Example: Context-Dependent Code List

Overview

You are using the work agreement code list in your solution. Now you want to make sure that the values of the code list differ according to the country where the code list is used.

Prerequisites

You have created a solution in the studio.

Procedure

  1. Create the custom business object.

    1. In the studio in the Solution Explorer, open your solution and click Add New Item.

      The Add New Item dialog box opens.

    2. Select Business Object, enter the name CodeListMapping_Test and click Add.

      The business object editor opens.

    3. Enter the following coding. You can also download it here.

      • import AP.Common.GDT as apCommonGDT;
      • businessobject CodeListMapping_Test {
      • element CountryCode : CountryCode;
      • element CustomerWorkAgreementAdministrativeCategoryCode : WorkAgreementAdministrativeCategoryCode;
      • }
    4. Save and activate the business object.

  2. Create the screen.

    1. In the Solution Explorer, right-click the business object and select Create Screens.

      The Create Screens dialog box opens.

    2. Under Screen Type, select Quick Activity Floorplan (QAF) and click OK.

    3. In the Solution Explorer, right-click the .qa.uicomponent file and select Open in UI Designer.

      The file opens in the UI designer.

  3. Assign the context to the code list.

    1. Switch to edit mode.

    2. On the DataModel tab, on the left, right-click Root/CodeListMapping_Test/CustomerWorkAgreementAdministrativeCategoryCode/content and select Codelist Content Mapping.

      This graphic is explained in the accompanying text.

      Data Model Tab

      The Model Codelist Context Mapping of content dialog box opens.

    3. Select the Selected checkbox and click ....

      This graphic is explained in the accompanying text.

      Dialog Box: Model Codelist Context Mapping of content

      The Select Data Field dialog box opens.

    4. Select the Root/CodeListMapping_Test/CountryCode data field and click OK and then OK.

    5. Save and activate your changes.

  4. Test the UI model.

    1. In the UI designer, select the Preview tab.

    2. Log on to SAP Business ByDesign.

      The CodeListMapping_Test UI appears.

    3. In the CountryCode field, select a country.

      The list entries in the CustomerWorkAgreementAdministrativeCategoryCode field change depending on which country you choose.

    This graphic is explained in the accompanying text.

    Preview