Application Development 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: 

How to insert pushbutton in selection screen and if i click that pushbutton

Former Member

How to insert pushbutton in selection screen and if i click that pushbutton it will clear the selection screen field plz send me coding for this.

10 REPLIES 10

Former Member
0 Kudos

write selection-screen in abap editor...press F1...you will get the option for putting a pushbutton...

assign it a ok code...and then write your code in the event at user-command.

Former Member
0 Kudos

Hi Kiran,

REPORT DEMO.

TABLES SSCRFIELDS.

DATA FLAG.

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.

This example defines four pushbuttons on a selection screen that is displayed as a dialog box. The selection screen is defined in a statement chain for keyword SELECTION-SCREEN.

If the text symbols TEXT-020 and TEXT-040 are defined as 'Button 2' and 'Button 4', the four pushbuttons appear as follows on the selection screen displayed as a dialog box.

CLI1, CLI2, CLI3 and CLI4 are used for <ucom>. When the user clicks one of the pushbuttons, the AT SELECTION-SCREEN event is triggered, and the FLAG field is set. The FLAG field can be further processed during subsequent program flow after the user has chosen Execute.

Refer the above code, and make change just to clear all the fields in the selection screen, when corresponding push button is clicked..

hope this helps.

0 Kudos

This message was moderated.

Hi,

You can use the below code for push button

SELECTION-SCREEN PUSHBUTTON 49(30) text-001 USER-COMMAND BTN.

And then

In the program use

DATA: fcode type sy-ucomm.

AT selection-screen.

fcode = sy-ucomm.

if fcode = 'BTN'.

clear: ....

endif.

If you want to hide the fields then you have to use code below

LOOP AT SCREEN

MODIFY SCREEN.

ENDLOOP.

at event AT SELECTION-SCREEN OUTPUT.

Regards,

Sesh

former_member188827
Active Contributor
0 Kudos

create ur own status using pf-status.in that create a push button and assign it a function code.

den in ur program use..

set pf-status 'zstat'.

case ok_code.

when 'zabc'.

...add the functionality u want here....

endcase.

plz reward points if it helps

Former Member
0 Kudos

Hi ,

Please check the code below ..

TYPE-POOLS icon.

SELECTION-SCREEN:

PUSHBUTTON 12(30) but2 USER-COMMAND cli2

VISIBLE LENGTH 10.

INITIALIZATION.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_information

  • text = 'Button 2'

info = 'My Quickinfo'

IMPORTING

RESULT = but2

EXCEPTIONS

OTHERS = 0.

Former Member
0 Kudos

HI, there are few sample programs to add button on ur selection screen.

Please REWARD POINT IF HELPFUL.

TABLES: t030, skat, sscrfields.

SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME

TITLE text-001.

SELECT-OPTIONS: p_ktopl FOR t030-ktopl,

p_komok FOR t030-komok,

p_ktosl FOR t030-ktosl.

SELECTION-SCREEN SKIP.

*SELECTION-SCREEN FUNCTION KEY 1. "Adds button to application toolbar

  • Declaration of sel screen buttons

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN PUSHBUTTON (20) w_button USER-COMMAND BUT1.

SELECTION-SCREEN PUSHBUTTON (25) w_but2 USER-COMMAND BUT2.

SELECTION-SCREEN END OF LINE.

SELECT-OPTIONS: p_konts FOR t030-konts,

p_bklas FOR t030-bklas.

PARAMETER: gd_ucomm like sy-ucomm default 'BUT1' no-display.

SELECTION-SCREEN END OF BLOCK block1.

TYPES: BEGIN OF t_t030,

ktopl TYPE t030-ktopl,

konts TYPE t030-konts,

txt20 TYPE skat-txt20,

bklas TYPE t030-bklas,

bkbez TYPE t025t-bkbez,

END OF t_t030.

DATA: it_t030 TYPE STANDARD TABLE OF t_t030 INITIAL SIZE 0,

wa_t030 TYPE t_t030.

DATA: gd_repsize TYPE i VALUE '83'.

************************************************************************

*INITIALIZATION.

INITIALIZATION.

  • Add displayed text string to buttons

w_button = 'GL account selection'.

w_but2 = 'Valuation class selection'.

************************************************************************

*AT SELECTION-SCREEN.

AT SELECTION-SCREEN.

  • Check if buttons have been

if sscrfields-ucomm eq 'BUT1'.

