Day 3

The Data Dictionary, Part 1


Chapter Objectives

After you complete this chapter, you should be able to:

Discovering R/3 Release Levels

There are many versions-also called release levels-of the R/3 system in use today. Release 3.0 was the first version, but since its introduction, SAP has also released versions 3.0a through 3.0f, 3.1g, 3.1h, and 4.0a through 4.0c. You can determine the release level of your system using the menu path System->Status.

This book was tested on a 3.0f system. Your system may be on another release level. Although most of the differences should be minor with regard to the topics covered here, some differences may cause confusion or cause the information in this book to appear incorrect. For example, menu paths can change between release levels. Wherever possible, differences that may cause confusion have been noted in this text. However, if the functionality in your system appears to differ from that described here, you can consult the R/3 release notes, available online, to determine if the difference can be attributed to the release level. To access the release notes, use the following procedure:

Start the ScreenCam "How to Display R/3 Release Notes" now.

To display the R/3 release notes:

  1. Go to the main menu and choose the menu path Tools->Find->Search Interface. The Search Interface: Request screen appears.
  2. Choose the radio button RELN.
  3. Press the Choose button on the Application toolbar. The Find Release Notes screen is displayed.
  4. Press the Complete List button. The Display Structure: Complete List of Release Notes screen is displayed.
  5. Click on any + (plus sign) to expand the node. Modifications To ABAP will appear under the Basis node, under the sub-node ABAP/4 Development Workbench.

Delving Deeper into the R/3 Data Dictionary

As a review, please take a few minutes and re-read the section in Day 2 titled "Introducing the R/3 Data Dictionary" at this time.

Data Dictionary objects are used in most ABAP/4 programs. The interlocking nature of ABAP/4 programs and DDIC objects makes in-depth knowledge of the R/3 Data Dictionary an essential programming skill. Therefore, beginning with this chapter, you will learn how to create DDIC objects such as tables, data elements, and domains.

NOTE
Many development objects used as examples throughout this book (such as tables, domains, and data elements) are based on actual development objects in the R/3 system. The example objects will have the same name as the actual R/3 objects, but they will be prefixed with ztx. For example, lfa1 is a real table in R/3, and the example table in this book is ztxlfa1.

Exploring the Types of Tables in R/3

In R/3 there are three table types: transparent tables, pooled tables, and cluster tables. They are shown in Figure 3.1.

Figure 3.1 : The three table types in the R/3 Data Dictionary.

Transparent Tables

A transparent table in the dictionary has a one-to-one relationship with a table in the database. Its structure in R/3 Data Dictionary corresponds to a single database table. For each transparent table definition in the dictionary, there is one associated table in the database. The database table has the same name, the same number of fields, and the fields have the same names as the R/3 table definition. When looking at the definition of an R/3 transparent table, it might seem like you are looking at the database table itself.

Transparent tables are much more common than pooled or cluster tables. They are used to hold application data. Application data is the master data or transaction data used by an application. An example of master data is the table of vendors (called vendor master data), or the table of customers (called customer master data). An example of transaction data is the orders placed by the customers, or the orders sent to the vendors.

Transparent tables are probably the only type of table you will ever create. Pooled and cluster tables are not usually used to hold application data but instead hold system data, such as system configuration information, or historical and statistical data.

Both pooled and cluster tables have many-to-one relationships with database tables. Both can appear as many tables in R/3, but they are stored as a single table in the database. The database table has a different name, different number of fields, and different field names than the R/3 table. The difference between the two types lies in the characteristics of the data they hold, and will be explained in the following sections.

Table Pools and Pooled Tables

A pooled table in R/3 has a many-to-one relationship with a table in the database (see Figures 3.1 and 3.2). For one table in the database, there are many tables in the R/3 Data Dictionary. The table in the database has a different name than the tables in the DDIC, it has a different number of fields, and the fields have different names as well. Pooled tables are an SAP proprietary construct.

When you look at a pooled table in R/3, you see a description of a table. However, in the database, it is stored along with other pooled tables in a single table called a table pool. A table pool is a database table with a special structure that enables the data of many R/3 tables to be stored within it. It can only hold pooled tables.

R/3 uses table pools to hold a large number (tens to thousands) of very small tables (about 10 to 100 rows each). Table pools reduce the amount of database resources needed when many small tables have to be open at the same time. SAP uses them for system data. You might create a table pool if you need to create hundreds of small tables that each hold only a few rows of data. To implement these small tables as pooled tables, you first create the definition of a table pool in R/3 to hold them all. When activated, an associated single table (the table pool) will be created in the database. You can then define pooled tables within R/3 and assign them all to your table pool (see Figure 3.2).

Figure 3.2 : Pooled tables have a many-to-one relationship with table pools.

Pooled tables are primarily used by SAP to hold customizing data.

When a corporation installs any large system, the system is usually customized in some way to meet the unique needs of the corporation. In R/3, such customization is done via customizing tables. Customizing tables contain codes, field validations, number ranges, and parameters that change the way the R/3 applications behave.

Some examples of data contained in customizing tables are country codes, region (state or province) codes, reconciliation account numbers, exchange rates, depreciation methods, and pricing conditions. Even screen flows, field validations, and individual field attributes are sometimes table-driven via settings in customizing tables.

During the initial implementation of the system the data in the customizing tables is set up by a functional analyst. He or she will usually have experience relating to the business area being implemented and extensive training in the configuration of an R/3 system.

Table Clusters and Cluster Tables

A cluster table is similar to a pooled table. It has a many-to-one relationship with a table in the database. Many cluster tables are stored in a single table in the database called a table cluster.

A table cluster is similar to a table pool. It holds many tables within it. The tables it holds are all cluster tables.

Like pooled tables, cluster tables are another proprietary SAP construct. They are used to hold data from a few (approximately 2 to 10) very large tables. They would be used when these tables have a part of their primary keys in common, and if the data in these tables are all accessed simultaneously. The data is stored logically as shown in Figure 3.3.

Figure 3.3 : Table clusters store data from several tables based on the primary key fields that they have in common.

Table clusters contain fewer tables than table pools and, unlike table pools, the primary key of each table within the table cluster begins with the same field or fields. Rows from the cluster tables are combined into a single row in the table cluster. The rows are combined based on the part of the primary key they have in common. Thus, when a row is read from any one of the tables in the cluster, all related rows in all cluster tables are also retrieved, but only a single I/O is needed.

A cluster is advantageous in the case where data is accessed from multiple tables simultaneously and those tables have at least one of their primary key fields in common. Cluster tables reduce the number of database reads and thereby improve performance.

For example, as shown in Figure 3.4, the first four primary key fields in cdhdr and cdpos are identical. They become the primary key for the table cluster with the addition of a standard system field pageno to ensure that each row is unique.

Figure 3.4 : The cdhdr and cdpos tables have the first four primary key fields in common and are always accessed together and so are stored in the table cluster cdcls.

As another example, assume the data from order header and order item tables is always needed at the same time and both have a primary key that begins with the order number. Both the header and items could be stored in a single cluster table because the first field of their primary keys is the same. When implemented as a cluster, if a header row is read, all item rows for it are also read because they are all stored in a single row in the table cluster. If a single item is read, the header and all items will also be read because they are stored in a single row.

Restrictions on Pooled and Cluster Tables

Pooled and cluster tables are usually used only by SAP and not used by customers, probably because of the proprietary format of these tables within the database and because of technical restrictions placed upon their use within ABAP/4 programs. On a pooled or cluster table:

