ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 03.04.2021
Просмотров: 2356
Скачиваний: 41
BC430
Lesson: Basic Data Types
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
.
a)
See the source code excerpt from the model solution.
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.
a)
See the source code excerpt from the model solution.
Result
Source text excerpt:
SAPBC430S_STRUCT_DEEP
REPORT
sapbc430s_struct_deep.
DATA wa_person TYPE zperson##.
DATA wa_phone
TYPE str_phone.
START-OF-SELECTION.
*Fill deep structure with data
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'.
wa_phone-p_type = 'P'.
wa_phone-p_number = '+31-10-9938990'.
INSERT wa_phone INTO TABLE wa_person-phone.
wa_phone-p_type = 'F'.
wa_phone-p_number = '+31-10-9938991'.
INSERT wa_phone INTO TABLE wa_person-phone.
wa_phone-p_type = 'M'.
wa_phone-p_number = '+31-79-12211433'.
INSERT wa_phone INTO TABLE wa_person-phone.
Continued on next page
2006/Q2
© 2007 SAP AG. All rights reserved.
43
Unit 2: Data objects in the ABAP Dictionary
BC430
*Write on List
WRITE: /
wa_person-name-firstname ,
wa_person-name-lastname ,
wa_person-street ,
wa_person-nr ,
wa_person-zip ,
wa_person-city .
WRITE: / 'Phone-Numbers:'.
LOOP AT wa_person-phone INTO wa_phone.
WRITE:
AT 20 wa_phone-p_type,
wa_phone-p_number.
NEW-LINE.
ENDLOOP.
44
© 2007 SAP AG. All rights reserved.
2006/Q2
BC430
Lesson: Basic Data Types
Lesson Summary
You should now be able to:
•
Create domains and use them in data elements
•
Define data elements and use them as the basis for defining data objects
in ABAP programs
•
Define structures and use them as the basis for defining data objects in
ABAP programs
•
Define internal tables and use them as the basis for defining data objects
in ABAP programs
•
Define complex (nested / deep) structures and use them as the basis for
defining data objects in ABAP programs
•
Define global constants with the help of a type pool and use them in ABAP
programs
2006/Q2
© 2007 SAP AG. All rights reserved.
45
Unit 2: Data objects in the ABAP Dictionary
BC430
Lesson: Tables in the ABAP Dictionary
Lesson Overview
Lesson Objectives
After completing this lesson, you will be able to:
•
Create Tables
•
Use the two-level domain concept
•
Define the technical settings of a table
•
Create and use include structures
Business Example
You should map information units, so-called entities in the database for your
company.
Tables
Figure 16: Tables and Fields
The structure of the objects of application development are mapped in tables
on the underlying relational database.
The attributes of these objects correspond to fields of the table.
46
© 2007 SAP AG. All rights reserved.
2006/Q2
BC430
Lesson: Tables in the ABAP Dictionary
A table consists of columns (fields) and rows (entries). It has a name and different
general attributes, such as delivery class and maintenance authorization.
A field has a unique name and attributes; for example, it can be a key field.
A table has one or more key fields, called the primary key.
The values of these key fields uniquely identify a table entry.
You must specify a reference table for fields containing a currency (data type
CURR) or quantity (data type QUAN). It must contain a field (reference field)
with the format for currency keys (data type CUKY) or the format for units (data
type UNIT). The field is only assigned to the reference field at program runtime.
Figure 17: Basic Objects of the ABAP Dictionary
The basic objects for defining data in the ABAP Dictionary are tables, data
elements and domains. The domain is used for the technical definition of a table
field (for example, field type and length) and the data element is used for the
semantic definition (for example short description).
A
domain
describes the value range of a field by its data type and length. The
value range can be limited by specifying fixed values.
A
data element
describes the meaning of a domain in a certain business context.
The data element contains primarily the field help (F1 documentation) and the
field labels in the screen.
A field is not an independent object, but it is table-dependent. The field can only
be maintained within a table.
You can enter the data type and number of places directly for a field. No data
element is required in this case. Instead, the data type and number of places is
defined by specifying a
direct type
.
2006/Q2
© 2007 SAP AG. All rights reserved.
47