Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV

Former Member
0 Likes
784

Hi,

I am new to SAP.I am working with ALV grid.I have modified an sample program.In this sample program i just wanna remove the setfilter,search and total icons from application toolbar.

How can i do this this??Experts kindly help me in this.

Here is the sample program..

program bcalvc_print.

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.

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.

*

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
657

Hi Sateesh,


  data: lt_exclude type ui_functions.
  data ls_exclude type ui_func.

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
  append ls_exclude to lt_exclude.
<b>  ls_exclude = cl_gui_alv_grid=>MC_FC_SUBTOT.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>MC_FC_SUM.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>MC_FC_FILTER .
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>MC_FC_FIND  .
  append ls_exclude to lt_exclude.
 </b> 

  call method g_grid->set_table_for_first_display
       exporting <b>it_toolbar_excluding  = lt_exclude</b>
       changing  it_fieldcatalog       = pt_fieldcat
                 it_outtab             = pt_outtab.

Thats all..

Regards

vijay

Hi,

I am new to SAP.I am working with ALV grid.I have modified an sample program.In this sample program i just wanna remove the setfilter,search and total icons from application toolbar.

How can i do this this??Experts kindly help me in this.

Here is the sample program..

program bcalvc_print.

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.

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.

*

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

2 REPLIES 2
Read only

Laxmana_Appana_
Active Contributor
0 Likes
657

Hi,

Pass exclude button values to parameter it_toolbar_excluding of the <b>set_table_for_first_display</b> method.

check sample code :

  PERFORM disable_functions TABLES i_excl_func.

*-- Display Report
    CALL METHOD o_grid->set_table_for_first_display
      EXPORTING
        is_layout                     = p_layout
       <b> it_toolbar_excluding          = i_excl_func</b>
      CHANGING
        it_outtab                     = p_output[]
        it_fieldcatalog               = p_fieldcat[]
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.

    IF sy-subrc <> 0.
    ENDIF.

FORM disable_functions  TABLES p_i_excl_func. ".
  DATA : wa_excl_func TYPE ui_func.

* Append/Create Row
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_append_row.
  APPEND wa_excl_func TO p_i_excl_func.
* Delete Row
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_delete_row.
  APPEND wa_excl_func TO p_i_excl_func.
* Local Insert
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  APPEND wa_excl_func TO i_excl_func.
* Copy/Duplicate
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_copy_row.
  APPEND wa_excl_func TO i_excl_func.
* Detail
  wa_excl_func = cl_gui_alv_grid=>mc_fc_detail.
  APPEND wa_excl_func TO i_excl_func.
* Views
  wa_excl_func = cl_gui_alv_grid=>mc_fc_views.
  APPEND wa_excl_func TO i_excl_func.
*-- Layout??
  wa_excl_func = cl_gui_alv_grid=>mc_fc_current_variant.
  APPEND wa_excl_func TO i_excl_func.

  wa_excl_func = cl_gui_alv_grid=>mc_fc_view_grid.
  APPEND wa_excl_func TO i_excl_func.

* Graph
  wa_excl_func = cl_gui_alv_grid=>mc_fc_graph.
  APPEND wa_excl_func TO i_excl_func.
* Info
  wa_excl_func = cl_gui_alv_grid=>mc_fc_info.
  APPEND wa_excl_func TO i_excl_func.
* Total
  wa_excl_func = cl_gui_alv_grid=>mc_fc_sum.
  APPEND wa_excl_func TO i_excl_func.
* Maximum
  wa_excl_func = cl_gui_alv_grid=>mc_fc_maximum.
  APPEND wa_excl_func TO i_excl_func.
* Minimum
  wa_excl_func = cl_gui_alv_grid=>mc_fc_minimum.
  APPEND wa_excl_func TO i_excl_func.
* Mean/Average
  wa_excl_func = cl_gui_alv_grid=>mc_fc_average.
  APPEND wa_excl_func TO i_excl_func.
* Subtotal
  wa_excl_func = cl_gui_alv_grid=>mc_fc_subtot.
  APPEND wa_excl_func TO i_excl_func.
* Check
  wa_excl_func = cl_gui_alv_grid=>mc_fc_check.
  APPEND wa_excl_func TO i_excl_func.
* Refresh
  wa_excl_func = cl_gui_alv_grid=>mc_fc_refresh.
  APPEND wa_excl_func TO i_excl_func.
* Cut
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_cut.
  APPEND wa_excl_func TO i_excl_func.
* Copy
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_copy.
  APPEND wa_excl_func TO i_excl_func.
* Paste
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
  APPEND wa_excl_func TO i_excl_func.
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_paste.
  APPEND wa_excl_func TO i_excl_func.
* Undo
  wa_excl_func = cl_gui_alv_grid=>mc_fc_loc_undo.
  APPEND wa_excl_func TO i_excl_func.
 

ENDFORM.                    " disable_functions

Regards

Appana

Read only

Former Member
0 Likes
658

Hi Sateesh,


  data: lt_exclude type ui_functions.
  data ls_exclude type ui_func.

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
  append ls_exclude to lt_exclude.
<b>  ls_exclude = cl_gui_alv_grid=>MC_FC_SUBTOT.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>MC_FC_SUM.
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>MC_FC_FILTER .
  append ls_exclude to lt_exclude.
  ls_exclude = cl_gui_alv_grid=>MC_FC_FIND  .
  append ls_exclude to lt_exclude.
 </b> 

  call method g_grid->set_table_for_first_display
       exporting <b>it_toolbar_excluding  = lt_exclude</b>
       changing  it_fieldcatalog       = pt_fieldcat
                 it_outtab             = pt_outtab.

Thats all..

Regards

vijay