CAUTION
The use of pooled and cluster tables can prevent your company from using third-party reporting tools to their fullest extent if they directly read data-base tables because pooled and cluster tables have an SAP proprietary for-mat. If your company wants to use such third-party tools, you may want to seek alternatives before creating pooled or cluster tables.

Because of these restrictions on pooled and cluster tables and because of their limited usefulness, this book concentrates on the creation and use of transparent tables. The creation of pooled and cluster tables is not covered.

Exploring Table Components

You now know what transparent tables are, and the differences between transparent, pooled, and cluster tables. You will now learn the components that are needed to create tables.

A table is composed of fields. To create a field you need a data element. The data element contains the field labels and online documentation (also called F1 help) for the field. It is purely descriptive; it contains the semantic characteristics for the field, also known as the "business context." The labels you provide within a data element will be displayed on the screen beside an input field. The data element also contains documentation that is displayed when the user asks for help on that field by pressing the
F1 key.

A data element's definition requires a domain (see Figure 3.5). The domain contains the technical characteristics of a field, such as the field length and data type.

Figure 3.5 : Tables are composed of fields that are composed of data elements, which, in turn, are composed of domains.

Domains and data elements are reusable. A domain can be used in more than one data element, and a data element can be used in more than one field and in more than one table.

For example, assume you need to design a customer information table called zcust that must contain work, fax, and home telephone numbers (see Figure 3.6).

Figure 3.6 : A design example using tables, data elements, and domains.

To create a field, you usually start by creating a domain for it. In this case, you might create a generic telephone number domain, name it zphone and give it a data type of CHAR and a length of 12. This would be a generic telephone number domain; most types of telephone numbers could be stored using this domain. As such, it can be used to define specific types of telephone numbers, such as fax or home telephone numbers.

After creating the domain to hold the purely technical description of a field, you then create a data element to hold the descriptive attributes of the field. In the data element you must enter the name of a domain to give it technical characteristics. Then, you enter the labels and documentation (F1 help) to describe the data you will store. In this example, you would probably create three data elements, one for each of the home, work, and fax telephone numbers. In each data element, you would enter field labels describing the type of telephone number you will store with it, and the F1 help for the end-user.

Having created the data elements, you can now create the table. You could create three phone number fields in the table (home, work, and fax) and assign the corresponding data element to each field. A data element is assigned to each field. This gives the field descriptive information from the data element and technical information from the domain that it references. When the field is used on a screen, it obtains a label and F1 help documentation from the data element, and its length and data type form the domain within the data element.

In another example, you might need to store a person's name in three different tables: customer, vendor, and employee tables. In the customer table you want to store a customer name, in the vendor table a vendor name, and in the employee table an employee name. Because it is a good idea to give the same data type and length to all person-name fields, you can create a single generic person-name domain, for example zpersname. Then you can create a data element for each business usage of a person's name: for the customer name, the vendor name, and the employee name. Within each data element you refer to your zpersname domain to give them all the same characteristics. You could then use these data elements to create fields within each table.

Maintaining Technical Characteristics of Fields

If you need to change the length of the field after you have created a table, you only need to change it in the domain. If the domain is used in more than one table, the change is automatically propagated to all fields that use that domain.

For example, if the business analysts requested that you increase the length of your person name field from 12 to 15 characters, you would change the length in the zpersname domain. When you activate your change, the lengths of all name fields based upon this domain (in the customer, vendor, and employee tables) will also change.

Determining When to Create or Reuse Domains and Data Elements

Each R/3 system comes with more than 13,000 preexisting domains created by SAP. When you create a new field, you must decide whether to create a new domain or reuse an existing one. To make this decision, determine whether the data type or length of your field should be dependent on an existing SAP field. If your field should be independent, create a new domain. If your field should be dependent, reuse an existing SAP domain. Similarly, you should reuse data elements if your field labels and documentation should change when SAP changes theirs.

For example, assume you wish to create a new table to contain additional vendor information. When you design the table, you must associate the vendors in your table to those in the SAP table.

In your table, create a primary key containing the vendor number. Use the existing data element to create your field. Both tables are now keyed on the SAP vendor number field using the same data elements and domains. If SAP changes the data type or length of their field, yours will change automatically.

Naming Conventions for Tables and Their Components

Tables, data elements, and domains created at the customer site must follow SAP naming conventions for customer objects. These are outlined in Table 3.1.

Table 3.1  Naming Conventions for Tables, Fields, Data Elements, and Domains created by the Customer
Object Type
Max Name Length
Allowed First Character
Table
10
y, z
Data element
10
y, z
Domain
10
y, z
Field
10
Any character

All names are a maximum of 10 characters long.

The names of all tables, domains, and data elements you create must start with the character y or z. You cannot use any other character at the beginning; all others are reserved by SAP. The R/3 system enforces this convention; you will get an error message if you try to create an object having a name that doesn't conform to these conventions.

Field names can begin with any character. However, certain words are reserved and cannot be used as field names. The DDIC table trese contains the complete list of reserved words. The contents of trese can be displayed using the Day 2 procedure in the section titled "Displaying Data in the Table."

Creating a Transparent Table and Its Components

In the following sections, you will create domains, data elements, and finally, your first transparent table-it will be a scaled-down version of the SAP-supplied vendor master table named lfa1.

NOTE
For the purposes of this book, please assume that the R/3 system doesn't already store any vendor master information. Assume that table lfa1 does not exist, nor do its data elements or its domains. Therefore, in these exercises we will create them.

To store vendor master information you will create table -lfa1. It will contain fields for a vendor number, a name, a region code, and a country code. The field names and technical characteristics you will use are shown in Table 3.2. An x in the PK column indicates fields that form the primary key. (The install procedure created a table named ztxlfa1 in your R/3 system. It is very similar to the -lfa1 table. Use it as a reference while reading this chapter.)

Table 3.2  Fields and Their Characteristics for Table -LFA1
Field Name
PK
DE Name
DM Name
Data Type
Length
mandt
x
mandt
 
 
 
lifnr
x
-lifnr
-lifnr
CHAR
10
name1
 
-name1
-name
CHAR
35
regio
 
-regio
-regio
CHAR
3
land1
 
-land1
-land1
CHAR
3

These field names and their technical characteristics are based on actual fields of table lfa1.

NOTE
Don't change the names shown above. The exercises later in this book rely on these field names as shown. If you don't use these exact names, subsequent exercises may not work.

Since this table contains application data, it should be client-dependent. Therefore, the first field must be mandt. (See Chapter 1 if you need to review client dependent tables.)

Approaches for Creating Tables

There are two approaches you can use when creating tables:

In the bottom-up approach, you create the domains first, then the data elements, and then the table.

In the top-down approach, you create the table first, and then create the data elements and domains as you go along.

The bottom-up approach is more intuitive for the first-time student, but it quickly becomes cumbersome. The top-down approach is much easier to use after you become somewhat familiar with the table creation process. For these reasons, I will demonstrate both techniques, starting with bottom-up.

As you read the following sections you will first learn about an object-such as a domain-and then you will create one. The objects you will create are described in Table 3.2.

CAUTION
Remember, when creating any of the objects in this book, use your handle (···) as the first three characters of the object name. (The characters ··· represent your handle. The handle was described in Chapter 2 in the section titled "Introducing Program Naming Conventions.")
Do not use ztx as the first three characters. If you use ztx, it will be very difficult to determine which objects are yours.

