ABAP Data Dictionary Transaction Code (TCODE): SE11, data dictionaries and SAP entire business applications are integrated.
This chapter mainly introduces: the example constructs the table, the data table maintains the procedure, adds the data, establishes the domain, the data element and the search Help, the logical database, the data table reads.
Related concepts
This chapter provides a clear understanding of the relationship between the ABAP data dictionary and the actual database. A data Dictionary object consists of a data field (Table field), a data element, a domain, and so on.
"Field" describes a field type and length information, and "Data element" describes the purpose of a field. Define the fields, define which fields the data elements use, and finally define which data elements to use for a table field.
Table type: Transparent table (Transparent table), Structure (Structure), additional structure (Append Structure), Storage table (pooled table), Cluster table (Cluster table), view (Generated View Structure).
Transparent tables and structures are used extensively in ABAP applications where: "Transparent tables" have corresponding physical tables in the database; "Structure" is a combination of several fields and no data records exist in the database.
Example Build table
The following example illustrates the establishment of a transparent table. The establishment of city tables, school tables, student tables, table relationships are one-to-many, the data structure is as follows:
(1) City table: Ytjaycity, structure as follows
Field name |
Data type |
Allow null values |
Primary/FOREIGN Key |
Description |
yct_id |
Int |
Not NULL |
(PK) |
Serial number |
Yct_name |
CHAR (30) |
Not NULL |
|
City Name |
Yct_country |
CHAR (255) |
|
|
Country name |
(2) School table: Ytjayschool, structure as follows
Field name |
Data type |
Allow null values |
Primary/FOREIGN Key |
Description |
yct_id |
Int |
Not NULL |
(PK) |
Serial number |
ysh_id |
Int |
Not NULL |
(PK) |
School serial number |
Ysh_name |
CHAR (30) |
Not NULL |
|
School Name |
Ysh_addr |
CHAR (255) |
|
|
Address |
(3) Student table: Ytjaystudent, structure as follows
Field name |
Data type |
Allow null values |
Primary/FOREIGN Key |
Description |
yct_id |
Int |
Not NULL |
(PK) |
City Serial Number |
ysh_id |
Int |
Not NULL |
(PK) |
School serial number |
ystu_id |
Int |
Not NULL |
(PK) |
Student number |
Ystu_name |
CHAR (30) |
|
|
Student Name |
Ystu_addr |
CHAR (255) |
|
|
Address |
Input TCODE:SE11, enter
Enter the database table and click the Create button
In the property page, enter a short text, select Type "A" (Application table), select "X Allow maintenance by standard table maintain tool"
Select the Fields page and click the button to enter the data type and length directly
Click "Save" button, pop Up "create Object Directory Entry" dialog box, click "Local Object" button
After the save is complete, click on "Technical settings" to define "data class", "Size category"
Click the Back button to return to the field edit page and click the Activate button to activate the datasheet.
The Ytjayschool and Ytjaystudent tables are then established in turn. Once the data table is established, you can log in to the database to view the established transparent tables.
Attention:
(1) The data tables created in SAP are built in the database;
(2) tables created directly in the database do not have a data dictionary in SAP;
(3) Adding data to SAP or a database can be accessed from each other.
With such a concept, it is possible to read database data in other languages, to do reports, development and other work.
Related Data Maintenance Program
Since the table was built, it was selected so that data maintenance could be done directly.
Input Tcode:se16
Enter table name
New data
Click on the "New" button below
Save after input is complete, click Back button to return to previous screen after adding records consecutively
Querying data
Click on the "Table content" button below
Enter the query criteria and click the "Execute" button
The query results are as follows:
Delete data
Menu "Table entry", "Delete all", "delete" button to delete the selected record
modifying data
Click the "Change" button below to edit and modify the selected record.
Generation and use of Data batch maintenance program
After opening the table structure maintenance interface (SE11), select Menu "Utilities"--"Table Maintenance Generator"
Enter the function group name, select a permission group, select the maintenance type "step", click the "Find Screen Number" button in the upper left corner
Select "Suggestion Screen number"
When processing is complete, click the New button in the upper-left corner
Popup "Modify Object Directory Entry" dialog box, click on the "Save" button, the lower left corner if the "Please select Package", then click the "Save" button
At this point, click the Local Objects button, and the environment will be generated in a few seconds
Now return to the main interface and enter "/NSM30" to maintain the data.
Enter the table/view name, click the Maintenance button
The dialog box appears, confirming
This interface allows for batch maintenance of tabular data
Establish domains, data elements, and search Help
This section describes the fields and data elements that establish the city ordinal and city names, and establishes search help. Search Help is one of the most common technologies in the SAP system and is very important.
Establish a domain
Enter TCODE:SE11, select "Domain", enter the field name, click "Create" button
Enter information such as field type, field length, etc. and click the "Save" button
Click on the "Local object" button, then click "Activate" button
The same method again establishes the city Name field, here slightly.
Building Data Elements
Select the data type option, enter a name, click Create
Select the "Data element" type
Select an already established domain name
Select the "Field Label" page, enter a description length and description, click the "Save" button, then click on the "Local object" button, and then click the "Activate" button
The same method again establishes the city name data element, here slightly.
Modifying table structures using data elements
Select Ytjaycity Data Sheet, click "Modify" button to enter the structure maintenance interface
Click the Data Element button, select the data element you just created, save it, and then activate
The same method to revise the school table
Build Search Help
Open the data element Ydajay_cityid, and after entering the "Search Help" name, save
Double-click the "Search Help" Name entry box to launch the design screen and click the "Yes" button
Select "Basic Index Help"
Enter a description, select City table, city serial number and name, where city serial number is input, Output field, double click Yct_name, establish city name parameter
Return to the previous interface, enter the parameter "yct_id", save and activate the data element
Then use SE16 to open the city table, you can select the city by "search Help"
Logical Database
Logical database is composed of tables with certain relationship, preselection sets the method of reading data.
Database read
Reading data tables is the most basic skill in programming, and the SQL syntax provided by different databases (Oracle,sql SERVER,SYBASE,DB2, etc.) is not exactly the same. SAP provides a set of SQL syntax (Open SQL) that enables SAP-supported databases to be processed through this set of SQL syntax in SAP applications. In addition, SAP also provides native SQL (local SQL statements) to handle the SQL syntax of the database itself. The SQL syntax of SAP is close to the standard SQL and consists of the common syntax of SELECT, INSERT, DELETE, update, and so on.
Basic reading data Table example
There are several ways and steps to read the database:
(1) Read data directly from the data table to the workspace output
(2) Read data from the data table to the inner table, and then output from the inner table
(3) Read data from the inner table row by line to the workspace, output from the work area
report ytest20160527.* defines the table in the workspace data a_ytjaycity type ytjaycity.* definition, note that there is a header Linedata ta_ytjaycity type table of Ytjaycity with HEADER line.* divider uline.write/' use workspace '. uline.* The data table to the workspace on a row-by-line basis, reading the first 3 lines of select * into corresponding fields of a_ytjaycity from ytjaycity up to 3 rows. WRITE:/a_ytjaycity-yct_id, A_ytjaycity-yct_name, A_ytjaycity-yct_country. Endselect. Uline. WRITE/' Use inner table '. Uline. SELECT * into corresponding fields of table ta_ytjaycity from ytjaycity up to 3 rows.* read data from the data table to the inner table, output directly from the inner table * If the ta_ytjaycity is not fixed Header line, the loop at Ta_ytjaycity will be faulted. WRITE:/ Ta_ytjaycity-yct_id,ta_ytjaycity-yct_name,ta_ytjaycity-yct_country. Endloop. Uline. WRITE/' transfer inner table data to workspace '. Uline. LOOP at Ta_ytjaycity to a_ytjaycity. WRITE:/ a_ytjaycity-yct_id, A_ytjaycity-yct_name, A_ytjaycity-yct_country. Endloop.
Output results
Reading data using the package size
In the example above, the first 3 rows are read using the up to 3 rows syntax, but the data cannot continue to be read.
The package size can be used to read several records at a time, and the following example has a Endselect statement that reads 2 records and then reads 2 records.
report ytest20160527.* definition inside table has HEADER linedata wa_ytjaycity TYPE Table of ytjaycity with header line.* to read 2 records each time, Until all data is read SELECT * into table wa_ytjaycity from ytjaycity package SIZE 2.* output internal table record LOOP at wa_ytjaycity. WRITE:/ wa_ytjaycity-yct_id, Wa_ytjaycity-yct_name, Wa_ytjaycity-yct_country. endloop.* Output 2 bar after output a horizontal line uline. Endselect.
Output results
internal and external connections
When you read data directly from two or more data tables, you need to use the inner table connection and the outer JOIN statement.
Report ytest20160527.* definition structure data:begin of SCHOOL, City TYPE ytjaycity-yct_name, NO TYPE ytjayschool-ysh_id , NAME type ytjayschool-ysh_name, ADDRESS type ytjayschool-ysh_addr,end of school.* workspace, data SCHOOL1 like SCHOOL. * Associated data table, read the first 3 records, write to the workspace, and output select Ytjaycity~yct_name ytjayschool~ysh_id ytjayschool~ysh_name ytjayschool~ysh_addr into SCHOOL1 from ytjayschool INNER joins ytjaycity on ytjayschool~yct_id = ytjaycity~yct_id up to 3 ROWS. WRITE:/school1-city, School1-no, School1-name, school1-address. Endselect.
Output results
ABAP data dictionary and data table read