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

How to create button in ABAP

Former Member
0 Likes
18,607

Plz tell me the syntax

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
7,524

Hi,

Look at the below piece of code to find the syntax for a push button in ABAP :

SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON 70(4) but1 USER-COMMAND create.
SELECTION-SCREEN PUSHBUTTON 74(4) but2 USER-COMMAND change.
SELECTION-SCREEN PUSHBUTTON 78(4) but3 USER-COMMAND display.

SELECTION-SCREEN END OF BLOCK b1.

this will surely help you.

plz reward if useful.

thanks,

dhanashri.

Plz tell me the syntax

6 REPLIES 6
Read only

franois_henrotte
Active Contributor
0 Likes
7,524

use F1 help on keyword SELECTION-SCREEN (screen elements) and look for PUSHBUTTON

Read only

former_member156446
Active Contributor
0 Likes
7,524

SELECTION SCREEN PUSHBUTTON [/]<pos(len)> <push>

USER-COMMAND <ucom> [MODIF ID <key>].

The [/]<pos(len)> parameters and the MODIF IF 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.

[check the link for more info|http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba81635c111d1829f0000e829fbfe/content.htm]

Read only

Subhankar
Active Contributor
0 Likes
7,524

Hi

If you want push button use set pf status.

SET PF-STATUS 'SUBHA'.

then double click on SUBHA.

then add user command in application toolbar or in menu bars

Read only

Former Member
0 Likes
7,524

Go through this

SELECTION-SCREEN - PUSHBUTTON

Syntax

SELECTION-SCREEN PUSHBUTTON [/][pos](len) button_text

USER-COMMAND fcode

[VISIBLE LENGTH vlen]

[MODIF ID modid]

[ldb_additions].

Extras:

1. ... [/][pos](len)

2. ... USER-COMMAND fcode

3. ... VISIBLE LENGTH vlen

4. ... MODIF ID modid

Effect

This statement creates a pushbutton on the current selection screen. The text on the pushbutton is determined by the content of button_text. The rules that apply to text also apply to button_text when creating an output field.

The additions ldb_additions can only be used in the selection include for a logical database.

Notes

You can use the function module ICON_CREATE to assign an icon, a quick info text and a corresponding text to a pushbutton. When you do this, you must specify an adequate length len for the pushbutton so that the icon can be displayed internally and adjust the visible length with VISIBLE LENGTH.

Once the event block in AT SELECTION-SCREEN has been processed, the system usually returns to displaying the selection screen. To exit selection screen processing and continue executing the program, you can only choose Execute or Cancel. This means pushbuttons on selection screens are intended primarily for use for dynamic modifications to the selection screen rather than to control the program.

Addition 1

... [/][pos](len)

Effect

You must specify the position of the output field using [/][pos](len). The syntax and meaning of [/][pos](len) are the same as when creating horizontal lines, although in this case, len defines the length of the pushbutton on the selection screen. If a pushbutton extends beyond position 83 or beyond the edge of a block with a frame, it is cut off at the right hand side.

Addition 2

... USER-COMMAND fcode

Effect

If you specify the USER-COMMAND addition, the pushbutton must be assigned a function code fcode. The function code fcode must be specified directly and can only contain a maximum of 20 characters.

Before you can work with the pushbutton, you must specify a TABLES statement to declare an interface work area for the structure SSCRFIELDS from the ABAP Dictionary.

If the user selects the pushbutton on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and the function code fcode is transferred to the ucomm component in the interface work area sscrfields.

Note

If the function code of a pushbutton corresponds to a function code used in the GUI status of the selection screen, the selection screen processing is influenced accordingly.

Addition 3

... VISIBLE LENGTH vlen

Effect

The VISIBLE LENGTH addition defines the visible length vlen of the pushbutton and your text. The syntax and meaning of this addition are the same as when creating output fields, although a pushbutton is never displayed as shorter than the text defined for it.

Addition 4

... MODIF ID modid

Effect

The MODIF ID addition assigns the pushbutton to the modification group modid that is assigned to the column group1 on the system table screen. This means it can be modified using a MODIFY SCREEN statement before the selection screen is displayed.

Example

Define and access a stand-alone selection screen 500 with two pushbuttons in an executable program. An icon and a quick info text are created for the second pushbutton.

TABLES sscrfields.

TYPE-POOLS icon.

SELECTION-SCREEN:

BEGIN OF SCREEN 500 AS WINDOW TITLE title,

PUSHBUTTON 2(10) but1 USER-COMMAND cli1,

PUSHBUTTON 12(30) but2 USER-COMMAND cli2

VISIBLE LENGTH 10,

END OF SCREEN 500.

AT SELECTION-SCREEN.

CASE sscrfields.

WHEN 'CLI1'.

...

WHEN 'CLI2'.

...

ENDCASE.

START-OF-SELECTION.

title = 'Push button'.

but1 = 'Button 1'.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_information

text = 'Button 2'

info = 'My Quickinfo'

IMPORTING

RESULT = but2

EXCEPTIONS

OTHERS = 0.

CALL SELECTION-SCREEN '0500' STARTING AT 10 10.

THnaks

Ankur Sharma

Read only

Former Member
0 Likes
7,525

Hi,

Look at the below piece of code to find the syntax for a push button in ABAP :

SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN PUSHBUTTON 70(4) but1 USER-COMMAND create.
SELECTION-SCREEN PUSHBUTTON 74(4) but2 USER-COMMAND change.
SELECTION-SCREEN PUSHBUTTON 78(4) but3 USER-COMMAND display.

SELECTION-SCREEN END OF BLOCK b1.

this will surely help you.

plz reward if useful.

thanks,

dhanashri.

Read only

Former Member
0 Likes
7,524

hi check this example..

report ztest.

start-of-selection.

write:/ 'this is the test'.

set pf-status 'DAT'.<----double click this it will take into another screen and fill it..

at user-command.

case sy-ucomm.

when 'DATA'.

write:/ 'button is pressed'.

endcase.