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:
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.
Nice Article , Thanks for sharing.
Nice one. I didn't know this class.
But I think the FUNCTION POPUP_GET_VALUES is easier to use đ
Does it provide checkbox and radiobuttons?
Previously I used FREE_SELECTIONS_DIALOG in dynamic programs, but it doesn't support them.
I've never used it for checkbox/radio. But I think it doesn't support...
Very useful..Nice one
Thanks for sharing !! Useful one..
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
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
ok ... 7.40 required đ„ ... I found the answer
http://scn.sap.com/community/abap/blog/2013/05/27/abap-news-for-release-740--constructor-operators-conv-and-cast
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
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!
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:
Regards,
Alfonso.
Nice stuff. Today I saved lot of time.
Thank!
Hola,
I was preparing a post for this functionality and you already done!
Nice one!
Gracias,
Alfonso.
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.
Do post if it offers different example than the one above, no harm.
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
You can copy the class into Z class then
in GENERATE_PROGRAM method replace
with
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
Do you know if we can have a custom list box and not from the domain, any way to achieve that.