Search This Blog

Friday, February 19, 2010

Selection-Screen Statements in SAP ABAP


--> There are 11 statements used in ABAP under this category.
    1) PARAMETERS.
    2) SELECTION-SCREEN COMMENT.
    3) SELECTION-SCREEN BEGIN OF LINE –
        END OF LINE.
    4) SELECTION-SCREEN SKIP.
    5) SELECTION-SCREEN ULINE.
    6) SELECTION-SCREEN PUSH BUTTON.
    7) SELECTION-SCREEN BEGIN OF BLOCK –
        END OF BLOCK.
    8) SELECTION-SCREEN BEGIN OF SCREEN –
        END OF SCREEN.
    9) SELECTION-SCREEN FUNCTION KEY.
  10) SELECT-OPTIONS.
  11) SELECTION-SCREEN POSITION.

1) PARAMETERS:
    --> Used to create I/O fields, check boxes and radio buttons in ABAP.
syntax:
    PARAMETERS <VAR_NAME>
[<TYPE/LIKE> <DATATYPE/EXISTING VARIABLE>]
[DEFAULT <INITIAL_VALUES>] [LOWER CASE] [OBLIGATORY]
[MATCHCODE_OBJECT <SHLD>].

By default, name of the variable itself is displayed as label on GUI. To change label for GUI, activate the code in SE38
  • click on 'GOTO' menu
  • Text Elements
  • Selection-text
  • Opens an interface with list of GUI components in program, set the required text to be displayed on GUI as label
 à save
    à activate
    à comeback.

b) Syntax for generating checkboxes using parameters statement.:
    syntax: PARAMETERS <VAR_NAME> AS CHECKBOX. 
  • Whenever a field is defined for checkbox, by default, variable is assigned to type 'C' data type.

  • If the checkbox is selected, value of the variable will be 'X'. Else, space.

       c) Syntax for generating radio buttons using parameters statement:

    syntax: PARAMETERS <VAR_NAME> RADIO BUTTON
                    GROUP <GROUP_NAME>.

 à Radio buttons are defined under one group category.
  • Under one group at least two components must be added.
  • Only one of the radio button in a group can be selected.  
2) SELECTION-SCREEN COMMENT statement:

Syntax: SELECTION-SCREEN COMMENT [/]<POS>(width)
        <Label variable>
  • It is a statement used in ABAP to add a label on selection-screen GUI. 
Ex:     Parameters : A type I default 300.
          selection-screen comment /20(15) LB1.
          write: A.
          INITIALIZATION.    "-> Event

             A = 900.
             LB1 = 'A value'.

INITIALIZATION EVENT:
  • It is an event in ABAP used to set default values for all GUI variables in SAP scrn.
  • This is executed before loading the screen.
à The need of this event is that there are some GUI variables like 'LABEL', 'PUSH BUTTONS', 'FUNTIONS KEYS', 'BLOCK NAMES', 'SCREEN TITLES' etc which cannot be initialized at the time of declaration using DEFAULT addition.
  • For initializing such GUI variables, we need INITIALIZATION EVENT.

  • Before loading the screen, initialization event is executed and even before it, declaration part is executed.  
FAQ: What is the need of initialization event when there is default addition in SAP?
Ans: (Explained above).

 3) Selection-screen begin of line – end of line:
    à Any input field created in SAP is created in new line. For displaying more than one input field in same row, the statements must be specified between Selection-screen Begin of line = = = = = Selection-screen End of line.
    à But here, the labels of the input fields will not be displayed. For displaying them we need to add manually using Selection-screen comments stmt.

Ex:       Selection-screen begin of line.
            Selection-screen comment 1(10) LB1.
Parameters: Name(20).
Selection-screen comment 40(10) LB2.
Parameters: No.(10).
Selection-screen end of line.

        Initialization.    "-> Event
           LB1 = 'Name'. LB2 = 'No:'.

4) Selection-screen skip [N]:

    à Used for generating Blank lines on GUI for selection screen.
    à N specifies the no. of lines to be skipped off.

5) Selection-screen ULINE:
    à This is a statement used for generating Horizontal lines on GUI.
    Syntax: SELECTION-SCREEN ULINE [/] [<POS>] [(WIDTH)].  

6) Selection-screen Push Button:
    à This is a statement used to add Push Buttons on GUI.
    Syntax: Selection-screen pushbutton [/] [<POS>] [(WIDTH)] <LB1> User-command <PB1>.
        where <LB1> is the variable on Pushbutton and <PB1> is the name of it.


Ex:     Parameters: Kunnr like kna1-kunnr,
                            Land1 like kna1-land1,
                            Name1 like kna1-name1,
                            Ort01 like Kna1-ort01.
Selection-screen Pushbutton /10(10) LB1 User command PB1.
Selection-screen Pushbutton 30(10) LB2 User command PB2.

Initialization.    "Event
    LB1 = 'Abap Editor'.
    LB2 = 'Abap Dictionary'.
At Selection screen.    "Event
Case sy-ucomm.
    When PB1.
        Call Transaction 'se38'.
    When PB2.
        Call Transaction 'se11'.
End Case.  
7) Selection-screen Begin of Block ===== End of Block:

à This is a statement used to create Block in the selection-screen, which will be easier for the users to understand the related/grouped Selection screen fields.
Syntax:     SELECTION-SCREEN BEGIN OF BLOCK <B> WITH FRAME TITLE <T>.
     SELECTION-SCREEN END OF BLOCK <B>.
8) Selection-screen Begin of Screen ===== End of Screen:

à This is a statement used to create our own screens and can be understood in conjuction with Screen Painter. (Explained in Screen Painter/MPP concepts)
9) Selection-screen Function key:
    à This is a stmt used to create application tool bar components in selection screen.
    Syntax: SELECTION-SCREEN FUNCTION KEY <Num>.
        where Num is ranging from 1 to 5.

SSCR FIELDS: It is a structure in SAP for selection screens. Only 5 application tool bar components can be crated in a screen.
    à Whenever application tool bar components are added using above stmt, for these components labels are defined under a structure called " SSCRFIELDS" as FC01, FC02, FC03, FC04 and FC05 related to respective function key number.  
 à For this structure we need to allocate implicit memory using "TABLES" statement.
    Ex:     TABLES SSCRFIELDS.
              PARAMETERS: ID(10).
              SELECTION-SCREEN FUNCTION KEY 1.
  SELECTION-SCREEN FUNCTION KEY 2.
  SELECTION-SCREEN FUNCTION KEY 3.
             
              INITIALIZATION:                  
                   SSCRFIELDS-FUNCTXT_01 = 'FIRST ATC'.
                   SSCRFIELDS-FUNCTXT_02 = 'SECOND ATC'.
                   SSCRFIELDS-FUNCTXT_03 = 'THIRD ATC'.

AT SELECTION-SCREEN.     CASE SY-UCOMM.
         WHEN 'FC01'.
            MESSAGE I000(ZMSG_11AM).
         WHEN 'FC02'.
            MESSAGE I001(ZMSG_11AM).
         WHEN 'FC03'.
            LEAVE PROGRAM.
         ENDCASE.
10) SELECT-OPTIONS:
    à This statement is used for creating range of input fields for selection screen. Using this option, we can fetch required selected data from the DB table.
        Syntax: SELECT-OPTION <Var> FOR <Existing variable>.
            <Var> becomes a GUI variable for existing variable.   
        Ex:     DATA CNO(5).
                 SELECT-OPTIONS CNUM FOR CNO.

    à Internally, when SELECT-OPTIONS is used, a structure is created as below:
DATA:  BEGIN OF CNUM,
                SIGN(1),
                OPTION(2),
                LOW(5),
                HIGH(5),
            END OF CNUM.
This is predefined structure for select-options.  
à By default the content of sign is 'I' and option will be BW (between) when range is selected or EQ (Equal to) when only LOW value is given. It means IN BETWEEN. i.e., fields in between the high and low values specified are selected or IS EQUAL to the value in LOW.
à If we set SIGN as 'E' (Exclusive), data other than the range/Value will be selected.

11) SELECTION-SCREEN POSITION:
    àThis is the statement used to control position of GUI fields at lower position or at higher position.                          
 à This must be used only between SELECTION-SCREEN BEGIN OF LINE ==== END OF LINE.   

Syntax: SELECTION-SCREEN POSITION <Pos.>.
        Where <Pos> is POS_LOW or POS_HIGH.
Ex:     DATA:    KUNNR LIKE KNA1-KUNNR,
          SELECT-OPTIONS CNO FOR KUNNR.
          SELECTION-SCREEN BEGIN OF LINE.
              SELECTION-SCREEN COMMENT 1(20) LB1.
              SELECTION-SCREEN POSITION POS_HIGH.
              PARAMETERS A TYPE I.
          SELECTION-SCREEN END OF LINE.  
  
         INITIALIZATION.
             LB1 = 'Customer name'.

4 comments:

  1. Great job on the sap abap blog. Thank you for sharing this type of blog.

    sap abap online training
    sap abap online course

    ReplyDelete
  2. The information provided here is of great use as I got to learn new things. Keep blogging.
    SAP ABAP TRAINING IN HYDERABAD

    ReplyDelete
  3. Looking for the best SAP ABAP Training in Bangalore, then don't delay join IntelliMindz SAP ABAP Training in Bangalore. Join our SAP ABAP training to get hands-on training and practice in SAP ABAP Software. Any Queries call @ 9655877677. IntelliMindz is the best IT Training Institute in Bangalore with placement, offering 200 and more software courses with 100% Placement Assistance.
    SAP ABAP Course in Bangalore
    SAP ABAP Course in Chennai
    SAP ABAP Online Course

    ReplyDelete