<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Descriptive text replacing a code in a smartTable in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/descriptive-text-replacing-a-code-in-a-smarttable/qaa-p/12184056#M4557253</link>
    <description>&lt;P&gt;I answer myself, in case it serves someone.&lt;/P&gt;&lt;P&gt;Finally I couldn't create the dropdown exclusively by annotations, so I had to declare the table by the xml view.&lt;/P&gt;&lt;P&gt;My initial problem not to do it this way, is because I add rows to the table in an inelegant way through the addRow method, mixing odata and local data. &lt;/P&gt;&lt;P&gt;It is also a table whose data is updated with the server causing a constant rebind of the table and therefore the rows added from UI5 are removed. &lt;/P&gt;&lt;P&gt;Problem that is caused when I declare the table in the xml view, however we managed to correct it by overwriting the updateItems method of the table.&lt;/P&gt;&lt;P&gt;It is a particular scenario of our project, but for a conventional implementation the following procedure should be correct. &lt;/P&gt;&lt;P&gt;We need: &lt;/P&gt;&lt;P&gt;2 entities: &lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;1 entity that retrieves the data to display with two fields (key and value, for example DropdownKey: "001", DropdownText: "Fantastic option")&lt;/LI&gt;&lt;LI&gt;1 entity with key value fields to retrieve all the data from the dropdown. &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Xml view: we declare the table and the smartField.&lt;/P&gt;&lt;P&gt;Annotations: We define the properties of ValueList&lt;/P&gt;&lt;P&gt;Metadata: Required tags on the fields of the entities.&lt;/P&gt;&lt;P&gt;Entities: &lt;/P&gt;&lt;P&gt;Our dropdown is called "Tipo Posición" consisting of the &lt;EM&gt;ItemType &lt;/EM&gt;and &lt;EM&gt;ItemDescription &lt;/EM&gt;fields.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816473-cu7up.png" /&gt;
&lt;/P&gt;&lt;P&gt;This is our entity for the dropdown: "TipoPosicion" with the key value fields.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816474-mguj2.png" /&gt;
&lt;/P&gt;&lt;P&gt;XML view:&lt;/P&gt;&lt;P&gt;Don't forget to declare the customData library to enable smartFields.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;smartTable:SmartTable entitySet="{EntitySetTable}" width="100%" direction="Column"
		tableType="ResponsiveTable"  useTablePersonalisation="true"
		enableAutoBinding="true" useExportToExcel="true" 
		editTogglable="true" customData:useSmartField="true" &amp;gt;
&amp;lt;Table id ="mainTableListaPosiciones" &amp;gt;
  &amp;lt;columns&amp;gt;
    &amp;lt;Column&amp;gt;
       &amp;lt;customData&amp;gt;
          &amp;lt;core:CustomData key="p13nData" value='\{"columnKey": "ItemType", "columnIndex":"1", "leadingProperty":"ItemType"}'/&amp;gt;
       &amp;lt;/customData&amp;gt;
       &amp;lt;Text text="{/#EntitySetTable/ItemType/@sap:label}"/&amp;gt;
    &amp;lt;/Column&amp;gt;
  &amp;lt;/columns&amp;gt;
  &amp;lt;items&amp;gt;
    &amp;lt;ColumnListItem&amp;gt;
	&amp;lt;cells&amp;gt;
          &amp;lt;smartField:SmartField value="{ItemType}" entitySet="EntitySetTable" &amp;gt;
	    &amp;lt;smartField:configuration&amp;gt; 
		&amp;lt;smartField:Configuration displayBehaviour="descriptionOnly"/&amp;gt;
	    &amp;lt;/smartField:configuration&amp;gt;
	 &amp;lt;/smartField:SmartField&amp;gt;
	&amp;lt;/cells&amp;gt;
     &amp;lt;/ColumnListItem&amp;gt;
   &amp;lt;/items&amp;gt;
  &amp;lt;/Table&amp;gt;
