IS485

ABAP DATA DICTIONARY LAB

EKEDAHL

ABSTRACT

In this lab, you will learn the basics of the ABAP Dictionary and how to view table contents via the Data Browser. You will:

 View data from a table in the ABAP dictionary

 View tables and table metadata

 Learn about the structure of ABAP Dictionary tables (Fields, Data Elements, Domains)

 Understand the purpose of APPEND and INCLUDE structures

 Use the Currency and Quantity fields and understand their purpose and operation

TASK: VIEWING DATABASE TABLE DATA

In addition to using the various SAP screens to look at data, it’s possible to look at the contents of a table directly, similar to the way you would display a table’s contents in SQL Server Management Studio or Microsoft Access.

In this exercise you will work with the following two tables:

 The table named BKPF contains the accounting document header. Every financial accounting transaction has exactly one accounting document header record.

 The table named BSEG contains the transactional records for the above accounting documents. Each debit and credit entry that is part of an accounting document has a corresponding record in this table. There is a one-to-many relationship between the table BKPF and the table BSEG.

Table selection using the Data Browser is a two or three step process.

1. First, you select the table name,

2. Optionally, you define the fields that will be used a filters to select records.

3. Finally, you complete the various filters.

Note that SAP table names are not case sensitive.

Page 1 of 20 1. Using the menu path Tools / ABAP Workbench / Overview / Data Browser, or the transaction code SE16, start the Data Browser. The following figure shows the Data Browser: Initial screen.

2. Enter the table named BKPF. Note that you can also search for tables using many different criteria. The following screen might appear depending on past selections that you have made. If it does, select the fields shown in the following figure.

3. Click enter (the check mark) to display the following selection screen:

Page 2 of 20 The selection screen shown in the preceding figure allows you specify the criteria used in the search. By default, you can search for an inclusive range of values. The Multiple Selection button (right arrow) allows you to build more complex queries.

4. The prompts shown in the preceding figure are quite cryptic. Specifically, the ABAP Dictionary field names are shown, and these field names are typically German acronyms. You can display the field’s description if you want by clicking Settings / User Parameters on the menu bar to display the following figure:

5. Change the Keyword from Field Name to Field Label. Note that there are several other user specific settings. Accept the change and close the dialog box. The descriptive field prompts now appear instead of the actual field names. Note that these settings are made on a per user basis

Page 3 of 20 and are persistent from one SAP invocation to the next.

6. Enter the company code 0001 and the date range 1995 to 1998. Click Execute to select the corresponding accounting header records. Note that the company code 0001 is the default company code used throughout the SAP datasets. Using the ABAP dataset, the following two rows should appear. Note that the prompts you see might differ from the prompts shown in the figure depending on whether you reconfigured them in the preceding steps.

 The fields Client (MANDT), Company Code (BUKRS) , Document Number (BELNR), and Fiscal Year (GJAHR) form the primary key for the table. In other words, this is a composite key. Note that SAP uses composite keys for many different tables. This will become clearer in a moment when you begin to look at the table’s structure. The field Client and Company Code are foreign keys. The client field is linked to the table T000 and the field Company Code is linked to the table T001. This will become clearer when you begin looking at the Data Dictionary in more detail.

 Note that an accounting document has a document type. This document type is very important and classifies accounting documents. For example, the document type SA is a G/L posting

Page 4 of 20 document in the FI system.

 A business transaction type corresponds to a business task.

7. Select the first record by checking the check box in the first column. Click the Choose button to select all of the fields from the first record. As you can see, the accounting document header is quite complex and has 103 fields. Our goal here is not to try to understand the meaning and purpose of each field. Our goal is to be able to view a table, and to generally understand its purpose.

S

8. Click the Back button until you get to the Data Browser: Initial Screen. Now, on your own, take a look at the table named BSEG and again use the company code 0001. Use the date range 1995 to 1998

From the above screen, note the following:

Page 5 of 20  The primary key is again a composite key made up of the client, company code, document number, fiscal year, and line item.

 The posting key (40) indicates a debit, and the transaction key (50) indicates a credit. These posting keys are defined by SAP. It’s also possible to create custom posting keys.

9. Return to the SAP easy access menu

TASK: VIEWING A DATABASE TABLE SCHEMA:

In this task, you will use the ABAP Dictionary to start looking at the structure of a database table.

1. Using the menu path Tools / ABAP Workbench / Development / ABAP Dictionary, or the transaction code SE11, start the ABAP Dictionary. The following figure shows the ABAP Dictionary: Initial screen.

As shown in the above figure, you can select different kinds of database objects as described in the following list:

 Database tables are physical tables with rows and columns. Conceptually, these are the same tables with which you are accustomed.

 A View contains data from one or more tables. SAP supports different kinds of views, which will be discussed later. Conceptually, a view is the same as a query.