gd_ucomm = 'BUT1'.

clear: p_BKLAS.

refresh: p_BKLAS.

elseif sscrfields-ucomm eq 'BUT2'.

clear: p_KONTS.

refresh: p_KONTS.

gd_ucomm = 'BUT2'.

endif.

************************************************************************

*AT SELECTION-SCREEN OUTPUT.

AT SELECTION-SCREEN OUTPUT.

if gd_ucomm eq 'BUT1'.

loop at screen.

if screen-name CS 'P_KONTS'.

screen-active = 1.

elseif screen-name CS 'P_BKLAS'.

screen-active = 0.

endif.

modify screen.

endloop.

elseif gd_ucomm eq 'BUT2'.

loop at screen.

if screen-name CS 'P_KONTS'.

screen-active = 0.

elseif screen-name CS 'P_BKLAS'.

screen-active = 1.

endif.

modify screen.

endloop.

endif.

TABLES: sscrfields.

DATA: gd_ucomm TYPE sy-ucomm.

SELECTION-SCREEN BEGIN OF BLOCK period WITH FRAME TITLE text-t02.

SELECT-OPTIONS: so_dates FOR sy-datum NO-EXTENSION.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 01(20) text-fy1. "= Fiscal Year

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_period LIKE qppnp-pabrp.

SELECTION-SCREEN POSITION 36.

PARAMETERS: p_year LIKE qppnp-pabrj.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN PUSHBUTTON /01(29) but1 USER-COMMAND but1.

SELECTION-SCREEN PUSHBUTTON /01(29) but2 USER-COMMAND but2.

SELECTION-SCREEN END OF BLOCK period.

************************************************************************

*INITIALIZATION.

INITIALIZATION.

  • MOVE 'Fiscal Year' TO BUT1.

MOVE 'Date Period' TO but2.

DATA: icon_name TYPE iconname,

button_text(20) TYPE c,

quickinfo LIKE smp_dyntxt-quickinfo,

icon_str(255) TYPE c.

  • Setup button 1 (Fiscal year)

icon_name = 'ICON_ARROW_RIGHT'. " 'ICON_DISPLAY_MORE'.

button_text = 'Fiscal Year'.

CONCATENATE button_text text-akt

INTO quickinfo

SEPARATED BY space.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_name

text = button_text

info = quickinfo

  • ADD_STDINF = 'X'

IMPORTING

RESULT = icon_str

EXCEPTIONS

OTHERS = 0. "not interested in errors

  • place text and icon on button

but1 = icon_str.

  • Setup button 2 (Date period)

icon_name = 'ICON_ARROW_LEFT'. " 'ICON_DISPLAY_MORE'.

button_text = 'Date Period'.

CONCATENATE button_text text-akt

INTO quickinfo

SEPARATED BY space.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_name

text = button_text

info = quickinfo

  • ADD_STDINF = 'X'

IMPORTING

RESULT = icon_str

EXCEPTIONS

OTHERS = 0. "not interested in errors

  • place text and icon on button

but2 = icon_str.

************************************************************************

*AT SELECTION-SCREEN.

AT SELECTION-SCREEN.

  • Check if buttons have been

IF sscrfields-ucomm EQ 'BUT1'.

gd_ucomm = 'BUT1'.

ELSEIF sscrfields-ucomm EQ 'BUT2'.

gd_ucomm = 'BUT2'.

ENDIF.

************************************************************************

*AT SELECTION-SCREEN.

AT SELECTION-SCREEN OUTPUT.

IF gd_ucomm IS INITIAL.

LOOP AT SCREEN.

IF screen-name CS 'P_PERIOD' OR

screen-name CS 'P_YEAR' OR

screen-name CS 'FY1' OR

screen-name EQ 'BUT2'.

screen-active = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSEIF gd_ucomm EQ 'BUT1'.

LOOP AT SCREEN.

IF screen-name CS 'P_PERIOD' OR

screen-name CS 'P_YEAR' OR

screen-name CS 'FY1' OR

screen-name EQ 'BUT2'.

screen-active = 1.

MODIFY SCREEN.

ENDIF.

IF screen-name CS 'SO_DATES' OR

screen-name EQ 'BUT1'.

screen-active = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSEIF gd_ucomm EQ 'BUT2' .

LOOP AT SCREEN.

IF screen-name CS 'P_PERIOD' OR