Activation of DDIC Objects

Before learning about DDIC objects in depth, you should know about object activation. Activation applies to all dictionary objects.

After creating a Data Dictionary object, you will activate it. Activating an object is simple-you will simply press the Activate button. This changes the status of the object to Active.

An object must be Active before it can be used. For example, if you try to use an inactive data element when creating a field, you will get a message saying that the data element does not exist or is not active. Your response would be to activate the data element.

If you change an object, you must activate it again for the changes to take effect. If you save the changes but do not activate it, the objects that refer to it will not "know about" the change.

Discovering Domains

Before actually creating a domain, I will describe the screen you will use to create it.

In Figure 3.7 is the screen you will use to create a domain-the Dictionary: Maintain Domain screen. On this screen you specify short text, the data type, a field length, and optionally an output length. These items are explained in the following sections.

Figure 3.7 : The Dictionary: Maintain Domain screen is used to create a domain.

Short Text Field

The Short Text field will contain a description of the domain. The end user never sees it; it is only displayed to developers. You will see it when you bring up a list of domains, such as when you search for one.

NOTE
Adding the word "domain" to the end of the short text description is redundant and should be avoided. For example, the short text "Generic telephone number domain" should be avoided. Instead, type "Generic telephone number."

In this field, you will describe the type of data the domain is intended to contain. For example, the description of a reusable telephone number domain might read "Generic telephone number" or "General telephone number."

Data Type Field

The Data Type field specifies the representation used internally by the database to store the value for that field. For some data types, it also determines the input format validation and output format of the field. For example, fields of data type DATS (date) and TIMS (time) are automatically formatted with separators when output to a list or displayed onscreen. On input, they must also be in date or time format, or an error message is issued to the user.

The most commonly used data types are listed in Table 3.3.

Table 3.3  Commonly Used Data Types
Type
Description
CHARCharacter strings (maximum 255 characters)
DECDecimal values (maximum length 31)
DATSDate field
TIMSTime field
INT1, INT2, INT4 Integer values
NUMCCharacter field that can contain only numerics

TIP
You should always press the Enter key after you fill in the data type field. Pressing Enter causes the screen to change based on the data type you specified. If the data type is a signed numeric type, a Sign check box will appear. For fields that allow decimals, a Decimal Places field will appear. For character fields, a Lowercase Letters check box will appear.

Output Length, Decimal Places, and Lowercase Letters Fields

The Output Length field indicates the number of bytes needed to output the field to a list or a screen, including commas, decimal point, sign, and any other formatting characters. For example, on output, date and time fields are automatically formatted with separators. Internally, a date is stored as eight characters (always YYYYMMDD), but the output length in the domain should be specified as 10 to enable two separators to be inserted. If the Output Length field is left blank, its value is automatically calculated by the system when you press Enter.

For decimal fields, you can specify the number of decimal places in the Decimal Places field.

Character fields are usually converted to uppercase before they are stored in the database. You can turn this conversion off by tickmarking the Lowercase Letters check box.

Most developers do not have problems understanding the internal representation of character or integer fields. However, the location of the decimal point in decimal fields is often a point of confusion, so it is described here.

For type DEC fields, the decimal point is not stored in the database. Only the numeric portion is stored, not the decimal. On output, the position of the decimal is determined by the value you put in the Decimal Places field of the domain.

In order for the field to be properly displayed, you must specify an output length that includes one byte for the decimal point and one byte for each thousands separator that can be displayed. However, the system will calculate the output length for you if you simply blank out the Output Length field and press Enter.

Creating a Domain

In this section, you will learn the bottom-up approach to creating a domain.

Start the ScreenCam "How to Create a Domain" now.

Perform this procedure twice to create the -lifnr and -name1 domains. Help with common problems is given in the Troubleshooter that follows it. If you have trouble with any one of the steps, don't forget to consult the Troubleshooter.

  1. Begin at the Dictionary: Initial Screen. (To get there from the SAP main menu, choose the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary.)
  2. Enter the domain name in the Object Name field.
  3. Choose the Domains radio button.
  4. Press the Create pushbutton. You then see the Dictionary: Maintain Domain screen. The fields containing question marks are required fields.
  5. Type a description of the domain in the Short Text field.
  6. Fill in the Data Type field. You can put your cursor in this field and press the down arrow to display a list of allowed data types. Pick one from the list or type one in.
  7. Enter a field length.
  8. Press the Activate button on the Application toolbar to both save and activate the domain. The Create Object Catalog Entry screen is displayed.
  9. Press the Local Object button. You are returned to the Dictionary: Maintain Domain screen.
  10. Press the Back button on the Standard toolbar. This returns you to where you began this procedure, the Dictionary: Initial Screen.

Trouble
Possible Symptoms
Solution
Can't create domainWhen you press the Create button, nothing happens. Look at the status bar in the bottom of the window and press the button again. It is likely that you will see a message there.
 When you press the Create button, you see the message "System change option does not allow changes to SAP objects." Change the domain name to start with y or z.
 When you press the Create button, you see the message "Enter access key." Change the domain name to start with y or z.
 When you press the Create button, you see the message "You are not authorized to make changes." Request development authorization from your security administrator.
 When you press the Create button, you see the message "already exists." The name you entered already exists in the Data Dictionary. Choose a different domain name.
Getting message"W: (calculated output length is smaller than specified)." Blank out the Output Length field and press Enter and then Activate.
 "E: Value table does not exist." Blank out the Value Table field and press Enter and then activate.

Obtaining SAP Documentation on Domains

There are many places to obtain SAP documentation on the features of domains.

If you wish to see documentation describing all data types and their uses, put your cursor on the Data Type field and press F1. You will see a dialog box containing highlighted fields. Click on these highlighted fields for more details.

You can also consult the R/3 library help for additional documentation on data types and other properties of the domain. To view this documentation, from any screen choose the menu path Help->R/3 Library. You will see the main menu of the R/3 library. From there, click on the following tabs: Basis Components->ABAP/4 Development Workbench->ABAP/4 Dictionary->New Developments In The ABAP/4 Dictionary In Release 3.0.

For still more documentation on the data types in the domain, from within the domain choose the menu path Help->Extended help. Then click on Creating Domains, and then click on External Data Type.

To obtain documentation that describes the mapping of domain data types to ABAP/4 data types, display F1 help for the "tables" keyword. (To do so, within the ABAP/4 editor, put your cursor on the word tables and press F1.)

Discovering Data Elements

Before actually creating a data element, I will describe the screen you will use to create it.

Figure 3.8 shows the screen used to create a data element. Here you specify the short text, domain name, labels, and a header, which are explained in the following sections. Documentation can also be created after the data element has been saved.

Figure 3.8 : The Dictionary: Change Data Element screen.

Short Text Field

The Short Text field describes a business context for a domain. For example, a "customer telephone number" is a specific business context for a "generic telephone number" domain, so it would be an appropriate description for a data element. The end user will see this description if they request F1 help for a field that was created using this data element.

Field Label and Header Fields

At the bottom of the screen shown in Figure 3.8 are four text fields. The first three are field labels. When any field appears on a screen (such as an input field on an input screen), one of the short, medium, or long fields will appear to the left of it as a field label. The programmer chooses one of these field labels when he creates a screen. The contents of the Header field will appear as a column header at the top of lists.

