Monday, June 17, 2013

Pushbutton on ABAP Selection Screen

TABLES sscrfields.
*--------------------------------------------------------------*
*Selection-Screen
*--------------------------------------------------------------*
SELECTION-SCREEN:
      PUSHBUTTON /2(40) button1 USER-COMMAND but1,
      PUSHBUTTON /2(40) button2 USER-COMMAND but2.
*--------------------------------------------------------------*
*At Selection-Screen
*--------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sscrfields.
    WHEN 'BUT1'.
      MESSAGE 'Button 1 was clicked' TYPE 'I'.
    WHEN 'BUT2'.
      MESSAGE 'Button 2 was clicked' TYPE 'I'.
  ENDCASE.
*--------------------------------------------------------------*
*Initialization
*--------------------------------------------------------------*
INITIALIZATION.
  button1 = 'Button 1'.
  button2 = 'Button 2'.
Selection Screen Output
Pushbutton-selection-screen-1
If Button 1 is clicked then we get the following popup.
Pushbutton-selection-screen-2
Even we can add icons to the pushbuttons on selection screen.
TYPE-POOLS: icon.
TABLES sscrfields.
*--------------------------------------------------------------*
*Selection-Screen
*--------------------------------------------------------------*
SELECTION-SCREEN:
      PUSHBUTTON /2(40) button1 USER-COMMAND but1,
      PUSHBUTTON /2(40) button2 USER-COMMAND but2.
*--------------------------------------------------------------*
*At Selection-Screen
*--------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sscrfields.
    WHEN 'BUT1'.
      MESSAGE 'Button 1 was clicked' TYPE 'I'.
    WHEN 'BUT2'.
      MESSAGE 'Button 2 was clicked' TYPE 'I'.
  ENDCASE.
*--------------------------------------------------------------*
*Initialization
*--------------------------------------------------------------*
INITIALIZATION.
  button1 = 'Button 1'.
  button2 = 'Button 2'.

  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name   = icon_okay
      text   = 'Continue'
      info   = 'Click to Continue'
    IMPORTING
      RESULT = button1
    EXCEPTIONS
      OTHERS = 0.

  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name   = icon_cancel
      text   = 'Exit'
      info   = 'Click to Exit'
    IMPORTING
      RESULT = button2
    EXCEPTIONS
      OTHERS = 0.
Selection Screen Output
Pushbutton-selection-screen-3

3 comments:

  1. dear reddy,

    thanks for the post.

    regards

    antonio

    ReplyDelete
  2. excellent work! update your site with some new topics also.

    Kumar

    ReplyDelete
  3. SAP ABAP training is provided in CHENNAI.

    THE CREATING EXPERTS is one of the leading trainer in SAP who provides real time training

    http://thecreatingexperts.com/sap-abap-training-in-chennai/

    contact 8122241286

    ReplyDelete