screen-name CS 'P_YEAR' OR

screen-name CS 'FY1' OR

screen-name EQ 'BUT2'.

screen-active = 0.

MODIFY SCREEN.

ENDIF.

IF screen-name CS 'SO_DATES' OR

screen-name EQ 'BUT1'.

screen-active = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

TABLES: t030, skat, sscrfields.

SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME

TITLE text-001.

SELECT-OPTIONS: p_ktopl FOR t030-ktopl,

p_komok FOR t030-komok,

p_ktosl FOR t030-ktosl.

SELECTION-SCREEN SKIP.

  • Add button to application toolbar

SELECTION-SCREEN FUNCTION KEY 1. "Will have a function code of 'FC01'

SELECTION-SCREEN FUNCTION KEY 2. "Will have a function code of 'FC02'

  • .....

SELECTION-SCREEN END OF BLOCK block1.

************************************************************************

*INITIALIZATION.

INITIALIZATION.

  • Add displayed text string to buttons

MOVE 'Application button' to SSCRFIELDS-FUNCTXT_01.

MOVE 'Excecute report ????' to SSCRFIELDS-FUNCTXT_02.

  • .....

************************************************************************

*AT SELECTION-SCREEN.

AT SELECTION-SCREEN.

if sscrfields-ucomm = 'FC01'.

break-point.

elseif sscrfields-ucomm = 'FC02'.

break-point.

endif.

use anything according to your need

Former Member
0 Kudos

Hi Kiran,

Try this code.

PARAMETERS: r1 RADIOBUTTON GROUP rad1 USER-COMMAND radio,

r2 RADIOBUTTON GROUP rad1.

PARAMETERS: matnr LIKE mara-matnr MODIF ID mg1.

AT SELECTION-SCREEN OUTPUT.

IF r2 = 'X'.

LOOP AT SCREEN.

IF screen-group1 = 'MG1'.

screen-active = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

Regards,

RAJ

    • Reward points if it is useful **

robert_zentai
Member
0 Kudos

Hi Kiran,

old queston, but I think this would be the simplest way:

TABLES: sscrfields.

*-SELECTION-SCREEN----------------------------------------------*

SELECTION-SCREEN: FUNCTION KEY 1.   " first button
SELECTION-SCREEN: FUNCTION KEY 2.   " second button



*-INITIALIZATION-------------------------------------------------------*
INITIALIZATION.

   gs_smp_dyntxt-text      = text-001.
   gs_smp_dyntxt-icon_id   = icon_display.  "choose an icon
   gs_smp_dyntxt-icon_text = text-001.
   gs_smp_dyntxt-quickinfo = text-001.
   MOVE: gs_smp_dyntxt TO sscrfields-functxt_01.

   gs_smp_dyntxt-text      = text-002.
   gs_smp_dyntxt-icon_id   = icon_change. "choose an icon
   gs_smp_dyntxt-icon_text = text-002.
   gs_smp_dyntxt-quickinfo = text-002.
   MOVE: gs_smp_dyntxt TO sscrfields-functxt_02.




*-PAI------------------------------------------------------------------*
AT SELECTION-SCREEN.

CASE sscrfields-ucomm.
     WHEN 'FC01'.  "first button
        " enter your code

        ".

        ".
     WHEN 'FC02'.  "second button
        " enter your code  

        ".

        ".


ENDCASE.

Regards,

Robert

0 Kudos

Hi,

Check this,

TABLES: vbak.

TYPESBEGIN OF ty_vbak,

           vbeln  TYPE vbak-vbeln,

           kunnr  TYPE vbak-kunnr,

           bstnk  TYPE vbak-bstnk,

         END OF ty_vbak.

SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.

SELECT-OPTIONS: so_vbeln FOR vbak-vbeln,

                 so_kunnr FOR vbak-kunnr,

                 so_bstnk FOR vbak-bstnk.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN PUSHBUTTON 70(4) but1 USER-COMMAND clear.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN.

   IF so_vbeln IS NOT INITIAL OR so_kunnr IS NOT INITIAL OR so_bstnk IS NOT INITIAL.

     CASE sy-ucomm.

       WHEN 'CLEAR' .

         REFRESH so_vbeln.

         REFRESH so_kunnr.

         REFRESH so_bstnk.

       WHEN OTHERS.

     ENDCASE.

   ENDIF.


Regards,

Karthik