SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Add buttons to report Selection screen



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Oct 14, 2007 6:39 pm    Post subject: Add buttons to report Selection screen Reply with quote

Add buttons to report Selection screen
The following code demonstrates how to add user defined push buttons to a standard report selection screen.
Push buttons are used to trigger user functions with in the program to make them interactive with the user.
The example below shows how buttons can allow you to dynamically alter a selection screen depending on which button is pressed. But they can be used for many other applications from displaying a window to calling other reports.

Code:

*&---------------------------------------------------------------------*
*& Report  ZSSCRBUTTON                                                 *
*&                                                                     *
*&---------------------------------------------------------------------*
*&  Adds buttons to selection screen.                                  *
*&  Demonstrates alteration of selection screen layout depending on    *
*&  which button is pressed.                                           *
*&---------------------------------------------------------------------*
 REPORT  zsscrbutton NO STANDARD PAGE HEADING.

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.


Add buttons with icon to selection screen

The following code demonstrates how to add user defined push buttons which contain icons to a standard report selection screen.Push buttons are used to trigger user functions with in the program to make them
interactive with the user. The example below shows how buttons can allow you to dynamically alter a selection screen depending on which button is pressed. But they can be used for many other applications
from displaying a window to calling other reports.

Code:

*&---------------------------------------------------------------------*
*& Report  ZSSCRBUTTONS2                                               *
*&                                                                     *
*&---------------------------------------------------------------------*
*&  Adds buttons to selection screen.                                  *
*&  Demonstrates alteration of selection screen layout depending on    *
*&  which button is pressed.                                           *
*&                                                                     *
*&  Additional Info:                                                   *
*&    TEXT-FY1 = 'Fiscal Year'                                         *
*&    Selection text for SO_DATES = 'Date Period'                      *
*&---------------------------------------------------------------------*

REPORT  zsscrbuttons2.

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.


Add buttons to Application toolbar of selection screen
The following code demonstrates how to add user defined push buttons to the application toolbar of a standard report selection screen.

Code:

*&---------------------------------------------------------------------*
*& Report  ZSSCRAPPBUT                                                 *
*&                                                                     *
*&---------------------------------------------------------------------*
*&  Adds buttons to application toolbar of selection screen.           *
*&---------------------------------------------------------------------*

REPORT  zsscrappbut NO STANDARD PAGE HEADING.

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.