If the fields that you create with this data element will not appear on any screens, uncheck the Maintain Field Labels check box and press the Enter key. You will no longer see the Field Label and Header fields. You will have to press Enter twice to cause the fields to disappear if these fields contain values.

Data Element Documentation

After you save the data element, a Documentation button appears on the Application toolbar so that you can store free-form text. The user sees this text when he requests F1 help. In other words, when a table field that uses this data element is displayed on a screen, the user can place his cursor into that field and press F1 to display the documentation you entered here.

When you see the Documentation screen, the first line will contain the characters &DEFINITION&. This is a heading; do not change this line. Type your documentation beginning on line two.

TIP
Data element documentation is often very useful to the programmer. By reading this F1 help, the programmer can determine the business usage of the data. Therefore, you should always create F1 help for the user via the Documentation button.

Creating a Data Element

In this section, you learn the bottom-up approach to creating a data element.

Start the ScreenCam "How to Create a Data Element" now.

Perform this procedure twice to create the -lifnr and -name1 data elements. Help with common problems is given in the Troubleshooter that follows it. If you have trouble with any one of the steps, don't forget to consult the Troubleshooter.

  1. Begin at the Dictionary: Initial Screen. (To get there from the SAP main menu, follow the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary.)
  2. Type the data element name in the Object Name field.
  3. Choose the Data Elements radio button.
  4. Press the Create button. The Dictionary: Change Data Element screen appears.
  5. Type short text for the data element.
  6. Type a domain name and press the Enter key. If the domain exists and is active, its data type and length will appear. If you don't see a data type and length after pressing Enter, verify the name of the Data Element. If the name is correct, verify that it is active by opening a new session (use menu path System->Create Session) and displaying it in the Data Dictionary.
  7. Enter field labels in the Field Label Short, Medium, Long, and Header fields. The value in the Short field should be a maximum of 10 characters, Medium should be a maximum of 15, and Long should be a maximum of 20. The value in the Header field should be the same length or shorter than the output length in the domain.
  8. Press the Save button on the Standard toolbar. The Create Object Catalog Entry screen is displayed.
  9. Press the Local Object button. You are returned to the Dictionary: Change Data Element screen. The Status fields contain the values New and Saved and the message "Saved without check" appears at the bottom of the window in the status bar. The Documentation button (among others) appears on the Application toolbar.
  10. Press the Documentation button. The Change Data Element: Language E screen is displayed. Here you can type end user documentation. This documentation is displayed when the user requests F1 help for fields created using this data element. The first line contains the characters &DEFINITION&. This is a heading; do not change this line. Type your documentation beginning on line two. Press the Enter key to begin each new paragraph.
  11. Press the Save Active button on the Application toolbar to save your text. The message "Document was saved in active status" appears in the status bar.
  12. Press the Back button on the Standard toolbar. You are returned to the Dictionary: Change Data Element screen.
  13. Press the Activate button on the Application toolbar. The value in the Status field changes to Act. and the message "was activated" appears in the status bar.
  14. Press the Back button. You are returned to the Dictionary: Initial Screen.

Trouble
Possible Symptoms
Solution
Can't create data elementWhen you press the Create button, nothing happens. Look at the status bar in the bottom of the window and press the button again. It is likely that you will see a message there.
 When you press the Create button, you see the message "System change option does not allow changes to SAP objects." Change the data element name to start with y or z.
 When you press the Create button, you see the message "Enter access key." Change the data element name to start with y or z.
 When you press the Create button, you see the message "You are not authorized to make changes." Request development authorization from your security administrator.
 When you press the Create button, you see the message "already exists." The name you entered already exists in the Data Dictionary. Choose a different domain name.
Can't activate data elementSeeing message "No active domain exists with name." Go to the Dictionary: Change Data Element screen and double-click on the domain name.
 Either the domain name you entered on the previous screen does not exist or is not active. You will then see either a dialog box or the Dictionary: Display Domain screen.
  If you see a dialog box with the title Create Domain, the domain does not exist. Check the name carefully. Did you enter the wrong name? It might be a good idea to open a new session and display the objects you created so far using the Object Browser. (In Day 2, see the section "Finding Your Development Objects.")
  If, after double-clicking, you see the Dictionary: Display Domain screen, look at the Status field on that screen. Is the status New? If so, the domain needs to be activated. Press the Activate button and then press the Back button to return to the data element and try again to activate it.
Getting message"Maintain field label." Enter short, medium, and long field labels and then activate.
 "W: Length was increased to the actual text length." The header text you entered was longer than the field length.
  This is not a serious error. To bypass it, just press Enter and then activate.
Can't enter field labels.Input fields are missing from the screen. Tickmark the Maintain Field Labels check box and press Enter.

Discovering Transparent Tables

Figure 3.9 shows the screen used to create a transparent table. Here you specify the short text, delivery class, field names, a data element name for each field, and select the primary key fields. The following sections explain these items in more detail.

Figure 3.9 : The Dictionary: Table/ Structure: Change Fields screen enables short text, attributes, and field names to be entered.

Short Text Field

The Short Text field is used for the same purposes as the domain Short Text fields. The end user will not see this description anywhere, but the developer will see it when bringing up a list of tables.

Delivery Class Field

The value in the Delivery Class field identifies the "owner" of the data in this table. The owner is responsible for maintaining the table contents. In customer tables, you always enter an A here, which indicates that the table contains application data owned by the customer only. Other values entered in the field are useful only to SAP, and indicate that either SAP owns the data or both SAP and the customer jointly own the data.

TIP
For a complete list of valid values and their meanings, put your cursor on the Delivery Class field and press F1.

Tab.Maint.Allowed Field

Tickmarking the Tab.Maint.Allowed check box causes the menu path Utilities->Create Entries to be enabled. After activating the table and choosing this menu path, the Table Insert screen is displayed, enabling you to enter data into your table. It is useful for testing and for manual entry of small amounts of data. If the Tab.Maint.Allowed check box is blank, the menu path Utilities->Create Entries will be grayed out.

Field Name Column

In the lower half of the screen you can enter field names in the Field Name column. The primary key fields must appear first in this list and must be indicated by a tickmark in the Key column. A data element name must be entered to the right of each field name. After filling in the field names, press the Next page button on the Standard toolbar if you want to enter additional fields.

Creating a Transparent Table Using Preexisting Domains and Data Elements

In this section, you learn the bottom-up approach to creating a transparent table.

Start the ScreenCam "How to Create a Transparent Table Using Preexisting Domains and Data Elements" now.

Perform this procedure to create the -lfa1 table. In this procedure, we will create the table, but will only include the first three fields (mandt, -lifnr and -name1) in it. Later on, we will add the remaining fields using the top-down approach.

