Skip to Content
Author's profile photo Petr Plenkov

Simple generic popup selection screen for quick input or output

Hola,

Today I’m going to share with you some tiny class that can save up much time when you develop something rapidly.

For those guys who accepts generic programming it will be a good present as well.

So with the help of the class CL_CI_QUERY_ATTRIBUTES we can raise a screen like this:

/wp-content/uploads/2015/01/upload_2015_01_27_at_1_05_03_pm_632063.png

with the code like this:


report ztest_generic_screen.
start-of-selection.
  perform main.
form main.
  data: lv_bukrs type bukrs,
        " select-options: type range of.. (must be dictionary type)
        lrg_werks type ckf_werks_table,
        " select-options: table, separate values
        lt_werks TYPE plants ,
        " checkbox + radiobutton ( must be DDIC types )
        lv_simulate type xfeld,
        lv_mode_open type xfeld,
        lv_mode_close type xfeld,
        lv_language TYPE spras.
  lv_language = sy-langu.
  " Generic screen call
  cl_ci_query_attributes=>generic(
    exporting
      " unique screen ID
      p_name       = conv #( sy-repid )
      " Screen title
      p_title      = 'Generic screen for input'
      " Screen fields
      p_attributes = value #(
        " parameter field
       ( kind = 'S'
         obligatory = abap_true
         text = 'Company code'(001)
         ref = ref #( lv_bukrs ) )
       " select-option
       ( kind = 'S'
         text = 'Plant'(002)
         ref = ref #( lrg_werks ) )
       " selec-option no intervals
       ( kind = 'T'
         text = 'Additional plants'(008)
         ref = ref #( lt_werks ) )
       " Screen groupd
       ( kind = 'G'
         text = 'Mode'(006)
         ref = ref #( SY-INDEX ) )
       " radiobuttons
       ( kind = 'R'
         text = 'Open'(004)
         button_group = 'MOD'
         ref = ref #( lv_mode_open ) )
       ( kind = 'R'
         text = 'Close'(005)
         button_group = 'MOD'
         ref = ref #( lv_mode_close ) )
       " checkbox field
       ( kind = 'C'
         text = 'Simulate'(003)
         ref = ref #( lv_simulate ) )
       " listbox field
       ( kind = 'L'
         text = 'Language'(007)
         ref = ref #( lv_language ) )
       )    " Table of Attribute Entries
      p_display    = abap_false    " General Flag
  ).
endform.

As you see we can use checkboxes, radiobuttons, listboxes, screen groups, obligatory option.

I don’t pretend this class to be used in serious programs, as of course only screens provide all the necessary stuff.

But if we speak about some simple screen to be raised from the class – this is kind of a fast solution avoiding screen and GUI status creation.

Good Luck,

I hope you liked it!

Adios.

Assigned Tags

      18 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo SOMENDRA SHUKLA
      SOMENDRA SHUKLA

      Nice Article , Thanks for sharing.

      Author's profile photo Mauricio Lauffer
      Mauricio Lauffer

      Nice one. I didn't know this class.

      But I think the FUNCTION POPUP_GET_VALUES is easier to use    😉

      Author's profile photo Petr Plenkov
      Petr Plenkov
      Blog Post Author

      Does it provide checkbox and radiobuttons?

      Previously I used FREE_SELECTIONS_DIALOG in dynamic programs, but it doesn't support them.

      Author's profile photo Mauricio Lauffer
      Mauricio Lauffer

      I've never used it for checkbox/radio. But I think it doesn't support...

      Author's profile photo T Fdo
      T Fdo

      Very useful..Nice one

      Author's profile photo gnaneswar reddy kothakota
      gnaneswar reddy kothakota

      Thanks for sharing !! Useful one..

      Author's profile photo Markus Deuter
      Markus Deuter

      Thank you for shareing ... it is indeed a good present

      One question. Are there any special release requirements ?

      On SAP ERP 6.0 without any EHP I get Trouble on conv#

      Have a look to this

      trouble on CONV.JPG

      Any ideas ?

      By the way ... I never heard about #conv, #value, #ref commands.

      Our F1 gives no help on this.

      Do you have a describing help swebite on this commands. are they new ?

      Thank you ...

      Regards,

      Markus

      Author's profile photo Markus Deuter
      Markus Deuter
      Author's profile photo Markus Deuter
      Markus Deuter

      To give a little present back to the SCN community, here is a ECC6.0 / Base 7.3 compatible example ...

      REPORT ztest_generic_screen.

      TYPE-POOLS abap.

        DATA: lt_elements TYPE sci_atttab,
              ls_element LIKE LINE OF lt_elements,

              lv_group1 TYPE text30,
              lv_group2 TYPE text30,

              lv_descr TYPE fm_text,
              lv_matnr TYPE matnr,
              lv_auftyp TYPE auftyp, "values taken from DDIC type
              lt_plants TYPE ckf_werks_table, "must be a DDIC type

              lv_flag1 TYPE xfeld VALUE abap_true, "with a default value
              lv_rb1 TYPE xfeld,
              lv_rd2 TYPE xfeld VALUE abap_true. "with a vefault value

        START-OF-SELECTION.
          PERFORM main.

      *&---------------------------------------------------------------------*
      *&      Form  main
      *&---------------------------------------------------------------------*

        FORM main.
          DATA: lv_title TYPE sychar30 VALUE sy-repid.

          GET REFERENCE OF lv_group1 INTO ls_element-ref.
          ls_element-text = 'Group 1'.
          ls_element-kind = 'G'.
          APPEND ls_element TO lt_elements.

          GET REFERENCE OF lv_descr INTO ls_element-ref.
          ls_element-text = 'Comment'.
          ls_element-kind = ' '.
          APPEND ls_element TO lt_elements.

          GET REFERENCE OF lv_matnr INTO ls_element-ref.
          ls_element-text = 'Material'.
          ls_element-kind = ' '.
          "ls_element-obligatory = abap_true. "obligatory !
          APPEND ls_element TO lt_elements.

          GET REFERENCE OF lt_plants INTO ls_element-ref.
          ls_element-text = 'Select option'.
          ls_element-kind = 'S'.
          APPEND ls_element TO lt_elements.

          GET REFERENCE OF lv_auftyp INTO ls_element-ref.
          ls_element-text = 'Order type'.
          ls_element-kind = 'L'.
          APPEND ls_element TO lt_elements.

          GET REFERENCE OF lv_group1 INTO ls_element-ref.
          ls_element-text = 'Group 2'.
          ls_element-kind = 'G'.
          APPEND ls_element TO lt_elements.

          GET REFERENCE OF lv_flag1 INTO ls_element-ref.
          ls_element-text = 'Checkbox'.
          ls_element-kind = 'C'.
          APPEND ls_element TO lt_elements.

          GET REFERENCE OF lv_rb1 INTO ls_element-ref.
          ls_element-text = 'Radiobutton 1'.
          ls_element-kind = 'R'.
          APPEND ls_element TO lt_elements.

          GET REFERENCE OF lv_rb1 INTO ls_element-ref.
          ls_element-text = 'Radiobutton 2'.
          ls_element-kind = 'R'.
          APPEND ls_element TO lt_elements.

          cl_ci_query_attributes=>generic(
            EXPORTING
              p_name       = lv_title
              p_title      = 'Generic screen for input'(001)
              p_attributes = lt_elements
              p_display    = abap_false
              ).

        ENDFORM.                    "main

      The result is

      dynamic dialog.JPG

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Stumbled upon this by accident. Very cool, thank you for sharing! And special thanks to Markus Deuter for sharing pre-7.4 version. 🙂

      Possibly a stupid question: how did you know about all the possible values in the KIND field? I can't see anything assigned in data dictionary and no documentation for the class either.

      Thank you!

       

      Author's profile photo Alfonso Rodríguez Pérez
      Alfonso Rodríguez Pérez

      Hi Jelena,

      I'm preparing a post for this topic as well...

      Not stupid question at all!...

      During execution method GENERATE_PROGRAM of class CL_CI_QUERY_ATTRIBUTES is called. Inside the code of the method you can find how screen is built and you can find how KIND field is managed:

                  case L_ATTRIBUTE-KIND.
                    when 'C'. " checkbox
                      APP 'AS CHECKBOX modif id SO.'.
      *             if STRLEN( L_ATTRIBUTE-TEXT ) > 30.
      *               raise TEXT_TOO_LONG.
      *             endif.
      
                    when 'R'.  " radiobutton
                      if L_ATTRIBUTE-BUTTON_GROUP is initial.
                        L_LINE = 'radiobutton group G000 modif id SO.'. "#EC NOTEXT
                      else.
                        concatenate
                          'radiobutton group' L_ATTRIBUTE-BUTTON_GROUP 'modif id SO.' "#EC NOTEXT
                          into L_LINE
                          separated by SPACE.
                      endif.
                      APP L_LINE.
      
                    when 'L'.  " (Listbox).
                      concatenate
                        'as listbox visible length 20' 'modif id SO.' "#EC NOTEXT
                        into L_LINE
                        separated by SPACE.
                      APP L_LINE.
      
                    when others.
                      APP 'modif id SO.'.
      *              if STRLEN( L_ATTRIBUTE-TEXT ) > 40.
      *                raise TEXT_TOO_LONG.
      *              endif.

       

      Regards,
      Alfonso.

      Author's profile photo Former Member
      Former Member

      Nice stuff. Today I saved lot of time.

      Thank!

      Author's profile photo Alfonso Rodríguez Pérez
      Alfonso Rodríguez Pérez

      Hola,

      I was preparing a post for this functionality and you already done!

      Nice one!

       

      Gracias,
      Alfonso.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thank you for not posting repeated content (like some people do, unfortunately) and instead commenting on the existing blog. You are a true Community Hero! 🙂

      P.S. It is totally OK to post on the same subject though if you have something to add to it.

      Author's profile photo deepak hada
      deepak hada

      Do post if it offers different example than the one above, no harm.

      Author's profile photo Katherine Darunday
      Katherine Darunday

      Hello everyone,

      This class has helped me in my requirement where I needed to create a selection screen based on a parameter table. However I want my selection screen on a normal sized screen and not displayed as a pop-up. Do you guys know of any class with the same functionality as CL_CI_QUERY_ATTRIBUTES but not displayed on a pop-up screen?

      Thank you.

      Regards,

      Katherine Darunday

      Author's profile photo Sercan Kucukdemirci
      Sercan Kucukdemirci

      You can copy the class into Z class then

      in GENERATE_PROGRAM method replace

      call selection-screen 0100 starting at 1 1.

      with

      call selection-screen 0100.

      Also i need to mention that this class doesn't return a value if user closed screen or proceeded. I had to write extra few lines to accomplish this.

       

      Regards,

      Sercan

      Author's profile photo deepak hada
      deepak hada

      Do you know if we can have a custom list box and not from the domain, any way to achieve that.