Easiest Way of ALV Toolbar Creating.

Good Point: Standard functions are still working.

Expected Result


Go to T-Code SE41 then fill in the following program and status name: –
Program: SAPLSLVC_FULLSCREEN
Status: STANDARD_FULLSCREEN
*See how to get program and status name at Appendix A.

And press ‘Copy Status’ or ‘Ctrl+F6’ button.


Fill in your program and status name which will be called into the program
then press Copy…Copy and Activate button respectively.






Go back to the program, you’ll see the new customized toolbar.


Double click the GUI Status and add your new function here.

Note: Useless standard function can be removed in case of running out of avialable box for your customized function or your report should not be applied that function like sorting.

After that set the new PF status name into PF_STATUS_SET subroutine which’s defined for I_CALLBACK_PF_STATUS_SET parameter.
And design its action into USER_COMMAND subroutine which’s defined for
I_CALLBACK_USER_COMMAND parameter.

*See source code at Appendix B.

Appendix A
After execute the ALV report, go to System > Status, you’ll see the standard program and GUI status name.




Appendix B
REPORT zalv_report.

TYPES:
  BEGIN OF gy_data,
    vbeln TYPE vbap-vbeln,
    posnr TYPE vbap-posnr,
    matnr TYPE vbap-matnr,
    zmeng TYPE vbap-zmeng,
    chk   TYPE char01,
  END OF gy_data.

DATA:
  gt_data   TYPE TABLE OF gy_data,
  gt_fcat   TYPE lvc_t_fcat,
  gw_fcat   TYPE lvc_s_fcat,
  gw_layout TYPE lvc_s_layo.


"Get data
SELECT
    vbeln,
    posnr,
    matnr,
    zmeng
  FROM vbap UP TO 10 ROWS
  INTO TABLE @gt_data
  WHERE zmeng <> 0.

"Set layout
gw_layout-zebra      = abap_true.
gw_layout-cwidth_opt = abap_true.
gw_layout-no_rowmark = abap_true.

"Set fieldcat
gw_fcat-fieldname = 'CHK'.
gw_fcat-coltext   = TEXT-000.
gw_fcat-checkbox  = abap_true.
gw_fcat-edit      = abap_true.
APPEND gw_fcat TO gt_fcat.
CLEAR: gw_fcat.

gw_fcat-fieldname = 'VBELN'.
gw_fcat-coltext   = TEXT-001.
APPEND gw_fcat TO gt_fcat.
CLEAR: gw_fcat.

gw_fcat-fieldname = 'POSNR'.
gw_fcat-coltext   = TEXT-002.
APPEND gw_fcat TO gt_fcat.
CLEAR: gw_fcat.

gw_fcat-fieldname = 'MATNR'.
gw_fcat-coltext   = TEXT-003.
APPEND gw_fcat TO gt_fcat.
CLEAR: gw_fcat.

gw_fcat-fieldname = 'ZMENG'.
gw_fcat-coltext   = TEXT-004.
APPEND gw_fcat TO gt_fcat.
CLEAR: gw_fcat.


"Call ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_callback_program       = sy-repid
    i_callback_pf_status_set = 'PF_STATUS_SET'
    i_callback_user_command  = 'USER_COMMAND'
    is_layout_lvc            = gw_layout
    it_fieldcat_lvc          = gt_fcat
    i_save                   = 'A'
  TABLES
    t_outtab                 = gt_data
  EXCEPTIONS
    program_error            = 1
    OTHERS                   = 2.

*&---------------------------------------------------------------------*
*& Form PF_STATUS_SET
*&---------------------------------------------------------------------*
FORM pf_status_set  USING pt_extab TYPE slis_t_extab.

  SET PF-STATUS 'ZSTANDARD_FULLSCREEN'.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
FORM user_command  USING pv_ucomm TYPE sy-ucomm
                         pv_field TYPE slis_selfield.

  CASE pv_ucomm.
    WHEN '&VF01'.

    WHEN OTHERS.
  ENDCASE.

ENDFORM.


Leave a Reply

Your email address will not be published. Required fields are marked *