Application Development 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: 

ALV OO basics how to add button, checkbox, react events ....?

Former Member
0 Kudos

Hi guys!

I'm new to ALV OO and so i need so help to get in touch with it

Does anybody have some good sample application how to customice the ALV oo, (adding button, adding checkbox) and where/how you get the events and process the events. Step by step.

If you have some samples, or maybe you know where i can find some good tutorials on that...please let me know!!

greets thomas

1 ACCEPTED SOLUTION

Former Member
0 Kudos

thanks kothand.

I'm just trying out some ALV thins now.

But what would be the necessary steps to add a checkbox or button in the last column of my ZZ_ALV_TEST Report (posted before)

15 REPLIES 15

former_member673464
Active Contributor
0 Kudos

hi ,

Refer to the following link for information about ALV using oo concept

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a41...

regards,

Veeresh

Former Member
0 Kudos

to be more detailed...

I found tutorials how to basically handle a ALV OO. I "just" need some basic information on customice this,..like I said before, Add buttons, add checkbox, radiobutton handle events ....

thanks!

0 Kudos

Hi Thomas,

As said the handle_toolbar method is used for adding the necessary buttons in toolbar.

To be generic you can check the events and methods in class - cl_gui_alv_grid

If you can tell exactly where you need Buttons and radio buttons i can help you more

Cheers

Kothand

former_member216100
Participant
0 Kudos

For adding buttons use:

METHOD HANDLE_TOOLBAR.
* append a separator to normal toolbar
    CLEAR LS_TOOLBAR.
    MOVE 3 TO LS_TOOLBAR-BUTN_TYPE.
    APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
* append an icon to show booking table
    CLEAR LS_TOOLBAR.
    MOVE 'COPY_VKORG' TO LS_TOOLBAR-FUNCTION.
    MOVE ICON_COPY_OBJECT TO LS_TOOLBAR-ICON.
    MOVE 'Copy Verk.Org.'(111) TO LS_TOOLBAR-TEXT.
    MOVE 'Copy Verkaufs Organisation'(112) TO LS_TOOLBAR-QUICKINFO.
    MOVE ' ' TO LS_TOOLBAR-DISABLED.
    APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
  ENDMETHOD.                    "handle_toolbar

for examples you can search for apbabs starting with BCALV_EDIT* or BCALV_GRID*

have fun..

Former Member
0 Kudos

So if i get it right.

To use a ALV OO you have to use a Dynpro with PBO PAI? is this right?

Or is there a way to use ALV oo in a basic report.

eg.

REPORT  ZZ_ALV_TEST.

data:
      ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
start-of-selection.
select * into table ispfli from spfli.

cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).

gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).

gr_table->display( ).

this is just a basic alv oo code. can i add buttons, here? i have no dynpro.

Former Member
0 Kudos

thanks kothand.

I'm just trying out some ALV thins now.

But what would be the necessary steps to add a checkbox or button in the last column of my ZZ_ALV_TEST Report (posted before)

0 Kudos

Please check the Sample demo program to Handle the events

SALV_DEMO_TABLE_EVENTS

For check box

you have to use the class

CL_SALV_COLUMNS_LIST

for sample code check this program

RSMON000_ALV

0 Kudos

I modified your code

please check the modified code.

REPORT  ZZ_ALV_TEST.

data:
      ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
DATA: GR_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE,
      GR_COLUMN  TYPE REF TO CL_SALV_COLUMN_TABLE.


start-of-selection.
select * into table ispfli from spfli.

cl_salv_table=>factory( importing r_salv_table = gr_table changing
t_table = ispfli ).

gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).

GR_COLUMNS = GR_TABLE->GET_COLUMNS( ).

  TRY.
      GR_COLUMN ?= GR_COLUMNS->GET_COLUMN( 'CARRID' ). "Column which you
* want to make checkbox
      GR_COLUMN->SET_CELL_TYPE( 1 ).
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.

gr_table->display( ).

0 Kudos

thanks a lot!!

one last thing, how can i make the checkbox editable?

0 Kudos

I am in process of making it editable.

Once it is done i will post it.

0 Kudos
TRY.
      GR_COLUMN ?= GR_COLUMNS->GET_COLUMN( 'CARRID' ). "Column which you
* want to make checkbox
      GR_COLUMN->SET_CELL_TYPE( 6 ).  "This will be in editable mode. But not able to input , i will try to find out any other option for editable
    CATCH CX_SALV_NOT_FOUND.
  ENDTRY.

0 Kudos

Hi Vijay,

How to able able to input for check box ?. i have also same requirement. did you get that one? please post that code.

Thanks,

Mahesh

Former Member
0 Kudos

Hi ,

Yes you need a Custom container to be declared for having OO ALV.

So Dynpro is necessray for OO ALV Grid display

Former Member
0 Kudos

Hi,

I hope the below link can help you.

For checkbox.

You can also use the below code for buttons.

*----

-


form change_toolbar.

  • §1.Get toolbar instance of your ALV Tree.

  • When you instantiate an instance of CL_GUI_ALV_TREE the constructor

  • of the base class (CL_ALV_TREE_BASE) creates a toolbar.

  • Fetch its reference with the following method if you want to

  • modify it:

call method g_alv_tree->get_toolbar_object

importing

er_toolbar = g_toolbar.

check not g_toolbar is initial. "could happen if you do not use the

"standard toolbar

  • §2.Modify toolbar with methods of CL_GUI_TOOLBAR:

  • add seperator to toolbar

call method g_toolbar->add_button

exporting

fcode = ''

icon = ''

butn_type = cntb_btype_sep.

  • add Standard Button to toolbar (for Delete Subtree)

call method g_toolbar->add_button

exporting

fcode = 'DELETE'

icon = '@11@'

butn_type = cntb_btype_button

text = ''

quickinfo = text-901. "Delete subtree

endform.

Thanks,

Khushbu.

Former Member
0 Kudos

Go Se38 and Give BCALV* u will get all example programs related to ALV using classes