Файл: BC430_EN_Col62_FV_Part_A4_-_ABAP_Dictionary.pdf

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

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

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

Добавлен: 03.04.2021

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

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

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

BC430

Lesson: Basic Data Types

Solution 2: Simple and Nested Structures

Task 1:

Create simple structures that you can use later in ABAP programs.

1.

In the Dictionary, create a structure

ZNAME##

and include the following

two components in the structure. Use the data elements that you created in
previous exercises for typing.

Component

Component Type

Description

FIRSTNAME

own

first name

LASTNAME

own

last name

a)

Start SE11 and enter the name of the structure in the

Data type

input

field.

b)

Choose

Create

and select

Structure

in the following dialog.

c)

Provide a short description and enter the specified components.
Activate the structure so that it is globally known.

2.

Create a structure

ZADRESS##

and enter the four following components:

Component

Component Type

Description

STREET

S_STREET

Street

NR

S_NO

House number

ZIP

POSTCODE

Post code

CITY

S_CITY

Place of residence

a)

Proceed in the same way as in the previous part of the exercise.

Task 2:

Create a nested structure, so that you can use it later in ABAP programs.

1.

Create a structure

ZPERSON##

in the Dictionary.

a)

Proceed in the same way as in the previous part of the exercise.

Continued on next page

2006/Q2

© 2007 SAP AG. All rights reserved.

33


background image

Unit 2: Data objects in the ABAP Dictionary

BC430

2.

Add the structure

ZADRESS##

as an Include structure to the ZPERSON##

structure. In addition, take on the structure

ZNAME##

in the ZPERSON##

structure as a nested structure under the component name NAME

a)

Include the address either via the menu

Edit->Include->Insert

or, in the

Component

column, write the key word

.INCLUDE

.

Caution:

The point before the key word is important.

For the second structure, which you want to take on as a deep structure,
enter any component name (e.g. 'Name').

Component

Component Type

Description

.include

ZADRESS##

Address structure

NAME

ZNAME##

Refers to the name
structure

Continued on next page

34

© 2007 SAP AG. All rights reserved.

2006/Q2


background image

BC430

Lesson: Basic Data Types

3.

Enter an ABAP program

ZBC430_##_STRUCT_NESTED

. Create a

structured data object (

wa_person

) in this program of the type

ZPERSON##

.

Fill the components of this data object with any personal data and output
this data in a list.

a)

See the source code excerpt from the model solution.

Result

Source text excerpt:

SAPBC430S_STRUCT_NESTED

REPORT

sapbc430s_struct_nested.

*Replace ## by Your group- or screennumber and

*uncomment the ABAP-coding

DATA wa_person TYPE zperson##.

START-OF-SELECTION.

wa_person-name-firstname = 'Harry'.

wa_person-name-lastname = 'Potter'.

wa_person-street = 'Privet Drive'.

wa_person-nr = '3'.

wa_person-zip = 'GB-10889'.

wa_person-city = 'London'.

WRITE: /

wa_person-name-firstname ,

wa_person-name-lastname ,

wa_person-street ,

wa_person-nr ,

wa_person-zip ,

wa_person-city .

2006/Q2

© 2007 SAP AG. All rights reserved.

35


background image

Unit 2: Data objects in the ABAP Dictionary

BC430

36

© 2007 SAP AG. All rights reserved.

2006/Q2


background image

BC430

Lesson: Basic Data Types

Exercise 3: Table Types (Internal Tables /

ITABs)

Exercise Objectives

After completing this exercise, you will be able to:

Create table types and use them in ABAP programs

Business Example

For local data retention, you define a table type that keeps the data sorted.

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

)

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.

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.

2006/Q2

© 2007 SAP AG. All rights reserved.

37