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

pushbutton

Former Member
0 Likes
1,177

Hi,

Can anyone tell me how to create pushbuttons in o/p screen?

6 REPLIES 6
Read only

Former Member
0 Likes
1,116

hi,

To create a pushbutton on the selection screen you use the following statement during the definition of the selection screen:

SELECTION SCREEN PUSHBUTTON [/]pos(len) push

USER-COMMAND fcode [MODIF ID key].

The [/]pos(len) parameters and the MODIF ID addition have the same function as for the formatting options for underlines and comments.

push determines the pushbutton text. For push, you can specify a text symbol or a field name with a maximum length of eight characters. This character field must not be declared with the DATA statement, but is generated automatically with length len. The field must be filled before the selection screen is called.

For fcode, a standard table has to be specified. When the user clicks on the pushbutton on the selection screen, the runtime environment triggers the AT SELECTION-SCREEN event and the function code fcode is transferred to the ucommcomponent of the interface work area sscrfields. You must use the TABLESstatement to declare the sscrfieldsstructure in the ABAP program.

After the AT SELECTION-SCREEN event has been processed, the system displays the selection screen again. The only way to exit the selection screen and carry on processing the program is to choose Execute (F8). Consequently, the pushbuttons are more suitable for controlling dynamic modifications of the selection screen than for controlling the program flow.

You can only see the pushbuttons of a selection screen if you call that screen. However, standard selection screens in executable programs are only called if they contain at least one input field declared using the PARAMETERS or SELECT-OPTIONS statements. This means that pushbuttons on a standard selection screen which do not include at least one input field are pointless. User-defined selection screens, on the other hand, can be called even if they do not contain an input field. In this case pushbuttons, on selection screens without input fields, are possible.

REPORT demo_sel_screen_pushbutton.

TABLES sscrfields.

DATA flag(1) TYPE c.

SELECTION-SCREEN:

BEGIN OF SCREEN 500 AS WINDOW TITLE tit,

BEGIN OF LINE,

PUSHBUTTON 2(10) but1 USER-COMMAND cli1,

PUSHBUTTON 12(10) text-020 USER-COMMAND cli2,

END OF LINE,

BEGIN OF LINE,

PUSHBUTTON 2(10) but3 USER-COMMAND cli3,

PUSHBUTTON 12(10) text-040 USER-COMMAND cli4,

END OF LINE,

END OF SCREEN 500.

AT SELECTION-SCREEN.

CASE sscrfields.

WHEN 'CLI1'.

flag = '1'.

WHEN 'CLI2'.

flag = '2'.

WHEN 'CLI3'.

flag = '3'.

WHEN 'CLI4'.

flag = '4'.

ENDCASE.

START-OF-SELECTION.

tit = 'Four Buttons'.

but1 = 'Button 1'.

but3 = 'Button 3'.

CALL SELECTION-SCREEN 500 STARTING AT 10 10.

CASE flag.

WHEN '1'.

WRITE / 'Button 1 was clicked'.

WHEN '2'.

WRITE / 'Button 2 was clicked'.

WHEN '3'.

WRITE / 'Button 3 was clicked'.

WHEN '4'.

WRITE / 'Button 4 was clicked'.

WHEN OTHERS.

WRITE / 'No Button was clicked'.

ENDCASE.

Hope this is helpful, DO reward.

Read only

Former Member
0 Likes
1,116

SELECTION-SCREEN PUSHBUTTON 24(35) NAME1 USER-COMMAND SEND.

Read only

Former Member
0 Likes
1,116

Hi,

Just copy paste and activate and test this code.

selection-screen: pushbutton 1(40) text-001 user-command push.

At selection-screen.

case sy-ucomm.

when 'PUSH'.

message i016(rp) with 'Go back to the selection screen'.

when others.

endcase.

In output there will be a push button and when the button is clicked there will be a message pop up which says "Go back to the selection-screen".

Note: here the button could be named and the name could be maintained in the text- element text-001.

hope this helps.

Read only

Former Member
0 Likes
1,116

Hi Hema,

For Creation of push buttons on the output screen use

SET PF-STATUS 'ZNAME'.

you double click on the ZNAME and create push buttons there ok..

Reward points if helpful

Kiran Kumar.G.A

Read only

Former Member
0 Likes
1,116

if you want a button in toolbar you have to use the pf-status

you have to assign a function code, icon, tooltip, icon text etc

if you want it in selection screen you need to add it through coding as parameters in selection screen

or as a screen elemnet then add it in screen layout and declare it again in the gloabal field of report

all the three cases have been specified above by other users

reward if useful

Read only

ankurgodre
SAP Mentor
SAP Mentor
0 Likes
1,116

Hi,

In order to create a pushbutton in ALV grid output screen, always remember to first copy the STATUS from the standard SAP program: SAPLKKBL .For this goto: SE90 or SE 80 & goto GUI status & put in this program name & execute it & then copy the standard status to the status which you will be creating for your program.After copying the standard status u can go to ur program & double click ur status (SET PF_STATUS 'ZSTANDARD'.) & add a pushbutton to the standard copied status.Save & activate & then u can code the function for that pushbutton. For further details mail me on: sapag07@rediffmail.com

Please reward if useful.

Regards

Ankur Godre