‎2006 Aug 22 2:52 PM
Hi,
I got the ALV grid.Just above the grid i wanna add Microsoftexcel,wordprocessing,localfile tool bars just above the grid and not in the application toolbar.Can anyone guide me on this.Thanx in advance.
‎2006 Aug 22 3:07 PM
‎2006 Aug 22 3:07 PM
‎2006 Aug 22 3:27 PM
Hi Mann,
Thanx for the reply.Here the doubt exactly is in the output screen that is next to the application toolbar
i just wanna add the printer,sorting icons..etc
kindly gimme an idea regarding this..
‎2006 Aug 22 3:25 PM
‎2006 Aug 22 3:29 PM
Hi,
See the sample Program <b>BCALV_GRID_08</b>
See the below link for more info
http://www.sap-basis-abap.com/abap/add-button-to-alv-toolbar-with-reuse-alv-list-display.htm
Thanks
Sudheer
‎2006 Aug 22 3:55 PM
HI,
I have used the sample program for my understanding.In the below program there is a code
mycontainer type scrfname value 'BCALVC_EVENT1_CONT1'
in the above code what is 'BCALVC_EVENT1_CONT1'.Is this a program???can anyone help me in this.
Thanx in advance..
program bcalvc_print.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Purpose:
~~~~~~~~
This program illustrates how the events for print processing
- PRINT_TOP_OF_PAGE
- PRINT_END_OF_PAGE
- PRINT_TOP_OF_LIST
- PRINT_END_OF_LIST
*
are handled. The corresponding handler methods control the
appearance of the list printed.
*----
-
To check program behavior
~~~~~~~~~~~~~~~~~~~~~~~~~
Print the list shown (It has got only three pages).
Remark: If you choose "Druckansicht" (preview?!) before printing,
the output for event PRINT_END_OF_PAGE is left out due
to scrolling.
Create a spool entry and preview your printout by calling
TA sp01 to reduce paper output please.
*----
-
Essential steps (Search for '§')
~~~~~~~~~~~~~~~
1. Define a (local) class for event handling
2. Define a method for each print event you need.
3. Implement your event handler methods. Use WRITE to provide output.
4. Link used print events and event handler methods.
5. In case of PRINT_END_OF_PAGE, you must set 'reservelns' to
the number of reserved lines at the end of a page.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
*********
Predefine a local class for event handling to allow the
declaration of a reference variable.
class lcl_event_receiver definition deferred.
*
*********
data: ok_code like sy-ucomm,
g_max type i value 100,
gt_sflight type table of sflight,
g_repid like sy-repid,
gs_print type lvc_s_prnt,
gs_layout type lvc_s_layo,
mycontainer type scrfname value 'BCALVC_EVENT1_CONT1',
reference to custom container: neccessary to bind ALV Control
custom_container type ref to cl_gui_custom_container,
grid1 type ref to cl_gui_alv_grid,
event_receiver type ref to lcl_event_receiver.
§ Step 1. Define a (local) class for event handling
****************************************************************
LOCAL CLASSES: Definition
****************************************************************
*===============================================================
class c_event_receiver: local class to handle print events...
- PRINT_TOP_OF_PAGE (page header)
- PRINT_END_OF_PAGE (page footer)
- PRINT_TOP_OF_LIST (list header)
- PRINT_END_OF_LIST (list footer)
*
Definition:
~~~~~~~~~~~
class lcl_event_receiver definition.
public section.
§ 2. Define a method for each print event you need.
methods:
handle_top_of_page
for event print_top_of_page of cl_gui_alv_grid,
handle_end_of_page
for event print_end_of_page of cl_gui_alv_grid,
handle_top_of_list
for event print_top_of_list of cl_gui_alv_grid,
handle_end_of_list
for event print_end_of_list of cl_gui_alv_grid.
private section.
data: pagenum type i.
endclass.
*
c_event_receiver (Definition)
*===============================================================
****************************************************************
LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
class c_event_receiver (Implementation)
*
class lcl_event_receiver implementation.
*§ 3. Implement your event handler methods. Use WRITE to provide output.
method handle_top_of_page.
data: tablename(30) type c.
perform get_tablename changing tablename.
write: /,'Event: PRINT_TOP_OF_PAGE'(001),
'Table: '(002),tablename.
endmethod. "handle_top_of_page
*----
-
method handle_end_of_page.
data: tablename(30) type c.
perform get_tablename changing tablename.
add 1 to pagenum.
write: /,'Event: PRINT_END_OF_PAGE'(003),
text-002,tablename,
'Number of pages so far: '(004), pagenum.
endmethod. "handle_end_of_page
*----
-
method handle_top_of_list.
data: tablename(30) type c.
clear pagenum.
perform get_tablename changing tablename.
write: /,'Event: PRINT_TOP_OF_LIST'(005),
text-002,tablename.
endmethod. "handle_top_of_list
*----
-
method handle_end_of_list.
data: tablename(30) type c.
perform get_tablename changing tablename.
write: /,'Event: PRINT_END_OF_LIST'(006),
text-002,tablename.
endmethod. "handle_end_of_list
*----
-
endclass.
*
c_event_receiver (Implementation)
*===================================================================
start-of-selection.
select * from sflight into table gt_sflight up to g_max rows.
*
end-of-selection.
g_repid = sy-repid.
call screen 100.
*----
*
MODULE PBO OUTPUT *
*----
*
module pbo output.
set pf-status 'MAIN100'.
set titlebar 'MAIN100'.
if custom_container is initial.
create a custom container control for our ALV Control
create object custom_container
exporting
container_name = mycontainer
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(010).
endif.
create an instance of alv control
create object grid1
exporting i_parent = custom_container.
*
Set a titlebar for the grid control
*
gs_layout-grid_title = 'Flights'(100).
§ 5. In case of PRINT_END_OF_PAGE, you must set 'reservelns' to
the number of reserved lines at the end of a page.
*
reserve two lines for the PRINT_END_OF_PAGE event
*
gs_print-reservelns = 2.
********
->Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
*
********
§ 4. Link used print events and event handler methods.
create object event_receiver.
set handler event_receiver->handle_top_of_list for grid1.
set handler event_receiver->handle_top_of_page for grid1.
set handler event_receiver->handle_end_of_list for grid1.
set handler event_receiver->handle_end_of_page for grid1.
*
call method grid1->set_table_for_first_display
exporting i_structure_name = 'SFLIGHT'
is_print = gs_print
is_layout = gs_layout
changing it_outtab = gt_sflight.
endif.
Controls are not integrated into the TAB-Order
Call "set_focus" if you want to make sure that 'the cursor'
is active in your control.
call method cl_gui_control=>set_focus exporting control = grid1.
Control Framework flushes at the end of PBO automatically!
endmodule.
*----
*
MODULE PAI INPUT *
*----
*
module pai input.
case ok_code.
when 'EXIT'.
perform exit_program.
endcase.
clear ok_code.
endmodule.
*----
*
FORM EXIT_PROGRAM *
*----
*
form exit_program.
call method custom_container->free.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(009).
endif.
leave program.
endform.
*&----
*
*& Form GET_TABLENAME
*&----
*
text
*----
*
<--P_TABLENAME text
*----
*
form get_tablename changing p_tablename.
data: lt_fieldcat type standard table of lvc_s_fcat,
ls_fieldcat type lvc_s_fcat.
call method grid1->get_frontend_fieldcatalog
importing et_fieldcatalog = lt_fieldcat.
call method cl_gui_cfw=>flush.
if sy-subrc <> 0.
p_tablename = 'No tablename in fieldcatalog!'(008).
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = p_tablename
txt1 = 'Error in Flush'(011).
else.
read table lt_fieldcat index 1 into ls_fieldcat.
p_tablename = ls_fieldcat-ref_table.
endif.
endform. " GET_TABLENAME
‎2007 May 15 1:57 PM
Hi,
'BCALVC_EVENT1_CONT1' is the name of the custom control created for that particular alv.
Regards,
Kalpana
> HI,
>
> I have used the sample program for my
> understanding.In the below program there is a code
>
> mycontainer type scrfname value
> 'BCALVC_EVENT1_CONT1'
>
> in the above code what is 'BCALVC_EVENT1_CONT1'.Is
> this a program???can anyone help me in this.
> Thanx in advance..
>
>
‎2007 May 15 9:58 PM