Help with common problems is given in the Troubleshooter that follows this procedure. If you have trouble with any one of the steps, don't forget to consult the Troubleshooter.

  1. Begin at the Dictionary: Initial Screen (To get there from the SAP main menu, use the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary).
  2. Type the table name -lfa1 in the Object Name field.
  3. Choose the Tables radio button.
  4. Press the Create pushbutton. This takes you to the Dictionary: Table/Structure: Change Fields screen.
  5. Enter short text describing the table.
  6. Type an A in the Delivery Class field.
  7. Tickmark the Tab.Maint.Allowed. check box.
  8. In the Field Name column, enter the name of the first field of the table.
  9. Tickmark the Key column if it forms part of the primary key.
  10. Enter the name of a data element in the Data Elem. column.
  11. Press the Enter key.
  12. Look at the status bar. If you see the message "Data element is not active," the data element either does not exist or has not been activated. These are the possible reasons why you might see this message:
  13. Check the name carefully. If the spelling is correct, double-click on it. If a data element of that name doesn't exist, you will see a dialog box titled Create Data Element. If the data element does exist, the data element itself will be displayed.
  14. If you are now looking at the data element, notice the value in the Status field. The Status field must contain Act. to indicate that it is active. If it does not, press the Activate button and verify the status is now Act. (If it will not activate, turn to the Troubleshooter associated with the procedure for creating data elements.) Once the data element has been activated, press the Back button to return to the Dictionary: Table/Structure: Change Fields screen.
  15. START=13
  16. Repeat steps 8 though 12 for each of the remaining fields in the table (-lifnr and -name1).
  17. Press the Save button on the Standard toolbar. You will then see the Create Object Catalog Entry screen.
  18. Press the Local Object button. You are then returned to the Dictionary: Table/Structure: Change Fields screen.
  19. Press the Technical Settings button on the Application toolbar. The ABAP/4 Dictionary: Maintain Technical Settings screen is displayed.
  20. In the Data Class field, enter APPL0 (APPL0 with a zero, not with the letter O).
  21. Enter 0 (zero) in the Size Category field.
  22. Press the Save button.
  23. Press the Back button. You are returned to the Dictionary: Table/Structure: Change Fields screen.
  24. Press the Activate button on the Application toolbar. If the activation was successful, the message "was activated" appears in the status bar and the Status field contains the value Act.
  25. Press the Back button to return to the Dictionary: Initial Screen.

Trouble
Possible Symptoms
Solution
Can't create tableWhen you press the Create button, nothing happens. Look at the status bar in the bottom of the window and press the button again. It is likely that you will see a message there.
  When you press the Create button, you see the message "Enter access key." Change the table name to start with y oz.
 When you press the Create button, you see the message "System change option does not allow changes to SAP objects." Change the table name to start with y or z.
 When you press the Create button, you see the message "You are not authorized to make changes." Request development authorization from your security administrator.
 When you press the Create button, you see the message "already exists." The name you entered already exists in the Data Dictionary. Choose a different domain name.
Can't activate table Seeing message "E-Field (Data element or domain is not active or does not exist)." Go back one screen to the Dictionary: Table/Structure: Change Fields screen. Double-click on the data element name. You will see either a dialog box or the data element itself.
  If you see a dialog box with the title Create Data Element, the data element does not exist. Check the name carefully. Did you enter the wrong name? It might be a good idea to open a new session and display the objects you have created so far using the Object Browser. (In Day 2, see the section "Finding Your Development Objects.")
  If you can display the data element, look at the Status field. Is the status New? If not, the data element needs to be activated. Press the Activate button and then press the Back button to return to the table.
Seeing screen ABAP/4 Dictionary: Maintain Technical Settings   The technical attributes were either not entered or not saved. Enter the technical attributes now, press the Save button, and then press Back.
Messages displayed in red "E- Field (Data element or domain is not active or does not exist)." See Can't activate table, above.
 "E- Entry in table TAORA missing." Look further down for a message (in red) about the Data Class or Size category.
  "E- Error in code generation for creating table in the DB" "E- Table (Statements could not be generated)." Look further down for a message (in red) about the Data Class or Size category.
  Look further down for a message (in red) about the Data Class or Size category.
  "E- Field Size category (Value not permitted)." You entered an invalid value in the Size Category field of the technical settings. Press Back and then press Technical Settings, and change the Size Category to 0 (zero).
  "E- Field Data class (Value not permitted)." You entered an invalid value in the Data Class field of the technical settings. Press Back and then press Technical settings, and change the Data Class to APPL0 (use a zero at the end of APPL).
  "E- Key is already defined; field cannot be in the key." The primary key fields are not adjacent to each other. Press Back and make sure your primary key fields are all at the beginning of the table with no intervening non-key fields. (All of the tickmarks in the Key column must be together at the beginning of the table.)
Seeing dialog box titled Adjust Table with the text Table must be adjusted in the database. Table needs to be converted. You changed the table and now a table conversion must be done to complete the activation. Choose a processing type of Online and press the Adjust button.
Seeing message at bottom of screen "Initial value not permitted as the field name" or: can't scroll up or: can't see fields you entered.   You tried to remove a field by blanking it out. You can't do that; you must delete fields using the Cut button on Application toolbar. Press Cut until you see the message "Selected entries were copied to the clipboard" at the bottom of the window in the status bar.
Can't get past a message A message beginning with the characters "W:" appears in the status bar and you can't get any further. Press the Enter key in response to the message.

Creating a Transparent Table Without Preexisting Domains and Data Elements

In this section you will learn to add fields to a table using the top-down approach. You will add the remaining two fields (-regio and -land1) to your -lfa1 table.

Using the top-down approach, you can add fields to a table before you create the data elements and domains. You can simply create data elements and domains as you go along.

To do so, you will enter a data element or domain name and then double-click on it. You will be taken to the Creation screen. From there you create the domain or data element, activate it, and then press the Back button to return to where you were.

What follows is the procedure for adding fields to a transparent table without first creating the domains and data elements.

Start the ScreenCam "How to Create a Transparent Table Without Preexisting Domains and Data Elements" now.

  1. Begin at the Dictionary: Initial Screen (To get there from the SAP main menu, use the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary).
  2. Type the table name -lfa1 in the Object Name field.
  3. Choose the Tables radio button.
  4. Press the Change pushbutton. This takes you to the Dictionary: Table/Structure: Change Fields screen.
  5. Press the New Fields pushbutton. Blank lines appear at the bottom of the screen, and the existing table fields are scrolled upward.
  6. In the Field Name column, enter the name of the field you wish to add.
  7. Tickmark the Key column if it forms part of the primary key. (The -regio and -land1 fields do not, but this procedure is written generically so that it can be used in general situations.)
  8. Enter the name of the associated data elements in the Data Elem. column.
  9. Press the Enter key.
  10. Look at the status bar. You should see the message "Data element is not active," because the data element does not exist.
  11. Double-click on the data element name. The Create Data Element dialog box will be displayed. In the Data Element field will be the name of the data element to be created. This will of course be the data element you wish to create, so unless it is misspelled, do not change it here.
  12. Press the Continue button. The Dictionary: Change Data Element screen appears.
  13. Enter short text for the data element.
  14. Enter a domain name.
  15. Double-click on the domain name to create it. The Create Domain dialog box will be displayed. In the Domain Name field will be the name of the domain to be created. This will of course be the domain you wish to create, so unless it is misspelled, do not change it here.
  16. Press the Continue button. The Dictionary: Maintain Domain screen is displayed.
  17. Fill in the Short Text, Data Type, and Field Length fields.
  18. Press the Activate button on the Application toolbar.
  19. Press the Local Object button. You are returned to the Dictionary: Maintain Domain screen. The value in the Status field changes to Act. and the message "was activated" appears in the status bar.
  20. Press the Back button on the Standard toolbar to return to the Dictionary: Change Data Element screen.
  21. Enter the remaining fields for the data element (refer to step number 7 of the Data Element Creation Procedure in the "Creating a Data Element" section).
  22. Press the Activate button on the Application toolbar. You will then see the Create Object Catalog Entry screen.
  23. Press the Local Object button. You are returned to the Dictionary: Change Data Element screen. The value in the Status field changes to Act. and the message "was activated" appears in the status bar.
  24. Press the Back button on the Standard toolbar. You are returned to the Dictionary: Table/Structure: Change Fields screen. There should be no messages in the status bar.
  25. Repeat steps 5 through 23 for each new data element you want to create.
  26. After you have created all domains and data elements, press the Activate button on the Application toolbar. If the activation was successful, the message "was activated" appears in the status bar and the Status field contains the value Act.
  27. Press the Back button to return to the Dictionary: Initial Screen.

