Файл: BC430_EN_Col62_FV_Part_A4_-_ABAP_Dictionary.pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 03.04.2021

Просмотров: 2294

Скачиваний: 40

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
background image

Unit 2: Data objects in the ABAP Dictionary

BC430

Solution 3: Table Types (Internal Tables /

ITABs)

Task:

Create simple internal tables on the basis of an existing structure, so that you
can use them later in ABAP programs.

1.

Create a table type

ZIT_SFLIGHT##

in the Dictionary. The table type

should be based on the line type of the database table

SFLIGHT

and be

sorted according to the flight date (

FLDATE

)

a)

In the SAP EASY ACCESS menu enter

se11

in the command field

and confirm your entry.

If you are in another transaction, you have to enter

/n se11

in the

command field and confirm the entry

b)

Select

Data Type

from the radio buttons.

c)

Enter the name of the table in the input field.

d)

Choose

Create

.

e)

In the subsequent dialog box, select

Table Type

.

f)

Assign a short description and enter the name of the database table in
the line type field.

g)

Switch to the

Initialization and Access

tab page and select

Sorted Table

as the access type.

h)

Switch to the

Key

tab page and select

Non-unique

as the key type.

i)

Now select the corresponding key component from

Key definition

,

Key

components

and the

Choose components

button.

j)

Activate the table so that it is globally known.

2.

Enter an ABAP program

ZBC430_##_ITAB_SORTED

. In this program,

create a structured data object (

wa_sflight

) of the type

SFLIGHT

as the

work area, and an internal table on the basis of the table type just defined.
From the SFLIGHT table, select the data of a carrier (e.g.

'JL'

) in the work

area and output this as an unsorted list.

a)

See the source code excerpt from the model solution.

3.

Extend the program as follows. Insert a line (ABAP command

ULINE

) in

the list. Load the same data again via the

SELECT

command with Array

Fetch into the internal table of the type

ZIT_SFLIGHT##

and output the

content of the table using the

LOOP

command in the same list. Compare the

order of the data in both list excerpts.

Continued on next page

38

© 2007 SAP AG. All rights reserved.

2006/Q2


background image

BC430

Lesson: Basic Data Types

a)

See the source code excerpt from the model solution.

Result

Source text excerpt:

SAPBC430S_ITAB_SORTED

REPORT SAPBC430S_ITAB_SORTED.

**Replace ## by Your group- or screennumber and

**uncomment the ABAP-coding

DATA it_flight TYPE zit_sflight##.

DATA wa_sflight TYPE sflight.

WRITE / 'Printout in tableorder of Database:'.

SELECT * FROM sflight

INTO

wa_sflight

WHERE

carrid = 'JL'.

WRITE: / wa_sflight-carrid,

wa_sflight-connid,

wa_sflight-fldate,

wa_sflight-price,

wa_sflight-currency,

wa_sflight-planetype.

ENDSELECT.

ULINE.

SELECT * FROM sflight

INTO

TABLE it_flight

WHERE

carrid = 'JL'.

WRITE / 'Printout in tableorder of sorted ITAB:'.

LOOP AT it_flight INTO wa_sflight.

WRITE: / wa_sflight-carrid,

wa_sflight-connid,

wa_sflight-fldate,

wa_sflight-price,

wa_sflight-currency,

wa_sflight-planetype.

ENDLOOP.

2006/Q2

© 2007 SAP AG. All rights reserved.

39


background image

Unit 2: Data objects in the ABAP Dictionary

BC430

40

© 2007 SAP AG. All rights reserved.

2006/Q2


background image

BC430

Lesson: Basic Data Types

Exercise 4: Deep Structures

Exercise Objectives

After completing this exercise, you will be able to:

Create deep structures and use them in ABAP programs

Business Example

You expand the structure of the personal data for your project team to such an
extent that you can incorporate a telephone list of any length you wish for each
employee.

Task:

Create an internal table based on a data object so that you can enter this in a
structure. Use this in an ABAP program.

1.

Create a table type for a standard table

ZIT_PHONE_NUMBER##

in the

Dictionary. The table type should be based on the line type of the existing
structure

STR_PHONE

.

2.

Extend your existing structure

ZPERSON##

in the Dictionary. The new

component should receive the name

PHONE

and be based on the internal

table

ZIT_PHONE_NUMBER##

.

3.

Create an ABAP program

ZBC430_##_STRUCT_DEEP

. To do this, copy

your solution for the program

ZBC430_##_STRUCT_NESTED

or the

model template

SAPBC430S_STRUCT_NESTED

. Extend this program

by one work area for a structured data object (

wa_phone

) of the type

STR_PHONE

.

4.

Extend the program as follows:

Insert three telephone numbers into the structured data object

wa_person

and output this data in the same list using the

LOOP

command.

2006/Q2

© 2007 SAP AG. All rights reserved.

41


background image

Unit 2: Data objects in the ABAP Dictionary

BC430

Solution 4: Deep Structures

Task:

Create an internal table based on a data object so that you can enter this in a
structure. Use this in an ABAP program.

1.

Create a table type for a standard table

ZIT_PHONE_NUMBER##

in the

Dictionary. The table type should be based on the line type of the existing
structure

STR_PHONE

.

a)

In the SAP EASY ACCESS, enter

se11

in the command field and

confirm your entry

If you are in another transaction, you have to enter

/n se11

in the

command field and confirm the entry.

b)

Select

Data Type

from the radio buttons.

c)

Enter the name of the table in the input field.

d)

Choose

Create

.

e)

In the subsequent dialog box, choose

Table Type

.

f)

Provide a short description and enter the name of the structure in the
line type field.

g)

Switch to the

Initialization and Access

tab page and choose

Standard

Table

as the access type.

h)

Switch to the

Key

tab page and choose

Non-unique

as key type.

i)

Now choose

Standard Key

as a

Key Definition

2.

Extend your existing structure

ZPERSON##

in the Dictionary. The new

component should receive the name

PHONE

and be based on the internal

table

ZIT_PHONE_NUMBER##

.

a)

Enter a new component with the name 'Phone' in your structure and
specify the newly created table type as component type.

Compo-
nent

Component Type

Description

.include

ZADRESS##

Address structure

NAME

ZNAME##

References the
name structure

PHONE

ZIT_PHONE_NUMBER##

References the
telephone table

Continued on next page

42

© 2007 SAP AG. All rights reserved.

2006/Q2