Você está na página 1de 6

1/30/2019 ABAP - Learner's Guide: Step by Step Procedure to add Button in Application Toolbar in ALV Output: SAP ABAP

More ram.9066@gmail.com Dashboard Sign Out

ABAP - Learner's Guide


One stop ABAP solution..!!!

Home SAP ABAP Android Apps

Wednesday, 20 November 2013

Step by Step Procedure to add Button in Application Implementing SAP BW on HANA

Toolbar in ALV Output: SAP ABAP SAP HANA Books

Problem Statement: Refer & Buy SAP Press Books


In some situation, there will be a requirement to add custom button in application tool bar of ALV
output. In this tutorial we will see the step by step procedure to add new button to application tool Pages
bar.
Home
SAP ABAP
Step-1: Create the report ‘ZAPP_BUTTTON_RPT’ from SE38 transaction and copy paste the Contact Us - About
below code.

Blog Archive
*&---------------------------------------------------------------------*
*& Report ZAPP_BUTTTON_RPT ►
► 2017 (1)
*&---------------------------------------------------------------------* ►
► 2015 (2)

▼ 2013 (16)
REPORT zapp_buttton_rpt.

► December (1)
TYPE-POOLS: slis. " SLIS contains all the ALV data types ▼
▼ November (1)
Step by Step Procedure to add Button in
*&---------------------------------------------------------------------* Applicatio...
*& Data Declaration

► October (7)
*&---------------------------------------------------------------------*
DATA: t_sbook TYPE TABLE OF sbook. ►
► September (1)
DATA: t_fieldcat TYPE slis_t_fieldcat_alv, ►
► June (6)
x_fieldcat TYPE slis_fieldcat_alv.

*&---------------------------------------------------------------------* Follow by Email


*& START-OF-SELECTION
*&---------------------------------------------------------------------* Email address... Submit
START-OF-SELECTION.

About Me
*--Fetch the required data from databaase table
SELECT * FROM sbook INTO TABLE t_sbook. Venugopal M Nanjappa

View my complete profile


*--Build field catalog
x_fieldcat-fieldname = 'CARRID'. " Fieldname in the data table
x_fieldcat-seltext_m = 'Airline Name'." Column description
APPEND x_fieldcat TO t_fieldcat.
CLEAR x_fieldcat.

x_fieldcat-fieldname = 'CONNID'.
x_fieldcat-seltext_m = 'Con. No.'.
APPEND x_fieldcat TO t_fieldcat.
CLEAR x_fieldcat.

*--Call FM to disaplay data in ALV GRID format


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* i_callback_program =
* i_callback_pf_status_set = ''
* i_callback_user_command = ''
it_fieldcat = t_fieldcat
TABLES
t_outtab = t_sbook
EXCEPTIONS
program_error =1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE 'Error in displaying output.' TYPE 'E'.
ENDIF.

Step-2: Save, Activate and Execute the above program. Output of the program looks like as
follows.

http://oneabap.blogspot.com/2013/11/problem-statement-insome-situation.html 1/6
1/30/2019 ABAP - Learner's Guide: Step by Step Procedure to add Button in Application Toolbar in ALV Output: SAP ABAP

Step-3: Now go to SE90 transaction.


Expand the Objects from the left 'Repository Information System' section as follows.
i.e. Repository Information System >> Program Library >> Program Subobjects >> GUI
Status
Double click on GUI Status, and enter Program Name as 'SAPLKKBL' and Extcute.

The screen looks as follows.

Upon executing, we will see the list of available GUI Status

Step-3:
Select the CHECKBOX corresponds to STANDARD.
From Menu, go to GUI Status >> Copy (Click On COPY)

Step-4: Popup window appears, fill the details as follows and click on 'COPY'.

Step-5: Below window will appears, click on 'COPY'.

http://oneabap.blogspot.com/2013/11/problem-statement-insome-situation.html 2/6
1/30/2019 ABAP - Learner's Guide: Step by Step Procedure to add Button in Application Toolbar in ALV Output: SAP ABAP

Step-6: Now the GUI status is copied to your program. This can be seen as below.

Step-7: Double click on the 'ZSTANDARD' GUI Status. It will take you to below screen.

