2.1 Using parameters as input variables
The statement PARAMETERS (always plural) is a simple way to allow users to provide input to a report that is stored in a variable. Specify the name of the parameter, its type, and if you would like, a default value:
PARAMETERS pa_name type c length 12 DEFAULT 'HUGO'.
(In this example, we already used the type c for character which will be explained shortly, but yes: it is the type you expect it to be).
When you start the report, the system will display a simple input field with the given default value that you can overwrite, see Figure 2.1.
Figure 2.1: A parameter as an input variable
The parameter serves as an input field and as a variable.
Now let’s use the input variable to make our welcome greeting a bit more personal, introducing chain statements as well:
WRITE: 'Hello', pa_name.
A chain statement combines several statements that use the same keyword into one statement that will be applied to several data objects. It requires a colon after the keyword (here: WRITE), and a comma between the data objects that the keyword applies to.
Did you try your own name with some lower-case letters and find that they were displayed as upper-case letters? You can use the keyword addition lower-case for the PARAMETERS keyword to account for lower-case letters. Note that this is not a conversion to lower case, but the permission for lower-case letters (omit the conversion to upper case).
The user interface (UI) in Figure 2.1 shows the name of the input variable, which is not always understandable to the user. If you consider that the length of a parameter name is restricted to eight characters, you may want to include more meaningful text.
You can provide additional text for this variable by using the menu Goto • Text Elements • Selection Texts. Enter Your name for the selection text of PA_NAME, as shown in Figure 2.2.
Figure 2.2: Maintenance of text for a parameter variable
It is important to note that you have to activate the selection text in this view before returning to the coding of your report (by using F3).
If you chose to activate an object and you have more than one object in an inactive state, the system will display these objects in a list. This allows you to selectively activate some of the objects or all of them. In the following example, the report is inactive. When you activate the selection text, both objects are part of the list displayed: object REPS (S for source), and object REPT (T for text), see Figure 2.3.
Figure 2.3: List of inactive objects
List of inactive objects
At a later stage of your ABAP development practice, you may come across a situation where the list of inactive objects is also shown, although it looks as if you have just one inactive object. Check the tab Transportable Objects to look for additional inactive objects. The transport of development objects is introduced and explained in Section 3.2.
The advantage of a selection text is that this text can be translated into other languages. If you choose a different language during logon, your report will show the text for the parameter in that language (assuming that the text has been translated into that language).
Selection texts and selection screen
The parameter text is called selection text because it specifies the data selection. An advanced report that reads data from the database will have the following sequence: first the selection criteria have to be specified by the user (PARAMETERS statement), then the database access uses the selection criteria, and then the selected data is displayed to the user.
The display of the selection texts is called the selection screen. The selection screen is assigned to the internal screen number 1000 and is covered in more detail in Section 7.3.
- A PARAMETERS statement declares a local variable.
- At the beginning of the report, the selection screen displays an input field, so that the user can specify the value of the variable.
- The input field on the selection screen has a text label associated with it that can be translated.
Alle Inhalte. Mehr Informationen. Jetzt entdecken.
et.training - Ihre Lernplattform für SAP-Software
- Zugriff auf alle Lerninhalte1
- Regelmäßige Neuerscheinungen
- Intelligenter Suchalgorithmus
- Innovatives Leseerlebnis
- Maßgeschneidere Lernpfade
- Zertifikate & QA-Tests2
1 Sie erhalten Zugriff auf alle Lerninhalte. Online-Trainings, Zertifikate sind NICHT Teil der Flatrate.
2 Weitere Informationen auf Anfrage.