2014 Nov 11 2:57 PM
Hi,
I'm having a standard ALV report which I'm using the class cl_salv_table to display.
I need to add a button next to the standard alv functionality buttons (next to the layout buttons),
and have it function so that once the user marks a certain row in the alv report and hits that button
a pop up window will appear displaying another table (Which will display records according to a select statement
I'll write in that event).
I'm sorry for the noobness, I know I'm sounding like a noob and may state the obvious, but, I am a total abap noob (-:
Please help!
Thanks in Advance,
Daniel.
Hi,
I'm having a standard ALV report which I'm using the class cl_salv_table to display.
I need to add a button next to the standard alv functionality buttons (next to the layout buttons),
and have it function so that once the user marks a certain row in the alv report and hits that button
a pop up window will appear displaying another table (Which will display records according to a select statement
I'll write in that event).
I'm sorry for the noobness, I know I'm sounding like a noob and may state the obvious, but, I am a total abap noob (-:
Please help!
Thanks in Advance,
Daniel.
2014 Nov 11 6:54 PM
Hello Daniel,
I guess you have forgotten to add set screen status.
call method gr_alv->set_screen_status
exporting
report = l_report
pfstatus = 'STANDARD'
set_functions = gr_alv->c_functions_all.
Cheers !!
Megh
2014 Nov 12 4:21 PM
You can use cl_gui_alv_grid. Here is the sample code for this.
*&---------------------------------------------------------------------*
*& Report ZALV_OOPS6
*&
*&---------------------------------------------------------------------*
*& ALV OOPS : Add Pushbutton To Toolbar
*&
*&---------------------------------------------------------------------*
report zalv_oops6 no standard page heading.
tables : ekko, ekpo.
include <icon>.
class lcl_event_reciever definition deferred.
data : i_ekko type table of ekko,
k_ekko type ekko,
i_ekpo type table of ekpo,
k_ekpo type ekpo,
k_layo1 type lvc_s_layo,
k_layo2 type lvc_s_layo.
data : o_cont1 type ref to cl_gui_custom_container,
o_cont2 type ref to cl_gui_custom_container,
o_alv1 type ref to cl_gui_alv_grid,
o_alv2 type ref to cl_gui_alv_grid,
o_ehandler type ref to lcl_event_reciever.
data : ok_code1 like sy-ucomm,
ok_code2 like sy-ucomm.
class lcl_event_reciever definition.
public section.
methods : handle_toolbar
for event toolbar
of cl_gui_alv_grid
importing e_object e_interactive,
handle_user_command
for event user_command
of cl_gui_alv_grid
importing e_ucomm.
endclass.
class lcl_event_reciever implementation.
method handle_toolbar.
data : k_toolbar type stb_button.
clear k_toolbar.
k_toolbar-butn_type = 3.
append k_toolbar to e_object->mt_toolbar.
clear k_toolbar.
k_toolbar-function = 'DETAIL'.
k_toolbar-icon = icon_doc_item_detail.
k_toolbar-quickinfo = 'PO Details'.
k_toolbar-text = 'PO Details'.
k_toolbar-disabled = space.
append k_toolbar to e_object->mt_toolbar.
clear k_toolbar.
endmethod.
method handle_user_command.
data : i_rows type lvc_t_row,
k_rows type lvc_s_row.
case e_ucomm.
when 'DETAIL'.
clear : i_rows[], k_rows.
call method o_alv1->get_selected_rows
importing
et_index_rows = i_rows.
if not i_rows[] is initial.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
call function 'POPUP_TO_INFORM'
exporting
titel = sy-repid
txt1 = 'Error in flush'
txt2 = sy-subrc.
else.
perform show_details tables i_rows.
perform get_alv_0101.
endif.
else.
call function 'POPUP_TO_INFORM'
exporting
titel = sy-repid
txt1 = 'No rows selected'
txt2 = sy-subrc.
endif.
endcase.
endmethod.
endclass.
selection-screen begin of block b1 with frame title text-001.
select-options s_aedat for ekko-aedat obligatory.
selection-screen end of block b1.
start-of-selection.
perform get_data_ekko.
perform get_alv_0100.
*&---------------------------------------------------------------------*
*& Form SHOW_DETAILS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_ROWS text
*----------------------------------------------------------------------*
form show_details tables i_select_rows structure lvc_s_row.
data : k_select_rows type lvc_s_row,
lv_index type lvc_index.
clear : i_ekpo[], k_ekpo, k_ekko.
loop at i_select_rows into k_select_rows.
clear lv_index.
lv_index = k_select_rows-index.
if not i_ekko[] is initial.
read table i_ekko into k_ekko index lv_index.
if sy-subrc eq 0.
select * from ekpo appending table i_ekpo
where ebeln = k_ekko-ebeln.
endif.
endif.
clear k_select_rows.
endloop.
endform. " SHOW_DETAILS
*&---------------------------------------------------------------------*
*& Form GET_DATA_EKKO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_data_ekko .
clear : i_ekko[], k_ekko.
select * from ekko into table i_ekko
where aedat in s_aedat.
endform. " GET_DATA_EKKO
*&---------------------------------------------------------------------*
*& Form GET_ALV_0100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_alv_0100 .
call screen 100.
endform. " GET_ALV_0100
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
set pf-status 'PF100'.
* SET TITLEBAR 'xxx'.
endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module ALV_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module alv_0100 output.
if o_cont1 is initial.
create object o_cont1
exporting
container_name = 'CONTAINER1'
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
if sy-subrc ne 0.
call function 'POPUP_TO_INFORM'
exporting
titel = sy-repid
txt1 = 'Error in generating screen'
txt2 = sy-subrc.
endif.
create object o_alv1
exporting
i_parent = o_cont1.
clear k_layo1.
k_layo1-grid_title = 'Purchase Order Header'.
k_layo1-zebra = 'X'.
k_layo1-cwidth_opt = 'X'.
k_layo1-sel_mode = 'A'.
call method o_alv1->set_table_for_first_display
exporting
i_structure_name = 'EKKO'
is_layout = k_layo1
changing
it_outtab = i_ekko.
create object o_ehandler.
set handler o_ehandler->handle_toolbar for o_alv1.
set handler o_ehandler->handle_user_command for o_alv1.
call method o_alv1->set_toolbar_interactive.
endif.
call method cl_gui_control=>set_focus exporting control = o_alv1.
endmodule. " ALV_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.
case ok_code1.
when 'BACK'.
perform free_0100.
leave to screen 0.
when 'EXIT'.
perform free_0100.
call method cl_gui_cfw=>flush.
if sy-subrc eq 0.
call function 'POPUP_TO_INFORM'
exporting
titel = sy-repid
txt2 = sy-subrc
txt1 = 'Error in Flush'.
endif.
leave program.
when 'CANCEL'.
perform free_0100.
leave to screen 0.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form FREE_0100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form free_0100 .
call method o_alv1->free.
call method o_cont1->free.
if not o_cont2 is initial.
call method o_alv2->free.
call method o_cont2->free.
endif.
endform. " FREE_0100
*&---------------------------------------------------------------------*
*& Form GET_ALV_0101
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_alv_0101 .
call screen 101 starting at 10 5.
endform. " GET_ALV_0101
*&---------------------------------------------------------------------*
*& Module ALV_0101 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module alv_0101 output.
if o_cont2 is initial.
create object o_cont2
exporting
container_name = 'CONTAINER2'
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
if sy-subrc ne 0.
call function 'POPUP_TO_INFORM'
exporting
titel = sy-repid
txt1 = 'Error in generating screen'
txt2 = sy-subrc.
endif.
create object o_alv2
exporting
i_parent = o_cont2.
clear k_layo2.
k_layo2-grid_title = 'Purchase Order Items'.
k_layo2-zebra = 'X'.
k_layo2-cwidth_opt = 'X'.
call method o_alv2->set_table_for_first_display
exporting
i_structure_name = 'EKPO'
is_layout = k_layo2
changing
it_outtab = i_ekpo.
else.
call method o_alv2->refresh_table_display.
endif.
call method cl_gui_control=>set_focus
exporting
control = o_alv2.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
call function 'POPUP_TO_INFORM'
exporting
titel = sy-repid
txt1 = 'Error in flush'
txt2 = sy-subrc.
endif.
endmodule. " ALV_0101 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0101 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0101 input.
case ok_code2.
when 'CANCEL'.
leave to screen 0.
endcase.
endmodule. " USER_COMMAND_0101 INPUT
Hope this will solve your problem.
Regards,
Megh
2014 Nov 12 1:18 PM
I guess you probably have forgotten to read past the headline (-:
I need to create a new button in my alv report, so that once the user marks a certain ROW,
and pushes the button, a pop window will appear, with a table that will contain data that has a certain connection to the row chosen (for example, additional info on a specific vendor).
Can anyone help me, please? (-:
2014 Nov 12 8:08 PM
Hi Daniel,
you are right: People answering here have little or no experience with SALV object model.
Well, I can't give you complete code, just some hints:
It depends if you use the 'full screen' display or display within container. For fill screen, yo have methods to set your (modified) screen status, for container you must register the toolbar event to add a button dynamically.
You have to register events for toolbar click. Then get the current row to build you popup table, then create a new SALV factory object and use display method with popup parameters (from/to/x/y) filled.
That's it.
Regards
Clemens
2014 Nov 12 4:56 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |