Basic Form of Selection Criteria

Một phần của tài liệu BC ABAP Programming PHẦN 5 potx (Trang 108 - 113)

Basic Form of Selection Criteria

You use the SELECT-OPTIONS statement to declare selection tables [Page 719] and create corresponding input fields on the associated selection screen. You can modify the associated text as selection text [Extern]. When the selection screen is processed, the values entered by the user into the input fields are assigned to the header line of the selection table and appended to the table. The position of the statement in the declaration part of the program determines the selection screen to which the input fields belong.

The basic form of the SELECT-OPTIONS statement is as follows:

SELECT-OPTIONS <seltab> FOR <f>.

It declares a selection criterion <seltab> that is linked to a field <f> that has already been declared locally in the program. The names of selection criteria are currently restricted to eight characters. Valid data types of <f> include all elementary ABAP types except data type F. You cannot use data type F, references and aggregate types. If you want to use the selection criterion to restrict database selections, it is a good idea to declare <f> with reference to a column of the corresponding database table. It then inherits all of the attributes of the data type already defined in the ABAP Dictionary. In particular, the field help (F1) and the possible entries help (F4)

defined for these fields in the Dictionary are available to the user on the selection screen.

The selection table, which has the same name as the selection criterion, <seltab>, is usually filled by the user on the selection screen or by calling programs. You can also process the selection table like any other internal table [Page 252] in the program.

REPORT DEMO.

DATA WA_CARRID TYPE SPFLI-CARRID.

SELECT-OPTIONS AIRLINE FOR WA_CARRID.

LOOP AT AIRLINE.

WRITE: / 'SIGN:', AIRLINE-SIGN, 'OPTION:', AIRLINE-OPTION, 'LOW:', AIRLINE-LOW, 'HIGH:', AIRLINE-HIGH.

ENDLOOP.

After the executable program DEMO has been started, the following standard selection screen appears:

AIRLINE to

Two input fields and a pushbutton to enter additional values for the selection criterion are displayed. The value that the user enters into the first input field is written into the AIRLINE-LOW component of the selection table. The value that the user enters into the second input field is written into the AIRLINE-HIGH component of the selection table.

If the user enters values as shown below:

AIRLINE AA to

The output appears as follows:

SIGN: I OPTION: EQ LOW: AA HIGH:

If the user leaves the second field blank (single field comparison), the default settings for SIGN and OPTION are I and EQ.

If the user enters values as shown below:

AIRLINE AA to LH

The output appears as follows:

SIGN: I OPTION: BT LOW: AA HIGH: LH

If the user enters a value in the second field (ranges selection), the default settings for SIGN and OPTION are I and BT.

To set up a more complex selection pattern, the user can choose the

pushbutton on the right side of the selection screen to display the Multiple Selection window and enter the following values:

Single vals Ranges Singlevals Ranges AA

AF

Multiple Selection for AIRLINE

Copy

and:

Basic Form of Selection Criteria

Single vals Ranges Single vals Ranges To

To To To To

DL LH

Multiple Selection for AIRLINE

Copy

SA UA

If the user adopts the multiple selection, the arrow on the selection screen turns green to indicate that multiple selections have been entered.

The output is:

SIGN: I OPTION: EQ LOW: AA HIGH:

SIGN: I OPTION: EQ LOW: AF HIGH:

SIGN: I OPTION: BT LOW: DL HIGH: LH SIGN: I OPTION: BT LOW: SA HIGH: UA

Using a multiple selection means to append several rows to a selection table.

The user can also specify exclusive criteria as multiple selections:

Single vals Ranges Single vals Ranges FC

Multiple Selection for AIRLINE

Copy

and:

Single vals Single vals Ranges To To To To To

SQ SR

Multiple Selection for AIRLINE

Copy

Ranges

The output is:

SIGN: E OPTION: EQ LOW: FC HIGH:

SIGN: E OPTION: BT LOW: SQ HIGH: SR

If exclusive criteria are used, the SIGN component of the selection table contains value E.

To explicitly set the SIGN and OPTION values, the user must select the input fields on the selection screen or the Multiple Selection screen either by double-clicking them or by choosing F2.

Select by initial value AIRLINE

= Single value

Not equal to Less than Greater than

Less than or equal to Greater than or equal to

>

<

Select

On the Maintain Selection Options screen that, for single field comparisons, looks like this, the user can select an operator for the OPTION field and switch between I and E for the SIGN field in the lowest line. On the selection screen, symbols on the left side of the input field are used to indicate the selection.

Basic Form of Selection Criteria

AIRLINE AA to

These symbols are green to show that the SIGN field has value I. If the SIGN field has value E, the symbols are red.

In this case, the list appears as follows:

SIGN: E OPTION: GE LOW: AA HIGH:

Một phần của tài liệu BC ABAP Programming PHẦN 5 potx (Trang 108 - 113)

Tải bản đầy đủ (PDF)

(153 trang)