Skip to Content

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.

To report this post you need to login first.

9 Comments

You must be Logged on to comment or reply to a post.

    1. Petr Plenkov Post author

      Does it provide checkbox and radiobuttons?

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

      (0) 
  1. 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

    (0) 
      1. 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

        (0) 

Leave a Reply