{"id":1270,"date":"2015-01-27T15:13:53","date_gmt":"2015-01-27T14:13:53","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1270"},"modified":"2015-01-27T15:13:53","modified_gmt":"2015-01-27T14:13:53","slug":"abap-combobox-on-selection-screen","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1270","title":{"rendered":"ABAP &#8211; ComboBox on Selection-Screen"},"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 create a combo box as one of selection-screen parameters<!--more--><br \/>\nI personally like OO ABAP, therefore I&#8217;ll use a helper class which will implement a method returning pairs of key-value for our combo box.<\/p>\n<pre lang=\"abap\">CLASS lcl_helper DEFINITION.\r\n  PUBLIC SECTION.\r\n    CLASS-METHODS:\r\n      get_combo_items RETURNING VALUE(rt_cbx_items) TYPE vrm_values.\r\nENDCLASS.<\/pre>\n<p>&#8230;and it&#8217;s implementation<\/p>\n<pre lang=\"abap\">CLASS lcl_helper IMPLEMENTATION.\r\n  METHOD get_combo_items.\r\n    FIELD-SYMBOLS:\r\n      &lt;ls_vrm&gt; LIKE LINE OF rt_cbx_items.\r\n\r\n    APPEND INITIAL LINE TO rt_cbx_items ASSIGNING &lt;ls_vrm&gt;.\r\n    &lt;ls_vrm&gt;-key = 'A'.\r\n    &lt;ls_vrm&gt;-text = 'First Option'.\r\n\r\n    APPEND INITIAL LINE TO rt_cbx_items ASSIGNING &lt;ls_vrm&gt;.\r\n    &lt;ls_vrm&gt;-key = 'B'.\r\n    &lt;ls_vrm&gt;-text = 'Second Option'.\r\n\r\n    APPEND INITIAL LINE TO rt_cbx_items ASSIGNING &lt;ls_vrm&gt;.\r\n    &lt;ls_vrm&gt;-key = 'C'.\r\n    &lt;ls_vrm&gt;-text = 'Third Option'.\r\n  ENDMETHOD.\r\nENDCLASS.<\/pre>\n<p>Now let&#8217;s define the selection screen:<\/p>\n<pre lang=\"abap\">SELECTION-SCREEN BEGIN OF BLOCK b01.\r\n  PARAMETERS:\r\n    p_combo AS LISTBOX VISIBLE LENGTH 15 OBLIGATORY.\r\nSELECTION-SCREEN END OF BLOCK b01.<\/pre>\n<p>We have to fill the combo box with values &#8211; this will be done in the <em>INITIALIZATION<\/em> part of processing.<\/p>\n<pre lang=\"abap\">INITIALIZATION.\r\n  CALL FUNCTION 'VRM_SET_VALUES'\r\n    EXPORTING\r\n      id              = 'P_COMBO'\r\n      values          = lcl_helper=&gt;get_combo_items( )\r\n    EXCEPTIONS\r\n      id_illegal_name = 1\r\n      OTHERS          = 2.\r\n\r\n* We pre-select the second option\r\n  p_combo = 'B'.<\/pre>\n<p>After you execute the report you&#8217;ll see the following:<br \/>\n<a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/COMBOBOX_SELECTIONSCREEN.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1271\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1271\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/COMBOBOX_SELECTIONSCREEN.png\" data-orig-size=\"362,103\" 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=\"ComboBox on Selection-Screen\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/COMBOBOX_SELECTIONSCREEN.png\" class=\"alignnone size-medium wp-image-1271\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/COMBOBOX_SELECTIONSCREEN-300x85.png\" alt=\"ComboBox on Selection-Screen\" width=\"300\" height=\"85\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/COMBOBOX_SELECTIONSCREEN-300x85.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/COMBOBOX_SELECTIONSCREEN.png 362w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article I&#8217;ll show you how to create a combo box as one of selection-screen parameters<\/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 - ComboBox on Selection-Screen","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,9,222],"tags":[382,135,355],"class_list":["post-1270","post","type-post","status-publish","format-standard","hentry","category-abap","category-development","category-dynpro","tag-combobox","tag-listbox","tag-selection-screen"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-ku","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1270","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=1270"}],"version-history":[{"count":1,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1270\/revisions"}],"predecessor-version":[{"id":1272,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1270\/revisions\/1272"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}