Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Home arrow Sample Code arrow ABAP Reports arrow Add Button to ALV Toolbar with REUSE_ALV_LIST_DISPLAY
Add Button to ALV Toolbar with REUSE_ALV_LIST_DISPLAY PDF Print E-mail
User Rating: / 6
PoorBest 
Written by Anon.   
Tuesday, 08 May 2007
In the program which calls ALV using REUSE_ALV_LIST_DISPLAY, you need to add a new button.
I saw the demo program BCALV_GRID_08, which is written using ABAP-Controls.
In that example, the button is added using TOOLBAR event of cl_gui_alv_grid. This is how to do it using REUSE_ALV_LIST_DISPLAY parameters.

you should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 -->Programming SubObjects--> Gui Status.

Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.

Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.

Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality such as sorting/subtotaling etc...

When you call 'REUSE_ALV_GRID_DISPLAY' make sure you pass it the new status name.

an example of one of mine:
call function 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_callback_program = 'ZSDBOLST_REPORT'
    i_callback_pf_status_set = 'STANDARD' <---------
    i_callback_user_command = 'USER_COMMAND'
    i_structure_name = 'I_BOLACT'
    i_grid_title = 'BOL Action Report'(031)
    is_layout = gs_layout
    it_fieldcat = gt_fieldcat[]
    i_save = 'A'
    is_variant = v_variant
  TABLES
    t_outtab = i_bolact
  EXCEPTIONS    
    program_error = 1
    others = 2.


As identified with the FM's help you can do the following.

1). Using SE80 (I think) you can copy a GUI status from one program to another. It mentions which one in the FM's help.
2). Create a form named like so:

Code:
*****************************************************************
* Form Set_pf_status
* Notes: Called by FM REUSE_ALV_GRID_DISPLAY
*****************************************************************
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZSTANDARD'.
ENDFORM. "Set_pf_status
 

In the above case the GUI status copied was named ZSTANDARD and adjusted accordingly, adding and removing the desired buttons. A button was added called '%DELETE'.

3). Create the following report:
Code:
*****************************************************************
* Form User_command
* Notes: Called by FM REUSE_ALV_GRID_DISPLAY
*        Detects whether the icon/button for
*        'Return Tag Deletion' has been pressed. If it has then
*        detect whether any rows have been highlighted and then
*        set the delete flag.
*****************************************************************
FORM user_command USING r_ucomm     LIKE sy-ucomm
                        rs_selfield TYPE slis_selfield.
DATA: li_count TYPE I.
IF r_ucomm EQ '%DELETE'.
  LOOP AT %g00 WHERE mark EQ 'X'.
    ADD 1 TO li_count.
  ENDLOOP.
  IF li_count GT 0.
    gc_delete_flag = 'X'.
    r_ucomm = '&F03'. "Back arraow
  ELSE.
    MESSAGE W000 WITH 'Please highlight the rows to be deleted!'.
  ENDIF.
ENDIF.
ENDFORM.  "User_command
 

As I've added an extra button to indicate which records should be deleted I need to identify a form to be called to process when this button is chosen.

Then when you call the ALV function you to specify the following extra details:

Code:
    call function 'REUSE_ALV_GRID_DISPLAY'
         exporting  i_callback_program = gc_repid
                    I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
                    I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
                    i_grid_title       = lc_grid_title
                    is_layout          = lc_layout
                    it_fieldcat        = gt_fieldcat
                    it_sort            = sort
                    i_save             = l_save
                    is_reprep_id       = l_bbs_id
                    is_variant         = l_variant
         tables     t_outtab           = %g00
         exceptions program_error      = 1
                    others             = 2.

The parameters in capitals are the extra ones that need to be added.

That should be it!

 


Related Items:

 
< Prev   Next >

Google Search

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor