Friday 12 July 2013

JULY 12


On ninth day I was taught about further details for "PARAMETERS " statement and various additions that can be used with it along with an example to implement it.

The following points also apply to the parameters statement :

  • The default data type is c (character).
  • The default value is 0, except for data type c, which is blank.
  • The value addition accepts a literal, a sy variable, or a variable previously defined in the program.
  • When using the like addition, the parameter being defined obtains its length and data type from the referenced variable. we cannot specify them on the same statement with like.
  • When using the like addition, the value is not obtained from the referenced variable. we can specify the value addition to give the parameter a default value. If we do not, it is assigned a default initial value of 0 (or blank for a character data type).
  • Like data, the parameters statement can appear anywhere in a program, but the definition must physically come before the statements that access it.
  • Parameters appear on a selection screen in the same order that they are defined in the program.
  • All parameters statements, no matter where they appear in the program, are collected together by the ABAP/4 interpreter and displayed on the selection screen at the same time. Even if we put a parameter statement in the middle of the program, that parameter will still be displayed on the selection screen before the program executes.
  • The parameters are displayed in an SAP standard format. To modify their appearance, for example, to move the input field left or move the label right, the selection-screen statement is uesd.

VARIOUS ADDITIONS WITH "PARAMETER" STATEMENTS ARE:

Using the Addition: lower case

All values entered into a parameter are translated into uppercase by default. To turn off this translation, use the addition lower case. This addition only applies to character fields.

Using the Addition: as checkbox

A check box has only two states: ticked and clear. we use them when we want to present the user with an on/off or true/false type of choice. we can use more than one check box on a screen. If we have multiple check boxes on a screen, they operate completely independently from each another.
To display a parameter as a check box, use the addition as checkbox. we cannot specify a data type or length; it will default to type c and length 1. The parameter will contain a capital X if the check box is ticked; it will contain a blank if the check box is clear. If the check box should initially contain a tickmark, use a default value of capital X.
Space and capital X are the only valid values. No other values are valid for a check box.

Using the Addition: radiobutton group g

Like check boxes, a radio button also has two states: selected and not selected. Unlike check boxes, radio buttons never operate alone, they operate only in groups. we can have any number of radio buttons in a group, but only one can be selected at a time. They are used when we need to present the user with a list of alternatives in which only one option can be chosen.
To display a parameter as a radio button, use the addition radiobutton group g. we cannot specify a data type or length; it will default to type c and length 1g is an arbitrary group name one to four characters long. we can have more than one group in a program.
The parameter will contain a capital X if the radio button is selected; it will contain a blank if it is not selected. To be initially selected, the radio button should contain a default value of capital X. No other values are valid for a radio button.
The additions to the parameters statement are described in short in the following table:

  Additions to the PARAMETERS Statement and Their Uses

Addition
Use
typeSame as the data statement.
DecimalsSame as the data statement.
LikeSame as the data statement.
DefaultSame as the value addition on the data statement.
ObligatoryThe user must enter a value into the field before the program will execute.
lower casePrevents values from being translated into uppercase.
as checkboxDisplays the input field as a check box.
Radiobutton groupgDisplays the input field as a radio button belonging to group g.
A sample program using parameters and to implement the above additions is given below.


 report ztx0706.
  parameters: p1(15) type c,
             p2  like p1 obligatory lower case,
              p3  like sy-datum default sy-datum,
              cb1 as checkbox,
              cb2 as checkbox,
              rb1 radiobutton group g1 default 'X',
              rb2 radiobutton group g1,
              rb3 radiobutton group g1.
  write: / 'You entered:',
         / '  p1 =', p1,
         / '  p2 =', p2,
         / '  p3 =', p3,
         / '  cb1=', cb1,
         / '  cb2=', cb2,
         / '  rb1=', rb1,
         / '  rb2=', rb2,
         / '  rb3=', rb3.

The OUTPUT generated by the above program is:





When the selection screen is shown, obligatory fields contain a question mark. These indicate to the user which fields must be filled in before continuing.