&amp;lt;/smartTable:SmartTable&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Annotations: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Annotations Target="Metadata.EntitySetTable/ItemType"&amp;gt;
   &amp;lt;Annotation Term="Common.ValueListWithFixedValues" Bool="true"/&amp;gt;
      &amp;lt;Annotation Term="Common.ValueList"&amp;gt;
         &amp;lt;Record Type="Common.ValueListType"&amp;gt;
	    &amp;lt;PropertyValue Property="CollectionPath" String="TipoPosicionSet"/&amp;gt;
	    &amp;lt;PropertyValue Property="Parameters"&amp;gt;
		&amp;lt;Collection&amp;gt;
        	   &amp;lt;Record Type="Common.ValueListParameterInOut"&amp;gt;
 		      &amp;lt;PropertyValue Property="LocalDataProperty" PropertyPath="ItemType"/&amp;gt;
		      &amp;lt;PropertyValue Property="ValueListProperty" String="ItemTypeCode"/&amp;gt;
		   &amp;lt;/Record&amp;gt;
		   &amp;lt;Record Type="Common.ValueListParameterDisplayOnly"&amp;gt;
		      &amp;lt;PropertyValue Property="ValueListProperty" String="Description"/&amp;gt;
                   &amp;lt;/Record&amp;gt;
  		   &amp;lt;Record Type="Common.ValueListParameterInOut"&amp;gt;
	              &amp;lt;PropertyValue Property="LocalDataProperty" PropertyPath="ItemDescription"/&amp;gt;
  		      &amp;lt;PropertyValue Property="ValueListProperty" String="Description"/&amp;gt;
	           &amp;lt;/Record&amp;gt;
		&amp;lt;/Collection&amp;gt;
            &amp;lt;/PropertyValue&amp;gt;
	&amp;lt;/Record&amp;gt;
     &amp;lt;/Annotation&amp;gt;
&amp;lt;/Annotations&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Metadata:&lt;/P&gt;&lt;P&gt;We redefined the DEFINE method of the * MPC_EXT class. &lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816477-yqlo5.png" /&gt;
&lt;/P&gt;&lt;P&gt;For the table entity we add the sap: text tags in the key field. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lo_entity_type) = model-&amp;gt;get_entity_type( iv_entity_name =  'EntitySetTable' ).

DATA(lo_property) = lo_entity_type-&amp;gt;get_property( iv_property_name = 'ItemType' ).

