Unit 3 - Transparent tables in the ABAP Dictionary

Preview:

Citation preview

• In this lesson you will get an overview of data modeling, which has to be done before the application development. Furthermore, you will learn about the basic descriptive elements in the ABAP Dictionary.

•You will also find out when and why it is appropriate to use data types (data descriptions) from the ABAP Dictionary.

Lesson: Data Modeling and Descriptive Elements in theABAP Dictionary

Lesson Overview

•When you define data objects in your ABAP program, you should use the advantages of the ABAP Dictionary.

Business Example

• In the development of business application software, parts of the real world must be represented in data form.

•We refer to an Entity Relationship Model (ERM).

•You use this data model as the basis for implementing appropriate table definitions (transparent tables) including their relationships with each other in the ABAP Dictionary.

FlightSchedule

Flight

Airport

SalesOffice

TravelAgency

FlightBooking

City

City-AirportAssignment

FlightCustomer

Airline

Relational Data Model(FlightDataModel)

Working with the Object Navigator

•The flight data model contains entities for all business information that is logically connected, such as:

•Cities•Airports•Airlines•Flight routes•Flights• . . .

These entities all relate to each other in certain ways:•Each flight schedule contains exactly one airline, one departure airport,

and one destination airport.•Each bookable flight always belongs to exactly one existing flight

schedule.•Assignments can be set between cities and nearby airports.

MANDT CURRCODECARRID URLCARRNAME

SCARR

MANDT AIRPFROMCARRID AIRPTOCONNID

SPFLI

DEPTIME …

MANDT FLDATECARRID SEATSMAXCONNID

SPFLI

SEATSOCC …

MANDT FLDATECARRID BOOKIDCONNID

SPFLI

CUSTOMID COUNTER …

Implementation Using Transparent Tables

•For each entity fixed in the data model, the developer creates a transparent table in the ABAP Dictionary.

•This is merely a platform-independent description of a database table, not the database table itself.

•A transparent table contains different fields (columns) to allow you to store and manage data records in a structured way.

•You have to declare table fields as key fields when their content is to be used for the clear identification of data records.

•The key value of a data record is a unique ID within the table.

•Before we deal with the transparent table, we must first explain two other Dictionary terms: data element and domain.

Descriptive Elements in the ABAP Dictionary

•A data element is a total description of a field. This includes the semantic as well as the technical field attributes.

•The technical field attributes such as data type and field length are usually not specified in the actual data element but by means of a reference to a domain.

•Data elements can be used for defining program-internal variables or for describing fields of transparent tables.

Short Descriptions Short text for Airline

Documentation……

File IDAirline / Airline / …

Data TypeReference domain

S_CARR_ID

Search Help…

Data Elements S_CARR_ID

FormatCHAR 3

Value Range…

DOMAIN

Data Element and Domain.

• In the ABAP Dictionary, a transparent table is an implemented description of the corresponding database table that contains the actual application data.

Technical Structure of a Transparent Table

Transparent Table

Data Element

Field

Domain

Described by

Points to

•The fields of the transparent table form the identically-named columns of the corresponding database table.

•Usually, a structure in the ABAP Dictionary is used to centrally describe structure variables that are to contain the fields of various tables.

•You can then use these dictionary structures in the ABAP program to define data objects (concrete structure variables) that either serve as temporary data storage in the program or as an interface for the field transport between the screen and ABAP program.

•With structures however, we refer to component and component type as opposed to field and data element, it is posible to have a structure as the component of another structure.

•Such structures with included substructures as components are called complex structures. In contrast, structures with simple components are called flat.

Data Element

Structure Field

Table Field

Structure

Transparent Table

Using Dictionary Elements to Define Data Objects Within theProgram

•DATA mycarrid TYPE s_carr_id.Returns a data object (variable) of the type specified in the data element s_carr_id.

•DATA myconnid TYPE sbc400focc-connid.Returns a data object (variable) that has the same type as the structure field sbc400focc-connid.

•PARAMETERS pa_carr TYPE spfli-carrid.Returns an input field on the selection screen as well as a variable that has the same type as the table field spfli-carrid.

The definitions in the above graphic have the following meaning:

•DATA wa_focc TYPE sbc400focc.Returns a structure variable that has the same type as the dictionary structure sbc400focc.

•DATA wa_spfli TYPE spfli.Returns a structure variable which has the same type as a line of the table spfli.

•Domain describes the technical attributes such as data type and length of a table field.

•Data Element gives the field labels and documentation for the table field.

Domain

•Create your first table•Enter data into your table•View the data in your table

Procedure: Creating Tables

You should now be able to:•Explain the purpose and the benefits of using a data model in application

development•Describe the structure of data elements and domains•Describe the structure of a transparent table•Describe the structure of a structure•Use the mentioned Dictionary elements in your ABAP programs

Your assignment is to:

•Create a relational data model for an airline company that needs to store data from the passengers such as Name, ID, Address and Flight ; data from the flights such as ID, Origin and Destination; and data from the airline company such as ID, Airline Name and Flight numbers assigned to it.

•Create transparent tables in the ABAP Dictionary to represent your relational model.

Unit 3: Case Study – Airline Relational Data Model

ZTPassengers – Passengers

Pass_ID Name Address Flight_ID

ZTFlight – Flight Information

Flight_ID Origin Destination Pass_ID

ZTAirline – Airline

Air_ID Name Flight_ID

•ONE Airline can have MANY Flights (1-N)•ONE Passenger can have MANY Flights

ONE Flight can have MANY Passengers

Flight Information Relational Data Model3 Transparent Tables

Flight Information Relational Data Model

Recommended