Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
AbapWB_content_EN.doc
Скачиваний:
1
Добавлен:
01.03.2025
Размер:
40.44 Mб
Скачать

127 Exercise 7: Working with Internal Tables

Exercise Duration: 30 Minutes

Exercise Objectives

After completing this exercise, you will be able to:

• Search for suitable table types in the ABAP Dictionary

• Define internal tables based on a global table type

• Fill internal tables using array fetch

• Process the content of internal tables using a loop

Business Example

You are to output flight dates stored in database table SPFLI in a list by using an internal table (as temporary storage).

System Data

System: Will be assigned Client: Will be assigned User ID: Will be assigned Password: Will be assigned

Set up instructions: No special instructions when using a standard training

system

Task 1:

Define internal table

1. Create the executable program ZBC400_##_ITAB_LOOP without a “TOP

include”.

2. Buffer the data from the database table SPFLI in an internal table. You should define an internal table with a line type that is compatible with the line structure of SPFLI.

In the ABAP Dictionary, search for all table types that match this condition.

Hint: Have the transparent table SPFLI displayed in the ABAP Dictionary. There, use the appropriate pushbutton to list the where-used list of SPFLI. (Pay attention to the correct selection when triggering the where-used list)

3. Define an internal table (name suggestion: it_spfli) based on one of the found global table types.

Continued on next page

4. Define a suitable work area for the internal table (name suggestion:

wa_spfli).

Task 2:

Fill and output the internal table

1. Program an array fetch access to all data records in the database table SPFLI

as follows:

SELECT * FROM spfli INTO TABLE it_spfli.

2. Use the LOOP statement to output the buffered data in the internal table in a list.

Solution 7: Working with Internal Tables

Task 1:

Define internal table

1. Create the executable program ZBC400_##_ITAB_LOOP without a “TOP

include”.

a) Carry out this step as usual.

2. Buffer the data from the database table SPFLI in an internal table. You should define an internal table with a line type that is compatible with the line structure of SPFLI.

In the ABAP Dictionary, search for all table types that match this condition.

Hint: Have the transparent table SPFLI displayed in the ABAP Dictionary. There, use the appropriate pushbutton to list the where-used list of SPFLI. (Pay attention to the correct selection when triggering the where-used list)

a) Carry out this step as described.

3. Define an internal table (name suggestion: it_spfli) based on one of the found global table types.

a) See source code excerpt in the model solution.

4. Define a suitable work area for the internal table (name suggestion:

wa_spfli).

a) See source code excerpt in the model solution.

Task 2:

Fill and output the internal table

1. Program an array fetch access to all data records in the database table SPFLI

as follows:

SELECT * FROM spfli INTO TABLE it_spfli.

a) See source code excerpt in the model solution.

Continued on next page

2. Use the LOOP statement to output the buffered data in the internal table in a list.

a) See source code excerpt in the model solution.

Result

Source code excerpt: SAPBC400TSS_ITAB_LOOP

REPORT sapbc400tss_itab_loop.

DATA it_spfli TYPE sbc400_t_spfli. DATA wa_spfli LIKE LINE OF it_spfli.

SELECT * FROM spfli INTO TABLE it_spfli.

* at least one dataset selected

IF sy-subrc = 0.