Modifying Tables

After you have created a table, you can:

This section describes how to perform these functions.

Copying a Table

If a table is active in the DDIC, you can copy it. You might want to do this if the table you want to create will be very similar to a table that already exists in the database. Or, you might want to experiment with some dictionary functionality that is unfamiliar to you, but you don't want to modify an existing table.

To copy a table, follow this procedure:

  1. Go to the Dictionary: Initial Screen. (To get there from the SAP main menu, use the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary.)
  2. Choose the Tables radio button.
  3. Press the Copy button on the Application toolbar.
  4. Enter the name of the From and To tables.
  5. Press the Continue button. You are returned to the Dictionary: Initial Screen and the message ++ appears in the status bar at the bottom of the window.
  6. Press the Activate button on the application toolbar to activate the new table.

This procedure copies the table structure only, not the data. To copy table data, write a small ABAP/4 program of your own.

NOTE
Tables can't be renamed. To change the name of a table, you must copy it to a different table with the desired name and then delete the original table. If this has to be done, be sure to copy both the structure and the data.

Deleting a Table

You can delete existing DDIC tables. You might want to do this if an existing table is no longer needed, or if you created a table for the purposes of trying out dictionary functionality that is unfamiliar to you.

To delete a table, follow this procedure:

  1. Go to the Dictionary: Initial Screen. (To get there from the SAP main menu, use the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary.)
  2. Enter the table name in the Object Name field.
  3. Choose the Tables radio button.
  4. Press the Delete button on the Application toolbar. A pop-up will ask you for confirmation of the delete request.
  5. Verify the table name you entered and press Yes if you wish to continue.

Adding Fields

There are two ways to add fields to an existing table:

Inserting a field enables you to position a field before an existing field.

Appending a field enables you to add new fields at the end of the table, after all of the existing fields.

Inserting a Field

To insert a new field above an existing field, perform this procedure:

  1. Begin at the Dictionary: Initial Screen. (To get there from the SAP main menu, use the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary.)
  2. Type the table name in the Object Name field.
  3. Choose the Tables radio button.
  4. Press the Change pushbutton. This takes you to the Dictionary: Table/Structure: Change Fields screen.
  5. Position your cursor on a field.
  6. Press the Insert Field button on the Application toolbar. A new row will appear above the cursor position.
  7. Create your new field on the row that you just inserted.

Appending a Field

To append a field to the end of a table, perform this procedure:

  1. Begin at the Dictionary: Initial Screen. (To get there from the SAP main menu, use the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary.)
  2. Type the table name in the Object Name field.
  3. Choose the Tables radio button.
  4. Press the Change pushbutton. This takes you to the Dictionary: Table/Structure: Change Fields screen.
  5. Press the New Fields button on the Application toolbar. On the bottom half of the screen, the existing fields scroll up to enable you to enter additional fields at the end.
  6. Create your new fields in the rows that you just inserted.

Deleting Fields

You can delete existing fields from a table. You may wish to do this if the field is no longer needed in the table, or if you created a field for the purposes of trying out dictionary functionality that is unfamiliar to you.

To delete a field from a table, complete the following steps:

  1. Go to the Dictionary: Initial Screen. (To get there from the SAP main menu, use the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary.)
  2. Enter the table name.
  3. Choose the Tables radio button.
  4. Press the Change button.
  5. Place your cursor on the field to be deleted.
  6. Press the Cut button on the Application toolbar, or choose the menu path
    Edit->Delete Field.
  7. Activate the table. The Adjust Table screen is displayed. Press the Adjust button to convert the table in the database.

CAUTION
To delete a field from a table, do not blank out the field name. Instead, put your cursor on the field name and press the Cut button. If you simply blank out the name, the message "Initial value not permitted as field name" will appear at the bottom of your screen in the status bar, and you won't be allowed to continue until you delete the row that you blanked out.

Changing the Data Type or Length of a Field

You can change the data type and/or length of existing fields in a table. You may wish to do this if the field length needs to be increased to hold longer values, or if the field validation rules change and the data type is no longer suitable for new data that should be entered in the field.

Complete the following steps to change the data type or length of a field:

  1. Go to the Dictionary: Initial Screen. (To get there from the SAP main menu, use the menu path Tools->ABAP/4 Workbench, Development->ABAP/4 Dictionary.)
  2. Enter the table name.
  3. Choose the Tables radio button.
  4. Press the Display button.
  5. Double-click on the data element corresponding to the field you want to change. The data element will be displayed.
  6. Double-click on the domain name in the data element. The domain will be displayed.
  7. Press the Display <-> Change button on the Application toolbar. You will now be able to change the attributes of the domain.
  8. Blank out the Output Length field.
  9. Change the data type and/or length.
  10. Press the Activate button. The Please note! screen is displayed showing a list of all tables and structures that use this domain. They will all be affected. To continue, press the Continue button.

NOTE
Making changes to a domain affects all fields that use that domain.

Working with Data

If you have not already done so, create your table now and activate it before proceeding.

Within R/3 are SAP-supplied utilities called data browsers that enable you to manipulate the data within tables. Although the word browser implies that you will only read the data, data browsers can be used for both reading and updating.

You can use the data browser utilities to display or modify data within tables in these ways:

This section describes how to use the data browsers to perform these functions.

Accessing Data Browser Functionality From Within the DDIC

As noted above, one of the functions of a data browser is to insert new rows into a table. A quick and easy way to access this functionality is from the Dictionary: Table/Structure screen (in either display or change mode), choose the menu path Utilities->Create Entries. Choosing this menu path is a shortcut-it will invoke a data browser but will bypass the initial screen and take you directly to the screen that will allow you to insert new rows into a table.

If this menu path is disabled, tickmark the Tab.Maint.Allowed field and reactivate your table. Please refer to the section earlier in this chapter titled "Tab.Maint.Allowed Field" for an explanation of this field.

Choosing this menu path automatically performs these tasks in order:

Start the ScreenCam "How to Add Data to a Table" now.

Perform this procedure to add data to your table. Help with common problems is given in the Troubleshooter that follows it. If you have trouble with any one of the steps, don't forget to consult the Troubleshooter.

  1. Go to the Dictionary: Initial Screen.
  2. Type the name of your table in the Object Name field.
  3. Press the Display button. The Dictionary: Table/Structure: Display Fields screen is displayed.
  4. Choose the menu path Utilities->Create Entries. Watch the status bar at the bottom of your screen when you choose the menu path; you might be able to see the message "Compiling. . .". This message indicates that the system is generating the update program. The Table Insert screen is displayed. On this screen is an entry field for each field in your table. To the left of each entry field is the field name. The primary key fields appear first, followed by a blank line, then the remaining fields of the table. To see the program that was generated, choose Utilities->Create Entries and then choose the menu path System->Status. The program name appears in the Program (Screen) field.
  5. Fill in the fields with the data you want to insert into your table.
  6. Press the Save button on the Standard toolbar. You will see the message "Database record successfully created" in the status bar.
  7. Repeat steps 5 and 6 for each row you want to enter.
  8. Press the Back button to return to the Dictionary: Table/Structure: Display Fields screen.
  9. Choose the menu path Utilities->Table Contents to display the rows you just created. The Data Browser: Table: Selection Screen is displayed.
  10. To display all of the rows in the table press the Execute button without entering any search criteria. The Data Browser: Table Select Entries screen is displayed, and the new rows you entered will be shown in a list.

