constants: c_ccname_grid_popup type scrfname value 'CC_GRID_POPUP'.
data: go_popup_custom_cont type ref to cl_gui_custom_container.
data: go_popup_grid type ref to cl_gui_alv_grid.
data: gs_popup_layout type lvc_s_layo.
data: gs_popup_variant type disvariant.
data: gt_popup_fcat type lvc_t_fcat.
data: g_popup_question type char70.
field-symbols: <gt_popup_outtab> type standard table.
module pbo_0501 output.
set pf-status 'STATUS_0501'.
set titlebar 'TITLE_0501'.
create object go_popup_custom_cont
exporting
* parent = i_parent_container
container_name = c_ccname_grid_popup
* style = style
* lifetime = lifetime_default
* repid = repid
* dynnr = dynnr
* no_autodef_progid_dynnr = no_autodef_progid_dynnr
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
if sy-subrc eq 0.
endif.
gs_popup_variant-report = sy-repid.
gs_popup_layout-zebra = abap_true.
gs_popup_layout-no_toolbar = abap_true.
gs_popup_layout-cwidth_opt = abap_true.
gs_popup_layout-sel_mode = 'C'.
create object go_popup_grid
exporting
* i_shellstyle = 0
* i_lifetime = i_lifetime
i_parent = go_popup_custom_cont
* i_appl_events = space
* i_parentdbg = i_parentdbg
* i_applogparent = i_applog_container
* i_graphicsparent = i_graphicsparent
* i_name = i_name
* i_fcat_complete = SPACE
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5
.
if sy-subrc eq 0.
go_popup_grid->set_table_for_first_display(
exporting
* i_buffer_active = i_buffer_active
* i_bypassing_buffer = i_bypassing_buffer
* i_consistency_check = i_consistency_check
* i_structure_name = i_structure_name
is_variant = gs_popup_variant
i_save = space
* i_default = 'X'
is_layout = gs_popup_layout
* is_print = is_print
* it_special_groups = it_special_groups
* it_toolbar_excluding = gt_toolbar_excluding
* it_hyperlink = it_hyperlink
* it_alv_graphics = it_alv_graphics
* it_except_qinfo = it_except_qinfo
* ir_salv_adapter = ir_salv_adapter
changing
it_outtab = <gt_popup_outtab>
it_fieldcatalog = gt_popup_fcat
* it_sort = gt_sort
* it_filter = gt_filter
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
).
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
call method go_popup_grid->set_ready_for_input
exporting
i_ready_for_input = 1.
endif.
endif.
endmodule. "pbo_0501 OUTPUT
*----------------------------------------------------------------------*
* MODULE pai_0501 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
module pai_0501 input.
case g_okcode.
when 'ENTER'.
leave screen.
when 'CANCEL'.
leave screen.
endcase.
endmodule. "pai_0501 INPUT
*----------------------------------------------------------------------*
function z_ab_popup_grid_multi_sel.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IT_FCAT) TYPE LVC_T_FCAT
*" VALUE(I_QUESTION) TYPE CHAR70 OPTIONAL
*" CHANGING
*" REFERENCE(CT_OUTTAB) TYPE STANDARD TABLE
*"----------------------------------------------------------------------
field-symbols: <structure> type any.
data: ft_row_no type lvc_t_roid .
data: ft_table_ref type ref to data.
field-symbols: <temptable> type standard table.
check ct_outtab[] is not initial.
"to be able to use it in PBO/PAI
assign ct_outtab to <gt_popup_outtab>.
gt_popup_fcat[] = it_fcat[].
g_popup_question = i_question.
call screen 0501 starting at 1 1.
case g_okcode.
when 'ENTER'.
go_popup_grid->get_selected_rows(
importing
"et_index_rows = et_index_rows
et_row_no = ft_row_no
).
if ft_row_no[] is initial.
refresh ct_outtab[].
else.
sort ft_row_no by row_id ascending.
create data ft_table_ref like ct_outtab.
assign ft_table_ref->* to <temptable>.
<temptable>[] = ct_outtab[].
loop at <temptable> assigning <structure>.
read table ft_row_no with key row_id = sy-tabix binary search transporting no fields.
if sy-subrc ne 0.
delete ct_outtab index sy-tabix.
endif.
endloop.
endif.
when 'CANCEL'.
refresh ct_outtab[].
endcase.
clear g_okcode.
endfunction.
I've updated demo program which can be found in attached NUGG file and now also popup usage can be found there. In user_command_0100 module you can find the call of popup FM.
In the new demo program click on POPUP DEMO button on the screen.
A popup will be called with the same entries as in the main window (that was done on purpose).
After you select lines and confirm selection popup screen will be closed and grid on the main screen will contain only selected values.
Enjoy!