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

adding a button to standard bar

Former Member
0 Likes
1,095

hi all,

iwant to add buttons to the tool bar can anybody plz help me out.

THANKS

ANUPAMA

Edited by: deep kammula on Apr 14, 2008 3:43 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
992

HI

goto se41.....in that give u r program name and decalre a status and u can add buttons there......

6 REPLIES 6
Read only

Former Member
0 Likes
993

HI

goto se41.....in that give u r program name and decalre a status and u can add buttons there......

Read only

0 Likes
992

hi,

it is like i want to add sort filter sum button in my report after the output displayed.

can anybody plz help me its a bit urgent.

thanks

Anupama

Read only

0 Likes
992

In that case you better make use of the ALV grids, see the example below...

Example report(type - ALV(ABAP list viewer))

REPORT Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB .

************************************************************************

*Simple example to use ALV and to define the ALV data in an internal

*table

************************************************************************

*data definition

tables:

marav. "Table MARA and table MAKT

----


  • Data to be displayed in ALV

  • Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-

  • matically determine the fieldstructure from this source program

Data:

begin of imat occurs 100,

matnr like marav-matnr, "Material number

maktx like marav-maktx, "Material short text

matkl like marav-matkl, "Material group (so you can test to make

" intermediate sums)

ntgew like marav-ntgew, "Net weight, numeric field (so you can test to

"make sums)

gewei like marav-gewei, "weight unit (just to be complete)

end of imat.

----


  • Other data needed

  • field to store report name

data i_repid like sy-repid.

  • field to check table length

data i_lines like sy-tabix.

----


  • Data for ALV display

TYPE-POOLS: SLIS.

data int_fcat type SLIS_T_FIELDCAT_ALV.

----


select-options:

s_matnr for marav-matnr matchcode object MAT1.

----


start-of-selection.

  • read data into table imat

select * from marav

into corresponding fields of table imat

where

matnr in s_matnr.

  • Check if material was found

clear i_lines.

describe table imat lines i_lines.

if i_lines lt 1.

  • Using hardcoded write here for easy upload

write: /

'No materials found.'.

exit.

endif.

end-of-selection.

  • To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.

  • The fieldcatalouge can be generated by FUNCTION

  • 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any

  • report source, including this report.

----


  • Store report name

i_repid = sy-repid.

  • Create Fieldcatalogue from internal table

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = i_repid

I_INTERNAL_TABNAME = 'IMAT' "capital letters!

I_INCLNAME = i_repid

CHANGING

CT_FIELDCAT = int_fcat

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

*explanations:

  • I_PROGRAM_NAME is the program which calls this function

*

  • I_INTERNAL_TABNAME is the name of the internal table which you want

  • to display in ALV

*

  • I_INCLNAME is the ABAP-source where the internal table is defined

  • (DATA....)

  • CT_FIELDCAT contains the Fieldcatalouge that we need later for

  • ALV display

IF SY-SUBRC <> 0.

write: /

'Returncode',

sy-subrc,

'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.

ENDIF.

*This was the fieldcatlogue

----


*

  • Call for ALV list display

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = i_repid

IT_FIELDCAT = int_fcat

TABLES

T_OUTTAB = imat

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

*explanations:

  • I_CALLBACK_PROGRAM is the program which calls this function

*

  • IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains

  • now the data definition needed for display

*

  • I_SAVE allows the user to save his own layouts

*

  • T_OUTTAB contains the data to be displayed in ALV

IF SY-SUBRC <> 0.

write: /

'Returncode',

sy-subrc,

'from FUNCTION REUSE_ALV_LIST_DISPLAY'.

ENDIF.

Read only

uwe_schieferstein
Active Contributor
0 Likes
992

Hello

Sample report BCALV_GRID_05 provides you with the required information if you are using OO-based ALV lists.


PROGRAM BCALV_GRID_05.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Purpose:
* ~~~~~~~~
* Demonstrate the creation of an own toolbar button.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* The report shows a list of flights of one airline.
* Select one or more lines and press the 'Detail'-Button to popup
* a dialog window with related bookings.
*-------------------------------------------------------------------
* Essential steps (Search for '§')
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 1.Apply steps for event handling for events TOOLBAR and
*   USER_COMMAND (see example for print events)
* 2.In event handler method for event TOOLBAR: Append own functions
*   by using event parameter E_OBJECT.
* 3.In event handler method for event USER_COMMAND: Query your
*   function codes defined in step 2 and react accordingly.
* 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
...

Regards

Uwe

Read only

Former Member
0 Likes
992

Hi on your initialization put the following code (sscrfields-functxt_01 = '@0P@Search'.)

then on your at selection-screen

CASE sscrfields-ucomm.

WHEN'FC01'.

perform what ever that you want to achieve from the button click

endcase.

try it...

Read only

former_member5472
Active Contributor
0 Likes
992

Hi,

you have to define a local class definaition/implementation for toolbar buttons

data g_grid1 TYPE REF TO cl_gui_alv_grid.

CLASS cl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS handle_toolbar_set

FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING e_object e_interactive.

*Implementation

METHOD handle_toolbar_set.

DELETE e_object->mt_toolbar

WHERE function = '&MB_SUM'

OR function = '&MB_SUBTOT'

OR function = '&GRAPH'

end method

if this is not clear than i will send you detail code

*use event handlers

  • EVENT HANDLERS for ALV grid

SET HANDLER event_receiver1->handle_toolbar_set FOR g_grid1.