Page 6 of 20  A Data type supports three sub types. You can create Data Elements, which we will discuss today, structures, or table types, which will be discussed later in the course.

 Roughly speaking, a Type Group allows you to declare several data types at once through a type pool.

 A Domain defines the technical attributes of a field such as the data type or the number of positions in the field. Data types and fields are created from domains. If the data characteristics of the domain changes, then the data types of all Data Elements and fields will be changed automatically.

 Through Search help, you assign Help topics to screen fields. This help is activated when the user presses F4. Thus, the Help data is built in to the database via help metadata.

 Lock objects are used to synchronize simultaneous access to a table by multiple users. Lock objects will be discussed later in the course if time permits.

2. In the above dialog box, make sure that the Database table radio button is selected. Enter the table named BKPF, and then click Display to see the table fields. Note that the Fields tab is active when the dialog is first displayed. If you try to change the data type, you will not be able to do so because you do not have the correct access key. This is the access key required to change any and all SAP-created objects.

Page 7 of 20  The table is named BKFP and has the description “Accounting Document Header”. This description is part of the metadata for all fields. This table contains the accounting document header record. Note that the table named BSEG contains the line items corresponding to the accounting document header.

 The field name appears in the first column. Field names must be 16 characters or less in length, begin with a letter, and contain only letters, digits, or the underscore character. Note that most of the ABAP field names are 4 or 5 characters. Their names are part of a German derived acronym.

 The second column indicates whether the field is part of a key field. As shown in the above figure, the table has a composite key made up of four fields. Note that key fields must appear together at the beginning of the table. This is a unique SAP restriction.

 The third column depicts whether or not the field must have an initial value when created. Fields that are part of a key must have an initial value. Other fields can have a NULL value when a row is created. The implementation of NULL values will be discussed later when we get into data types in more detail.

Page 8 of 20  Fields can be created based on an existing data element (data type) or based on an ABAP Dictionary primary data type. Data elements and domains will be discussed in a moment.

 Every field has a data type and a length. Floating-point data types have a decimal places indicator, which is ignored for nonfloating-point data types. The decimal places indicator depicts the number of positions to the right of the decimal point.

 Finally, the field has a description.

TASK: VIEWING DOMAINS AND TECHNICAL SETTINGS

1. While the table BKPF is still displayed, click Technical Settings along the top of the screen to display the following dialog:

 Note that the table is Active and is therefore available for use. Like an ABAP program, a table must be activated before it can be used. The following figure shows the possible data classes:

Page 9 of 20  Note that the Data class is APPL1 indicating that the table contains transactional data. Selecting the correct table type is important to improve performance.

 Note that the Size category is set to 3, which defines the expected size of the table.

Page 10 of 20 2. Click the Back button to return to the table display.

 Tables, like ABAP programs, can be active and inactive. When a table is activated, it is copied from the ABAP dictionary to the actual database and becomes available for use.

 The Data class is only relevant when using the ORACLE and INFORMIX databases. It is used to define the physical area of the database where the table is stored. This is done for performance reasons. APPL0 is for master data, which is frequently read but not frequently updated. APPL1 is for transactional tables which are frequently updated. APPL2 is for customizing data, which changes rarely. Configuring these settings properly will significantly improve performance.

 The Size category is used to preallocate space for the table based on its expected size.

 The Buffering section and Buffering type are used to improve performance. While the complete details of buffering are beyond the scope of this course, buffering controls how data is read from a table. For example, when using full buffering, when a record is read from a table, the entire table is read into memory. Full buffering is useful for very small lookup tables.

 If Log data changes are enabled, then updates and deletes are written to a log table. The log table is named DBTABPRT.

Note the following from the DB-Specific properties column. Here you can see that there is support for column-wise tables (HANA).

Page 11 of 20 TASK: DISPLAYING INDEXES

In addition to primary keys, you can create indexes on a table called secondary indexes. If you often search for records on a particular field, then create a secondary index on that field to improve performance. The meaning of the term index in the context of the ABAP dictionary is the same as its meaning with other databases such as Access or SQL Server.

1. Display the indexes for the BKPF table by clicking Indexes… at the top of the screen. The following dialog box appears. Close the dialog box to return to the table display.

2. Close the dialog box to return to the table display.

 As you can see from the above figure, an index can be inactive or active just like other database objects.

 Information about the creator of the index is maintained.

 The index has a name that is derived from the table name and index number.

TASK: Introduction to APPEND and INCLUDE structures

SAP supplies additional database constructs beyond the traditional columnar table with which you are accustomed. These constructs are designed to improve the maintainability of tables as they are upgraded by both SAP and customers.

 APPEND structures are typically used to enhance standard SAP tables. For example, suppose that you needed to add one field to an existing SAP or customer table. By using an APPEND structure, changes made by SAP or other developers will be applied to the base table and the

Page 12 of 20 APPEND structure will continue to operate normally. A table can be enhanced using many APPEND structures.

 INCLUDE structure are primarily used to group fields together. INCLUDE structures can be used by many tables. If the INCLUDE structure is modified, then it will be updated accordingly in all of the tables that use the INCLUDE structure.

