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: 

Reuse_alv_grid_display

Former Member
0 Kudos

Hi All,

Iam writing a report program using oops and I am displaying the data using reuse_alv_grid_display.But the client wants a UPLOAD button on application toolbar. Please provide a sample code that how to put a button on application toolbar.

Note:I am not using any performs and forms in my program.The entire report is done using oops so, it contains only methods.

Thanks in advance.

Regards,

Chakradhar.

1 ACCEPTED SOLUTION

VijayaKrishnaG
Active Contributor
0 Kudos

Hi Charki,

As you mentioned that you are using OOPs to build ALV, you have to call method SET_TABLE_FOR_FIRST_DISPLAY.

And to add a button on Tool bar we have an Event called TOOLBAR in the same class. Please refere the following sample code to add a button on standard toolbar.

-----------------------------------------------------------------------------------------------------------------

CLASS LCL_EVENT HANDLER DEFINITION.

  PUBLIC SECTION.

    METHODS:  Handle_Toolbar  FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID

                                               IMPORTING e_object

                                                                  e_interactive,

ENDCLASS. 

CLASS LCL_EVENT HANDLER IMPLEMENTATION.

  METHOD HANDLE_TOOLBAR.

    DATA LS_TOOLBAR TYPE STB_BUTTON.          " Push button properties

* Push Button

      CLEAR LS_TOOLBAR.

      MOVE G_FC                                          TO LS_TOOLBAR-FUNCTION.                 " Function code of button

      MOVE '<text that appear on button>'(100) TO LS_TOOLBAR-TEXT.

      MOVE '<wrte text here>'(100)                   TO LS_TOOLBAR-QUICKINFO.

      MOVE SPACE                                        TO lv_toolbar-disabled.

    

     APPEND LS_TOOLBAR TO e_object->mt_toolbar.

ENDMETHOD.

ENDCLASS.

" At where ALV is displaying

DATA : GR_EHANDLER TYPE REF TO LCL_EVENT HANDLER,

            GR_TABLE         TYPE REF TO CL_GUI_ALV_GRID,

CREATE OBJECT GR_EHANDLER.

* Event Handler, before displaying ALV

    SET HANDLER GR_EHANDLER->HANDLE_TOOLBAR FOR GR_TABLE.

" Call method SET_TABLE_FOR_FIRST_DIPLAY

-----------------------------------------------------------------------------------------------------------------

Regards,

Vijay

4 REPLIES 4

rajkumarnarasimman
Active Contributor
0 Kudos

Hi Chakri,

If you are displaying the report using OOABAP, then you can display the same using SET_TABLE_FOR_FIRST_DISPLAY method. I hope that in that case, we can use method... endmethod.

For this case, we are using REUSE_ALV_GRID_DISPLAY, then we have to use the FORM....ENDFORM for USER_COMMAND(handling the actions) and PF-STATUS. Correct me if I am wrong.

Go to SE80 and open the program SLVC_FULLSCREEN here you will find the GUI Status node. drill the node and rightclick -> copy the GUI Status STANDARD_FULLSCREEN. give the target program name (your alv grid program) and zguistatus name.

Add the 'UPLOAD' button in the Zguistatus.

For handling the button event the code snippet is below,


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

   I_CALLBACK_PROGRAM                  = SY-REPID

   I_CALLBACK_PF_STATUS_SET       = 'SET_PF_STATUS'

   I_CALLBACK_USER_COMMAND      = 'USER_COMMAND'

   IT_FIELDCAT                                       = d_fieldcat

   I_GRID_TITLE                                      = 'Communications Infotype'

   IT_EVENTS                                          = it_event

  TABLES

    t_outtab                                                = it_final.

FORM user_command USING l_comm TYPE syucomm

rs_selfield TYPE slis_selfield.

CASE l_comm.

     WHEN '&UPLOAD'.

          "Write the Upload statement here

ENDCASE.

ENDFORM.

FORM set_pf_status USING rt_extab TYPE slis_t_extab .

  SET PF-STATUS 'ZSTANDARD_FULLSCREEN'.

ENDFORM.

Regards

Rajkumar Narasimman

0 Kudos

Hi Rajkumar,

Thanks for ur reply.What you said is correct but I want it using oops and also for the function module resue_alv_grid_display  is their any chance of doing in this combination.

Thanks in advance.

Regards,

Chakradhar.

0 Kudos

Hi Chakri,

Even I tried the same long back before you did. I didn't make it. So I purely converted the program to OOABAP.

I understood that using REUSE_ALV_GRID_DISPLAY, we can't call the Method...Endmethod.

If you are trying in OOABAP, please use OOABAP concepts to show the ALV Grid. We know using REUSE_ALV_GRID_DISPLAY is little bit easy to show the ALV Output. But when we come to OOABAP, it is better to adopt object oriented functionality.

Regards

Rajkumar Narasimman

VijayaKrishnaG
Active Contributor
0 Kudos

Hi Charki,

As you mentioned that you are using OOPs to build ALV, you have to call method SET_TABLE_FOR_FIRST_DISPLAY.

And to add a button on Tool bar we have an Event called TOOLBAR in the same class. Please refere the following sample code to add a button on standard toolbar.

-----------------------------------------------------------------------------------------------------------------

CLASS LCL_EVENT HANDLER DEFINITION.

  PUBLIC SECTION.

    METHODS:  Handle_Toolbar  FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID

                                               IMPORTING e_object

                                                                  e_interactive,

ENDCLASS. 

CLASS LCL_EVENT HANDLER IMPLEMENTATION.

  METHOD HANDLE_TOOLBAR.

    DATA LS_TOOLBAR TYPE STB_BUTTON.          " Push button properties

* Push Button

      CLEAR LS_TOOLBAR.

      MOVE G_FC                                          TO LS_TOOLBAR-FUNCTION.                 " Function code of button

      MOVE '<text that appear on button>'(100) TO LS_TOOLBAR-TEXT.

      MOVE '<wrte text here>'(100)                   TO LS_TOOLBAR-QUICKINFO.

      MOVE SPACE                                        TO lv_toolbar-disabled.

    

     APPEND LS_TOOLBAR TO e_object->mt_toolbar.

ENDMETHOD.

ENDCLASS.

" At where ALV is displaying

DATA : GR_EHANDLER TYPE REF TO LCL_EVENT HANDLER,

            GR_TABLE         TYPE REF TO CL_GUI_ALV_GRID,

CREATE OBJECT GR_EHANDLER.

* Event Handler, before displaying ALV

    SET HANDLER GR_EHANDLER->HANDLE_TOOLBAR FOR GR_TABLE.

" Call method SET_TABLE_FOR_FIRST_DIPLAY

-----------------------------------------------------------------------------------------------------------------

Regards,

Vijay