{"id":1273,"date":"2015-02-02T09:33:51","date_gmt":"2015-02-02T08:33:51","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1273"},"modified":"2015-02-02T09:33:51","modified_gmt":"2015-02-02T08:33:51","slug":"abap-problems-with-combo-box-in-alv","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1273","title":{"rendered":"ABAP &#8211; Problems with combo box in ALV"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\" size-full wp-image-358 alignleft\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" alt=\"SAP\" width=\"44\" height=\"50\" \/>In this article I&#8217;ll show you how to implement a &#8220;combo box&#8221; with key-value structure as one of ALV columns. <!--more-->It can be considered as an easy task but you would be facing an unexpected problem in ALV which will display KEYS instead of VALUES of the combo box. If you select a value from the list, it will be displayed correctly until you press enter (in case you have the Enter event handled) or you refresh the grid. After refresh keys will be displayed again instead of values.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_02.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1275\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1275\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_02.png\" data-orig-size=\"300,214\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Keys are displayed instead of values\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_02.png\" class=\"alignnone size-medium wp-image-1275\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_02-300x214.png\" alt=\"Keys are displayed instead of values\" width=\"300\" height=\"214\" \/><\/a><\/p>\n<p>I&#8217;m not sure if this is a bug or a &#8220;feature&#8221; in SAP,\u00a0 but in my task I needed to have KEYS hidden in the combo control and display the VALUE (understandable text) to the user. This was necessary because I had to display &#8220;Short text&#8221; description of selected DDIC domain value.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_01.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1274\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1274\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_01.png\" data-orig-size=\"566,349\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Domain definition\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_01.png\" class=\"alignnone size-medium wp-image-1274\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_01-300x185.png\" alt=\"Domain definition\" width=\"300\" height=\"185\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_01-300x185.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_01-487x300.png 487w, https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_01.png 566w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>One solution of this &#8220;issue&#8221; can be described in the following steps:<\/p>\n<ol>\n<li>The required ALV column is marked with dropdown handle ID in field catalog\n<pre lang=\"abap\">\"There might be more than one handle defined,\r\nbecause you can have more than one combo columns in your ALV\r\nSo we have to specify which one will this field use\r\n&lt;ls_fcat&gt;-drdn_hndl = 1.<\/pre>\n<\/li>\n<li>The required ALV column is marked with dopdown alias in field catalog\n<pre lang=\"abap\">&lt;ls_fcat&gt;-drdn_alias = abap_true.<\/pre>\n<\/li>\n<li>The required ALV column might be set as editable (in case you want it)\n<pre lang=\"abap\">&lt;ls_fcat&gt;-edit = abap_true.<\/pre>\n<\/li>\n<li>Prepare an itab structure holding dropdown key-value items\n<pre lang=\"abap\">METHOD get_combo_items.\r\n  DATA:\r\n    lt_dd07v TYPE TABLE OF dd07v.\r\n\r\n  FIELD-SYMBOLS:\r\n    &lt;ls_dral&gt; TYPE lvc_s_dral,\r\n    &lt;ls_dd07&gt; TYPE dd07v.\r\n\r\n* Get values and their short texts for given domain \r\n  CALL FUNCTION 'DDIF_DOMA_GET'\r\n    EXPORTING\r\n      name      = 'ZDOM_TEST'\r\n      langu     = sy-langu\r\n    TABLES\r\n      dd07v_tab = lt_dd07v.\r\n\r\n  LOOP AT lt_dd07v ASSIGNING &lt;ls_dd07&gt;.\r\n    APPEND INITIAL LINE TO rt_dral ASSIGNING &lt;ls_dral&gt;.\r\n    &lt;ls_dral&gt;-handle    = 1.\r\n    &lt;ls_dral&gt;-int_value = &lt;ls_dd07&gt;-domvalue_l.\r\n    &lt;ls_dral&gt;-value     = &lt;ls_dd07&gt;-ddtext.\r\n  ENDLOOP.\r\nENDMETHOD.<\/pre>\n<\/li>\n<li>Attach the itab with items to the ALV grid\n<pre lang=\"abap\">me-&gt;mo_grid-&gt;set_drop_down_table(\r\n  it_drop_down_alias = me-&gt;get_combo_items( )\r\n).<\/pre>\n<\/li>\n<li>Create standard INPUT (VALUE -&gt; KEY) conversion exit\n<pre lang=\"abap\">FUNCTION conversion_exit_zprio_input.\r\n*\"---------------------------------------------------------\r\n*\"*\"Local Interface:\r\n*\"  IMPORTING\r\n*\"     VALUE(INPUT)\r\n*\"  EXPORTING\r\n*\"     VALUE(OUTPUT)\r\n*\"---------------------------------------------------------\r\n  DATA:\r\n    lt_dd07v TYPE TABLE OF dd07v.\r\n  FIELD-SYMBOLS:\r\n    &lt;ls_dd07&gt; TYPE dd07v.\r\n\r\n  CALL FUNCTION 'DDIF_DOMA_GET'\r\n    EXPORTING\r\n      name      = 'ZDOM_TEST'\r\n      langu     = sy-langu\r\n    TABLES\r\n      dd07v_tab = lt_dd07v.\r\n\r\n  READ TABLE lt_dd07v ASSIGNING &lt;ls_dd07&gt;\r\n    WITH KEY ddtext = input.\r\n  CHECK sy-subrc = 0.\r\n\r\n  output = &lt;ls_dd07&gt;-domvalue_l.\r\nENDFUNCTION.<\/pre>\n<\/li>\n<li>Create standard OUTPUT (KEY-&gt; VALUE) conversion exit\n<pre lang=\"abap\">FUNCTION CONVERSION_EXIT_ZPRIO_OUTPUT.\r\n*\"----------------------------------------------------------\r\n*\"*\"Local Interface:\r\n*\"  IMPORTING\r\n*\"     VALUE(INPUT)\r\n*\"  EXPORTING\r\n*\"     VALUE(OUTPUT)\r\n*\"----------------------------------------------------------\r\n  DATA:\r\n    lt_dd07v TYPE TABLE OF dd07v.\r\n  FIELD-SYMBOLS:\r\n    &lt;ls_dd07&gt; TYPE dd07v.\r\n\r\n  CALL FUNCTION 'DDIF_DOMA_GET'\r\n    EXPORTING\r\n      name      = 'ZDOM_TEST'\r\n      langu     = sy-langu\r\n    TABLES\r\n      dd07v_tab = lt_dd07v.\r\n\r\n  READ TABLE lt_dd07v ASSIGNING &lt;ls_dd07&gt;\r\n    WITH KEY domvalue_l = input.\r\n  CHECK sy-subrc = 0.\r\n\r\n  output = &lt;ls_dd07&gt;-ddtext.\r\nENDFUNCTION.<\/pre>\n<\/li>\n<li>Assign your conversion exit to the ALV field with dropdown in field catalog\n<pre lang=\"abap\">&lt;ls_fcat&gt;-convexit = 'ZPRIO'.<\/pre>\n<\/li>\n<\/ol>\n<p>The result should now be like this:<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_03.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1276\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1276\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_03.png\" data-orig-size=\"353,211\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ALV Dropdown with correct key-value assignment\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_03.png\" class=\"alignnone size-medium wp-image-1276\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_03-300x179.png\" alt=\"ALV Dropdown with correct key-value assignment\" width=\"300\" height=\"179\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_03-300x179.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/ALV_COMBO_03.png 353w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/Z_ALV_DROPDOWN.zip\">You can donwload complete source code of Z_ALV_DROPDOWN right here.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article I&#8217;ll show you how to implement a &#8220;combo box&#8221; with key-value structure as one of ALV columns.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"ABAP - Problems with combo box in ALV","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,86,9,222],"tags":[447,382,383,384,134],"class_list":["post-1273","post","type-post","status-publish","format-standard","hentry","category-abap","category-alv","category-development","category-dynpro","tag-alv","tag-combobox","tag-conversion-exit","tag-ddif_doma_get","tag-dropdown"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-kx","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1273"}],"version-history":[{"count":1,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1273\/revisions"}],"predecessor-version":[{"id":1279,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1273\/revisions\/1279"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}