DATA(lo_annotation) =
 lo_property-&amp;gt;/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
 lo_annotation-&amp;gt;add( iv_key = 'text'
 iv_value = 'ItemDescription' ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816479-dfkid.png" /&gt;
&lt;/P&gt;&lt;P&gt;In the dropdown entity we add the tags sap:text and in its container sap:semantics = "fixed-values".&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lo_entity_type =
 model-&amp;gt;get_entity_type( iv_entity_name = 'TipoPosicion' ). "#EC NOTEXT

"ItemTypeCode
lo_property = lo_entity_type-&amp;gt;get_property( iv_property_name = 'ItemTypeCode' ).

lo_annotation = 
   lo_property-&amp;gt;/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
 lo_annotation-&amp;gt;add( iv_key = 'text'
 iv_value = 'Description' ).
lo_entity_set = model-&amp;gt;get_entity_set( iv_entity_set_name = 'TipoPosicionSet' ).
lo_annotation = lo_entity_set-&amp;gt;create_annotation( iv_annotation_namespace = 'sap' ).
lo_annotation-&amp;gt;add(
 EXPORTING
 iv_key = 'semantics'
 iv_value = 'fixed-values'
 ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816481-lmc98.png" /&gt;
&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816482-97ubt.png" /&gt;
&lt;/P&gt;&lt;P&gt;In this way we achieve the desired result:
&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816480-4nqwy.png" /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2020 14:51:33 GMT</pubDate>
    <dc:creator>Ricardo___</dc:creator>
    <dc:date>2020-06-04T14:51:33Z</dc:date>
    <item>
      <title>Descriptive text replacing a code in a smartTable</title>
      <link>https://community.sap.com/t5/technology-q-a/descriptive-text-replacing-a-code-in-a-smarttable/qaq-p/12184055</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
  &lt;P&gt; I have the following scenario.&lt;/P&gt;
  &lt;P&gt; A smartTable with two fields, one for the code and one for its description. &lt;/P&gt;
  &lt;P&gt;What I want to represent is a single field with the description that will later become a drop-down with different options defined by its code.&lt;/P&gt;
  &lt;P&gt; I want to get something like this, but only using annotations.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1784808-2020-03-09-1223.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1784809-2020-03-09-1224.png" /&gt;&lt;/P&gt;
  &lt;P&gt; I know that within the SmartTable I can define a table with Smartfields to get it, but it is not what I am looking for, it has to work by annotations.&lt;/P&gt;
  &lt;P&gt;What I have is the following:&lt;/P&gt;
  &lt;P&gt; This is my SmartTable: &lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1784810-2020-03-09-1229.png" /&gt;&lt;/P&gt;
  &lt;P&gt;In the metadata we receive this:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1784811-2020-03-09-1232.png" /&gt;&lt;/P&gt;
  &lt;P&gt; And in the annotations we have declared the LineItems and for the code field the dropdown. &lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1784812-2020-03-09-1235.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1784813-2020-03-09-1236.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Getting the following functionality:&lt;/P&gt;
  &lt;P&gt; Reading Mode:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1784814-2020-03-09-1238.png" /&gt;&lt;/P&gt;
  &lt;P&gt; Edit Mode:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1784815-2020-03-09-1241.png" /&gt;&lt;/P&gt;
  &lt;P&gt; But here I have two problems. &lt;/P&gt;
  &lt;P&gt;In read mode, the code is represented, not its description. &lt;/P&gt;
  &lt;P&gt;In Edit mode, your displayBehavior shows the description and code, but I just want the description.&lt;/P&gt;
  &lt;P&gt; How can I get this?, just by annotations.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 12:08:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/descriptive-text-replacing-a-code-in-a-smarttable/qaq-p/12184055</guid>
      <dc:creator>Ricardo___</dc:creator>
      <dc:date>2020-03-09T12:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Descriptive text replacing a code in a smartTable</title>
      <link>https://community.sap.com/t5/technology-q-a/descriptive-text-replacing-a-code-in-a-smarttable/qaa-p/12184056#M4557253</link>
      <description>&lt;P&gt;I answer myself, in case it serves someone.&lt;/P&gt;&lt;P&gt;Finally I couldn't create the dropdown exclusively by annotations, so I had to declare the table by the xml view.&lt;/P&gt;&lt;P&gt;My initial problem not to do it this way, is because I add rows to the table in an inelegant way through the addRow method, mixing odata and local data. &lt;/P&gt;&lt;P&gt;It is also a table whose data is updated with the server causing a constant rebind of the table and therefore the rows added from UI5 are removed. &lt;/P&gt;&lt;P&gt;Problem that is caused when I declare the table in the xml view, however we managed to correct it by overwriting the updateItems method of the table.&lt;/P&gt;&lt;P&gt;It is a particular scenario of our project, but for a conventional implementation the following procedure should be correct. &lt;/P&gt;&lt;P&gt;We need: &lt;/P&gt;&lt;P&gt;2 entities: &lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;1 entity that retrieves the data to display with two fields (key and value, for example DropdownKey: "001", DropdownText: "Fantastic option")&lt;/LI&gt;&lt;LI&gt;1 entity with key value fields to retrieve all the data from the dropdown. &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Xml view: we declare the table and the smartField.&lt;/P&gt;&lt;P&gt;Annotations: We define the properties of ValueList&lt;/P&gt;&lt;P&gt;Metadata: Required tags on the fields of the entities.&lt;/P&gt;&lt;P&gt;Entities: &lt;/P&gt;&lt;P&gt;Our dropdown is called "Tipo Posición" consisting of the &lt;EM&gt;ItemType &lt;/EM&gt;and &lt;EM&gt;ItemDescription &lt;/EM&gt;fields.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816473-cu7up.png" /&gt;
&lt;/P&gt;&lt;P&gt;This is our entity for the dropdown: "TipoPosicion" with the key value fields.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816474-mguj2.png" /&gt;
&lt;/P&gt;&lt;P&gt;XML view:&lt;/P&gt;&lt;P&gt;Don't forget to declare the customData library to enable smartFields.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;smartTable:SmartTable entitySet="{EntitySetTable}" width="100%" direction="Column"
		tableType="ResponsiveTable"  useTablePersonalisation="true"
		enableAutoBinding="true" useExportToExcel="true" 
		editTogglable="true" customData:useSmartField="true" &amp;gt;
&amp;lt;Table id ="mainTableListaPosiciones" &amp;gt;
  &amp;lt;columns&amp;gt;
    &amp;lt;Column&amp;gt;
       &amp;lt;customData&amp;gt;
          &amp;lt;core:CustomData key="p13nData" value='\{"columnKey": "ItemType", "columnIndex":"1", "leadingProperty":"ItemType"}'/&amp;gt;
       &amp;lt;/customData&amp;gt;
       &amp;lt;Text text="{/#EntitySetTable/ItemType/@sap:label}"/&amp;gt;
    &amp;lt;/Column&amp;gt;
  &amp;lt;/columns&amp;gt;
  &amp;lt;items&amp;gt;
    &amp;lt;ColumnListItem&amp;gt;
	&amp;lt;cells&amp;gt;
          &amp;lt;smartField:SmartField value="{ItemType}" entitySet="EntitySetTable" &amp;gt;
	    &amp;lt;smartField:configuration&amp;gt; 
		&amp;lt;smartField:Configuration displayBehaviour="descriptionOnly"/&amp;gt;
	    &amp;lt;/smartField:configuration&amp;gt;
	 &amp;lt;/smartField:SmartField&amp;gt;
	&amp;lt;/cells&amp;gt;
     &amp;lt;/ColumnListItem&amp;gt;
   &amp;lt;/items&amp;gt;
  &amp;lt;/Table&amp;gt;
&amp;lt;/smartTable:SmartTable&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Annotations: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Annotations Target="Metadata.EntitySetTable/ItemType"&amp;gt;
   &amp;lt;Annotation Term="Common.ValueListWithFixedValues" Bool="true"/&amp;gt;
      &amp;lt;Annotation Term="Common.ValueList"&amp;gt;
         &amp;lt;Record Type="Common.ValueListType"&amp;gt;
	    &amp;lt;PropertyValue Property="CollectionPath" String="TipoPosicionSet"/&amp;gt;
	    &amp;lt;PropertyValue Property="Parameters"&amp;gt;
		&amp;lt;Collection&amp;gt;
        	   &amp;lt;Record Type="Common.ValueListParameterInOut"&amp;gt;
 		      &amp;lt;PropertyValue Property="LocalDataProperty" PropertyPath="ItemType"/&amp;gt;
		      &amp;lt;PropertyValue Property="ValueListProperty" String="ItemTypeCode"/&amp;gt;
		   &amp;lt;/Record&amp;gt;
		   &amp;lt;Record Type="Common.ValueListParameterDisplayOnly"&amp;gt;
		      &amp;lt;PropertyValue Property="ValueListProperty" String="Description"/&amp;gt;
                   &amp;lt;/Record&amp;gt;
  		   &amp;lt;Record Type="Common.ValueListParameterInOut"&amp;gt;
	              &amp;lt;PropertyValue Property="LocalDataProperty" PropertyPath="ItemDescription"/&amp;gt;
  		      &amp;lt;PropertyValue Property="ValueListProperty" String="Description"/&amp;gt;
	           &amp;lt;/Record&amp;gt;
		&amp;lt;/Collection&amp;gt;
            &amp;lt;/PropertyValue&amp;gt;
	&amp;lt;/Record&amp;gt;
     &amp;lt;/Annotation&amp;gt;
&amp;lt;/Annotations&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Metadata:&lt;/P&gt;&lt;P&gt;We redefined the DEFINE method of the * MPC_EXT class. &lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816477-yqlo5.png" /&gt;
&lt;/P&gt;&lt;P&gt;For the table entity we add the sap: text tags in the key field. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lo_entity_type) = model-&amp;gt;get_entity_type( iv_entity_name =  'EntitySetTable' ).

DATA(lo_property) = lo_entity_type-&amp;gt;get_property( iv_property_name = 'ItemType' ).

DATA(lo_annotation) =
 lo_property-&amp;gt;/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
 lo_annotation-&amp;gt;add( iv_key = 'text'
 iv_value = 'ItemDescription' ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816479-dfkid.png" /&gt;
&lt;/P&gt;&lt;P&gt;In the dropdown entity we add the tags sap:text and in its container sap:semantics = "fixed-values".&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lo_entity_type =
 model-&amp;gt;get_entity_type( iv_entity_name = 'TipoPosicion' ). "#EC NOTEXT

"ItemTypeCode
lo_property = lo_entity_type-&amp;gt;get_property( iv_property_name = 'ItemTypeCode' ).

lo_annotation = 
   lo_property-&amp;gt;/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
 lo_annotation-&amp;gt;add( iv_key = 'text'
 iv_value = 'Description' ).
lo_entity_set = model-&amp;gt;get_entity_set( iv_entity_set_name = 'TipoPosicionSet' ).
lo_annotation = lo_entity_set-&amp;gt;create_annotation( iv_annotation_namespace = 'sap' ).
lo_annotation-&amp;gt;add(
 EXPORTING
 iv_key = 'semantics'
 iv_value = 'fixed-values'
 ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816481-lmc98.png" /&gt;
&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816482-97ubt.png" /&gt;
&lt;/P&gt;&lt;P&gt;In this way we achieve the desired result:
&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816480-4nqwy.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 14:51:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/descriptive-text-replacing-a-code-in-a-smarttable/qaa-p/12184056#M4557253</guid>
      <dc:creator>Ricardo___</dc:creator>
      <dc:date>2020-06-04T14:51:33Z</dc:date>
    </item>
  </channel>
</rss>