3

TIP
If you place your cursor on any field and press the F1 key, the Help - Table Insert screen is displayed. On this screen you will see the documentation you entered into the data element. To return to the Table Insert screen, press either the Continue or Cancel button.

Trouble
Possible Symptoms
Solution
Can't add dataThe menu item Create Entries is grayed out and nothing happens when you click on it. The Tab.Maint.Allowed check box is not checked. Go to the Dictionary: Table/Structure: Change Fields screen (to get there display the table and click on the Display <-> Change button on the Application toolbar until the fields are modifiable). Add a tickmark to the Tab.Maint.Allowed check box. Press the Activate button.
 When you press the Save button, you see the message "A data record with the specified key already exists" at the bottom of the window. The table already contains a record with the same primary key as the one you are trying to save. The primary key fields are the first group of fields that appear on the screen. There is a blank space on the screen under the last field in the primary key. Change a value in one of the fields above the space and try saving your record again.

General Data Browser Utilities

The functionality you accessed in the preceding section is just one function of a single data browser. In the R/3 system, there are four general data browser utilities: SE16, SE17, SM30, and SM31. They are similar to each other in some ways, and yet provide varying types of functionality.

Using SE16

SE16 is the most used general-purpose data browser utility program. With it, you can search tables for specific rows and display them, update them, delete them, copy them, add new rows, and more. It can be accessed in either of these two ways:

Start the ScreenCam "How to Display Table Data Using the Data Browser" now.

  1. Type /nse16 in the Command field.
  2. Press the Enter key. The Data Browser: Initial Screen appears.
  3. Type your table name in the Table Name field.
  4. Press the Table Contents button on the Application toolbar. If the table contains more than 40 fields, you will see the Choose Fields For Selection screen. If you see it, place a tickmark beside the fields for which you want to enter search criteria, and press the Execute button. The fields you tickmark will be shown on the next screen-the Data Browser: Table: Selection screen. This screen is usually simply called a selection screen. Here you can enter search criteria to find specific rows in the table. To display all rows, do not enter any search criteria. If there will be more than 500 rows that match your criteria and you want to display them all, blank out the value in the Maximum No. Of Hits field.
  5. Press the Execute button on the Application toolbar. You will then see the Data Browser: Table Select Entries screen. All rows that match your criteria are displayed up to the maximum number of rows specified in the Maximum No. of Hits field.

Trouble
Solution
Nothing happens when you press the Execute button.
  • You intentionally or accidentally typed something into a field on the selection screen and no rows match that search criteria. Blank out all of the fields on the selection screen and press Execute again.
  • There is no data in the table.
  • Did you press Save after every record?
  • Did you enter data into the table?
There are fewer records in the record? output list than you inserted into the table.
  • Did you press Save after every record?
  • Did you enter unique primary key field values for each
  • You intentionally or accidentally typed something into a field on the selection screen and not all records match that search criteria. Return to the selection screen, blank out all of the fields, and press the Execute button again.

NOTE
Like the menu path Utilities->Create Entries, Utilities->Table Contents also generates a program, and it is regenerated if you change the table structure. To display the program that it generates, from the selection screen choose the menu path System->Status.

Start the ScreenCam "Data Browser Functionality" now.

On the data browser screen you can do the following:

TIP
To find information on maintenance dialogs in the R/3 Library, choose the menu path System->R/3 Library Help. From there, click on the following tabs: Basis Components->ABAP/4 Development Workbench->Extended Applications Function Library->Extended Table Maintenance.

Using SM31 and SM30

SM31 and SM30 can also be used to display and update table data. SM31 is an older version of SM30 that has less functionality. The input field on the first screen of SM30 is long enough to accommodate any table name; on SM31 it is only five characters long. Before you can use either one, a special program called a standard maintenance dialog must be generated for the table you want to display.

A standard maintenance dialog is an ABAP/4 program that you generate. When you invoke SM31 or SM30, the data browser will automatically find and invoke that generated program. It provides a more complex interface and more functionality than SE16. For more information on maintenance dialogs and the procedure to create them, consult the R/3 Library help.

Comparing SE17 with SE16

SE17 is very similar to SE16 in the fact that it can be used to search for specific rows within a table. However, SE17 cannot be used for updates. Using SE16, you can specify complex search criteria for a maximum of 40 fields at a time; with SE17, you can specify simple search criteria for any number of fields at once. SE16 only enables output to be sorted by a single column at a time; SE17 enables you to specify any sort sequence across multiple columns. SE16 will not work for a table that has a standard maintenance dialog, but SE17 will.

Summing Up the Data Browsers

In special cases, for display only where you need to specify multiple sort criteria, use SE17. However, for most day-to-day display/update activities, use SE16. However, you will not be able to use SE16 if the table has a standard maintenance dialog. In that case, use SM31.

The simplest way to tell if you should use SE16 or SM31 is to simply try one. If it doesn't work, then the other probably will. If neither one works, resort to SM30.

Displaying the Data Using Your Own ABAP/4 Program

Instead of using a data browser, it is quite easy to write a small ABAP/4 program to display the data in your table. Try creating one now. Design your program to write out a suitable message if no rows exist in the table.

A sample solution is shown in Listing 3.1. Try creating one on your own before looking at the solution.


Listing 3.1  Simple Program to Display the Data in the ZTXLFA1 Table

 1  report ztx0301.
 2   tables ztxlfa1.
 3   select * from ztxlfa1.
 4       write: / ztxlfa1-lifnr,
 5                ztxlfa1-name1,
 6                ztxlfa1-regio,
 7                ztxlfa1-land1.
 8       endselect.
 9   if sy-subrc <> 0.
10       write 'Table is empty.'.
11       endif.

Utilizing F1 Help

F1 help is the documentation seen by the user for a field. To obtain it, the user places his cursor on the field and presses F1. The documentation is displayed in a dialog box. You will use the following procedure to modify the F1 help you created earlier for the lifnr field.

Start the ScreenCam "How to Create or Modify F1 Help" now.

Adding F1 Help to a Field

To add F1 help to a field:

  1. Begin on the Dictionary: Table/Structure screen (either change or display mode).
  2. Locate the field to which you want to add help and double-click on the data element name corresponding to that field. The Dictionary: Display Data Element screen will be displayed.
  3. Press the Display <-> Change button on the Application toolbar. The screen switches to change mode.
  4. Press the Documentation button on the Application toolbar. The Change Data Element: Language E screen is displayed.
  5. Type the text the user should see when he or she requests help for this field. The first line contains the characters &DEFINITION&. This is a heading; do not change this line. Type your documentation beginning on line two. Press the Enter key to begin each new paragraph.
  6. Press the Save Active button on the Application toolbar to save your changes. The message "Document was saved in active status" appears in the status bar.
  7. Press the Back button on the Standard toolbar. You are returned to the Dictionary: Change Data Element screen.
  8. Press the Back button once more to return to the Dictionary: Table/Structure screen.