Step-8: Enter the function code as '&BUT' as shown above and double click on the same to
proceed further.

Upon double clicking following screen appears, select 'Static Text' Radio Button and press OK.

Step-9: Below screen appears, enter Function text, Icon Name and Information Text as show
below and press OK.

http://oneabap.blogspot.com/2013/11/problem-statement-insome-situation.html 3/6
1/30/2019 ABAP - Learner's Guide: Step by Step Procedure to add Button in Application Toolbar in ALV Output: SAP ABAP
As you can see in the above figure, we have selected "Folder Icon". You select the icon of your
interest by F4 help on Icon name field.

Step-9: Assign Function to function key. In our example we have selected "Shift-F1", then press
OK.

Step-10: Below screen appears, now validate the data entered and press OK.

Step-11: Upon pressing OK it will take you to below screen.

Save the changes to GUI status and Activate.

Step-12: Now go back to your program. Copy and Paste the below code. SAVE and ACTIVATE
the program.

*&---------------------------------------------------------------------*
*& Report ZAPP_BUTTTON_RPT
*&---------------------------------------------------------------------*

REPORT zapp_buttton_rpt.

TYPE-POOLS: slis. " SLIS contains all the ALV data types

*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: t_sbook TYPE TABLE OF sbook.
DATA: t_fieldcat TYPE slis_t_fieldcat_alv,
x_fieldcat TYPE slis_fieldcat_alv.

*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.

*--Fetch the required data from databaase table


SELECT * FROM sbook INTO TABLE t_sbook.

http://oneabap.blogspot.com/2013/11/problem-statement-insome-situation.html 4/6
1/30/2019 ABAP - Learner's Guide: Step by Step Procedure to add Button in Application Toolbar in ALV Output: SAP ABAP

*--Build field catalog


x_fieldcat-fieldname = 'CARRID'. " Fieldname in the data table
x_fieldcat-seltext_m = 'Airline Name'." Column description
APPEND x_fieldcat TO t_fieldcat.
CLEAR x_fieldcat.

x_fieldcat-fieldname = 'CONNID'.
x_fieldcat-seltext_m = 'Con. No.'.
APPEND x_fieldcat TO t_fieldcat.
CLEAR x_fieldcat.

DATA: l_repid TYPE sy-repid.


l_repid = sy-repid.

*--Call FM to disaplay data in ALV GRID format


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_pf_status_set = 'SUB_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcat
TABLES
t_outtab = t_sbook
EXCEPTIONS
program_error =1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE 'Error in displaying output.' TYPE 'E'.
ENDIF.

*&---------------------------------------------------------------------*
*& Form sub_pf_status
*&---------------------------------------------------------------------*
* Sub-Routine to Set the PF status
*----------------------------------------------------------------------*
FORM sub_pf_status USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'ZSTANDARD'.
ENDFORM. "sub_pf_status

*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* Sub-Routine to handle the click on the ALV aoutput
*----------------------------------------------------------------------*
FORM user_command USING r_ ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.

IF r_ucomm EQ '&BUT'.
MESSAGE 'Custom button is clicked.' TYPE 'S'.
ENDIF.

ENDFORM. "User_command

Step-13: Execute(F8) the program. Now we can see the newly added BUTTON in application
toolbar.

Click on the button to see the success message written in the code.

Conclusion:
Thus we have learnt the procedure to add the Button in Application Toolbar in ALV Output.

Regards,
Venugopal M N

Posted by Venugopal M Nanjappa at 11:27

Labels: ABAP, Adding Button in Application Toolbar, ALV

No comments:
http://oneabap.blogspot.com/2013/11/problem-statement-insome-situation.html 5/6
1/30/2019 ABAP - Learner's Guide: Step by Step Procedure to add Button in Application Toolbar in ALV Output: SAP ABAP

Post a Comment

Enter your comment...

Comment as: ram9066 (Goog Sign

Publish Preview No

Newer Post Home Older Post

Subscribe to: Post Comments (Atom)

© 2013. All Rights Reserved. Simple theme. Powered by Blogger.

http://oneabap.blogspot.com/2013/11/problem-statement-insome-situation.html 6/6

Você também pode gostar