1. While the table BKPF is active, scroll down in the window until you see the following APPEND and INCLUDE structures:

 Note that the lines that follow the .APPEND structure appear in blue. These fields are part of the APPEND structure, rather than the table itself.

 Note that the above figure shows multiple .APPEND structures. A table can “append” as many structures as are needed.

Page 13 of 20  Note that the .INCLUDE structures also appear in blue. These .INCLUDE structures are part of the .APPEND structure than the table itself.

2. Double click the .APPEND structure named .ABKPF_PSO to display the following figure. You will learn more about the details of the APPEND structure later but for now, just understand that the fields shown in blue are part of the append structure. Note that, with restrictions, one APPEND STRUCTURE can contain another APPEND structure.

TASK: Introduction to Quantity and Currency fields

SAP implements two very unique data types beyond those implemented in most databases; Currency fields and Quantity fields. Each is discussed in turn. These two data types are characterized as reference fields which use reference tables. The idea of a reference field is best explained by an example.

Currency fields (those with a CURR data type) must also contain a reference table and reference field. It is this reference table that contains the currency key depicting the underlying currency. For example, the currency field might be expressed in Euros or U.S. dollars. The following figure shows the representation of the CURR data type:

Page 14 of 20  A field with a data type of CURR has an additional reference table and reference field within that table.

 The field in the reference table has a data type of CUKY (currency key), which is really a 5 character string.

1. Make sure that the table BSEG is active. Make sure that the Currency / Quantity Fields tab is active. Scroll down, as necessary until you see the field named DMBTR (Amount in local currency). This field represents the amount of the accounting transaction expressed in the local currency.

Page 15 of 20 2. Note that the field has a data type of CURR, the reference table is T001, and the reference field is WAERS. Double-click on the table named T001. The table named T001 is the Company codes table. The following figure shows the Company Codes table:

3. Note that the field named WAERS defines the currency key for the company. The data type of this field is CUKY (currency key)

4. Double-click on the field named WAERS. Note that the data type is CUKY and the length is 5 characters.

5. Click the Back button until you return to the accounting table.

Currency conversion is accomplished via a set of currency tables as follows:

Page 16 of 20  TCURC lists the possible currencies. A currency is made up of a currency code, and description (short text, long text). Note that SAP predefines nearly all of the world’s currencies.

 TCURR contains exchange rates as between currencies. A value will be converted from currency to currency using an exchange rate. Exchange rates are valid for a period of time. When performing currency conversions, the system automatically applies the correct exchange rate. Note that currency is exchange is a bit more complicated than discussed here but the above tables demonstrate the nuts and bolts of the process.

Quantity fields work similarly to currency fields. Simply put, SAP supports the conversion of quantities expressed in different units of measure. For example, you might express the weight of a shipment in either pounds or tons. The SAP system will convert values expressed in different units of measure to a common unit of measure. Understanding how this works requires that you take a look at a few SAP tables and understand a few key terms.

Page 17 of 20 The QUAN data type is defined in the ABAP dictionary for inclusion of a quantity in a specific unit. It is possible to use the units already defined by the ABAP Dictionary or to create new ones because the entire system is driven by various tables as follows:

To understand how SAP does unit conversions, you will explore the relevant tables involved in converting temperatures.

The table named T006D contains a list of dimensions based on the SI dimensions of physical quantities. These dimensions include such things as length, mass, volume, or weight to name a few. The following figure shows a segment of the T006D table. Note that the dimension TEMP has an SI unit of K, which means Kelvin.

The table named T006 is related to the table T006D. It contains the conversion factor of a dimension. For example, the following figure shows the table T006D for the TEMP (temperature) dimension.

The internal measurement units “K” represent kelvin, “C” and “GC” represent centigrade. And “FA” is Fahrenheit. Pay close attention to the conversion factors. Kelvin is the base unit because both the numerator and denominator are both one. To convert centigrade to kelvin, add 273.15. You can also see the formula to convert FA to K.

So, whenever you create a variable with a quantity data type, conversion can be perform on quantities having the same dimension.

Page 18 of 20 1. To understand this concept better, take a look at tables T006 and T006D using the dimension LENGTH. Try to understand how the conversion factors work between lengths. Note that there are 1000 M in one KM based on the numerator and denominator.

TASK: FOREIGN KEYS AND INPUT CHECKS

The concept of a foreign key is no different between SAP and other databases that you have used. That is, they define relationships between tables. Referring back to the accounting document header table BKPF, the field named BLART contains the accounting document types. Every financial accounting document has exactly one type and there are about 80 different types of accounting documents. These accounting document types control:

 In general, the document type defines the kind of business transaction. For example, a vendor payment is a document type.

 The number ranges for documents.

The goal here is not to understand everything about a document type. Rather, the goal is to provide a context for the idea of a check field

1. Activate the ABAP Dictionary for the table named BKPF. Again, this is the accounting document header table.

2. Click the Entry help/check tab.

3. Look closely at the field named BLART. Note that the check table is T003. This table contains the list of document types.

Page 19 of 20 4. Return to the SAP Easy Access Menu

Page 20 of 20