Testing F1 Help

To test your F1 help:

  1. Begin on the Dictionary: Table/Structure screen (either change or display mode).
  2. Choose the menu path Utilities->Create entries.
  3. Put your cursor on the field with the modified help text.
  4. Press F1. The system will display your modified documentation.

Adding Hypertext Links to F1 Help

Hypertext links enable you to click on a highlighted word or phrase in F1 help and display additional help for that word or phrase. To add hypertext links, you first create a document you want to link to, and then insert a reference to that document in your help text. Document names must start with y or z. You can include hyperlinks in your new document also and link from there to another document, ad infinitum.

Start the ScreenCam "How to Create a Hypertext Link in F1 Help" now.

  1. Begin at the R/3 main menu and choose the menu path Tools->ABAP/4 Development Workbench. The ABAP/4 Development Workbench screen is displayed.
  2. Choose the menu path Utilities->Documentation. The Document Maintenance: Initial Screen is displayed.
  3. Click on the down-arrow of the Document Class field. A list of document classes is displayed.
  4. Double-click on General Text. The Document Class field now contains the value General text, and a field named General Text is displayed at the top of the Document Maintenance screen. (The Documentation Type field should already contain the value Original user. If it doesn't, click on the down arrow at the end of the field and change it.)
  5. In the General Text field, type the name of a document you want to create. The name must start with y or z. REMEMBER THIS NAME.
  6. Press the Create button. The Change General Text: Language E screen is displayed.
  7. Type your document here. Press the Enter key at the end of each paragraph.
  8. Press the Save Active button. The Create Object Catalog Entry screen is displayed.
  9. Press the Local Object button. You are returned to the Change General Text screen and the message "Document was saved in active status" appears in the status bar.
  10. Press the Back button to return to the Document Maintenance: Initial screen.
  11. Press the Back button again to return to the ABAP/4 Development Workbench screen.
  12. Go into the Data Dictionary and display your data element.
  13. Press the Display <-> Change button on the Application toolbar. Your screen switches to change mode.
  14. Press the Documentation button on the Application toolbar. The Change Data Element: Language E screen is displayed.
  15. Place your cursor in the position at which you want to insert a hyperlink.
  16. Choose the menu path Include->Reference. The Insert Link screen is displayed.
  17. Click on the down arrow at the end of the Selected Reference field. The Title screen is displayed; notice that it contains a list of document classes.
  18. Double-click on General text. The Selected Reference field now contains the value General text, and a field named General Text is displayed at the top of the screen.
  19. In the General Text field, type the name of the document you created in step 6.
  20. In the Name In Document field, enter the hyperlink text. This is the text that will be highlighted and on which the user will be able to click to receive more help.
  21. Press the Continue button. You are returned to the Change Data Element: Language E screen and a link appears at the cursor position.
  22. Press the Save Active button on the Application toolbar.
  23. You can try out your new hyperlink immediately by choosing the menu path Document->Screen Output. The Display Documentation screen is displayed, your help text appears, and your hyperlink should be highlighted.
  24. Click on the hyperlink. The Display Hypertext: screen is displayed and your document should appear.
  25. Press Back three times to return to the Dictionary: Table/Structure screen.
  26. To test your hyperlink, display your table and choose the menu path Utilities->Create Entries. The Table Insert screen is shown.
  27. Position your cursor in the field for which you created F1 help.
  28. Press F1. Your help text with the hyperlink should be displayed.
  29. Click on the hyperlink. Your new document should be displayed.

Trouble
Solution
Can't find General Text in the list of document classes.
  • Scroll up.
Seeing message "Change relevant to translation?"
  • Press the Save Active button on the Application toolbar, not the Save button on the Standard toolbar.
Seeing message "Data element is not used in an ABAP/4 Dictionary structure."
  • Change the document class to General Text.
I'm pressing the Documentation button in the data element screen, but it doesn't do anything. again.
  • Is the screen title Dictionary: Display Data Element? If so, you are in display mode. You need to be in change mode. Press the Display <-> Change button and then try

Summary

Q&A

Q
If I make the length of a field smaller by changing the domain, and if that field is used in a table that already contains data filling the entire length of the field, what happens?
A
When you activate the domain, the system will attempt to activate the tables that are dependent upon that domain. The activation of the tables that would have lost data will fail, and a list of those tables will be shown to you. If you then go and activate those tables, the system will automatically convert the data in them, and the data in the column referenced by the domain will be truncated.
Q
How do you find out what tables will be affected before you change a domain?
A
Do a Where-used list on the domain. To do this, display the domain, press the Where-Used List button on the Application toolbar, select Other Objects, and press Continue. A tree list will be displayed. Double-click on the line that reads Table. The list of table names is displayed. Double-click on any line to display the table.
Q
Is it possible to create a table field without using a data element or domain? It seems like such a lot of work to have to create these for every field.
A
Yes, it is possible to create a table field without using a data element or domain. Display the table in change mode and then choose the menu path Edit->Direct Type Entry. You can then enter the field length and data type directly. This method is not recommended for fields that will appear onscreen; it is only appropriate for fields that will never be seen onscreen and will not have any foreign key relationships to other tables (see the following chapter for an explanation of foreign keys). SAP uses this method of creating tables for tables that hold system information such as database cursor IDs. You might use it in a staging table that holds raw data in transit into or out of the R/3 system. There are two main drawbacks of this method. One, no data elements are used and so no field labels or F1 help will exist. Two, no domains are used and so foreign keys cannot be created.

Workshop

The following exercises will give you practice creating objects in the data dictionary and using those objects in simple programs with the tables, select, and write statements. The answers appear in the appendix.

Quiz

  1. What is the purpose of the domain?
  2. What does the data element contain?
  3. To what does the term application data refer?
  4. For fields of type DEC, is the decimal point stored with the value of the field?
  5. What are the transaction codes of the four data browsers. Which one is most commonly used, and which one cannot be used to update data?
  6. What is the difference between a transparent table and a pooled or cluster table?

Exercise 1

Add the fields shown in Table 3.4 to your -lfa1 table. None of these fields will have an x in the Key column because they do not form part of the primary key. The purpose of these fields is to contain a second name for the vendor, the date and time the row was created, and the user ID of the user who created the record. Create a new data element for all fields. Reuse the domain from the name1 field for the name2 field. For the rest of the fields, use the existing R/3 domain names shown below. Document these fields using the Documentation button in the data element. After you have activated your changes, use a data browser to update the existing rows in your table and put data into the new fields. While you are updating the rows, test your F1 help.

Table 3.4  New Fields and Their Characteristics for Table ZTXLFA1
Field NameDE Name DM Name
name2--name2 --name
erdat--erdat datum
ertim--ertim time
ername--ernam usnam

Exercise 2

Create a transparent table -kna1 to contain customer master data, as shown in Table 3.5. Use a data browser to add data to the table. Create a new program -e0302 that reads the data from this table and writes it to the list.

Table 3.5  Fields and Their Characteristics for Table -KNA1
Description
  Field Name
PK
DE Name
DM Name
Type
Len
Client
  mandt
x
mandt
   
Customer Number
  kunnr
x
-kunnr
-kunnr
CHAR
10
Customer Name
  name1
 
-kname1
-name
CHAR
35
City
  cityc
 
-cityc
-cityc
CHAR
4
Region
  regio  --  regio --  regio   CHAR  3
Country
  land1
 
-land1
-land1
CHAR
3