⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch04.htm

📁 这个是sap开发语言abap的教育文档
💻 HTM
📖 第 1 页 / 共 5 页
字号:
When you create a check table, you must first create a domain.
You would always create a new domain specifically for a check
table. You would then create the data element, and then the table
itself. You would then activate the table. You would then go back
into the domain for the primary key field and put the name of
the check table you just created in the Value Table field - but
remember we call it the Default Check Table field. 
<P>
Now, you would create another table, in our example it is <TT>ztxlfa1</TT>.
You would create the <TT>land1</TT> field and use the <TT>ztxland1</TT>
data element, and then both fields would use the same domain.
<P>
Now you would create the foreign key to validate <TT>land1</TT>.
You would place your cursor on the <TT>ztxlfa1-land1</TT> field
and press the Foreign Key button. When you do this, the system
will look in the domain at the Value Table field (remember we
call it the Default Check Table field). If there were a table
name there, the system would automatically propose that name as
the name of the check table. In our case, the system would find
<TT>ztxt005</TT>. Therefore, the system would propose <TT>ztxt005</TT>
as the check table-exactly what we would want. The foreign key
proposal would be shown, and we could then save it.
<P>
In this example, the system automatically created the foreign
key for us, because we put the name of the check table in the
Value Table field. Using three mouse clicks, we created a foreign
key! That, in essence, is the primary reason for the Value Table
field. It exists to make the creation of foreign keys easier.
<P>
To summarize, the Value Table field is used in two ways by the
system:
<UL>
<LI>The value table (remember to imagine Default Check Table)
is automatically proposed as the check table when creating a foreign
key.
<LI>The value table provides a list of values for F4 help, but
no validation is done on this list.
</UL>
<H4>Value Table Field as the Check Table Proposal</H4>
<P>
In this section you will add a value table to a domain and observe
its effect on the creation of a foreign key.
<P>
Edit domain -<TT>land1</TT> now and
enter -<TT>t005</TT> in the Value
Table field, then activate the domain.
<P>
Now you will delete the foreign key on the -<TT>lfa1-land1</TT>
field and then create it again so that you can see the effect
of the Value Table field on the foreign key creation process.
To do so, follow the procedure below.
<OL>
<LI>Begin at the Dictionary: Initial Screen.
<LI>In the Object Name field, type the name of the table (-<TT><B>lfa1</B></TT>).
<LI>Choose the Tables radio button.
<LI>Press the Change button. The Dictionary: Table/Structure:
Change Fields screen is displayed.
<LI>Position your cursor on the foreign key field (<TT>land1</TT>).
<LI>Press the Foreign Keys button on the Application toolbar.
The Change Foreign Key screen is displayed.
<LI>Press the Delete button (the trashcan) at the bottom of the
window.
<LI>You are returned to the Dictionary: Table/Structure: Change
Fields screen. The message <I>Foreign key was deleted</I> appears
in the status bar.
<LI>With your cursor still positioned on the foreign key field
(<TT>land1</TT>), press the Foreign Keys button again. The Create
Foreign Key screen is displayed. It reads <I>Foreign key does
not exist. Generate proposal with value table as check table?</I>
You see this message box because the system has looked in the
domain and found a name in the Value Table field. It responds
by issuing this message box.
<LI>Press the Yes button. The Create Foreign Key screen is displayed,
and the Check Table field contains the value table from the domain.
The Check Table fields and Foreign Key fields are filled in.
<LI>Press the Copy button. You are returned to the Dictionary:
Table/Structure: Change Fields screen. The message <I>Foreign
key was transferred</I> appears in the status bar. The Status
fields read <TT>Revised</TT> and <TT>Not saved</TT>.
<LI>Press the Activate button. The message <I>was saved </I>appears
in the status bar. The Status fields read <TT>Act.</TT> and <TT>Saved</TT>.
</OL>
<P>
With a table name in the Value Table field in the domain you can
quickly and reliably create foreign keys. 
<H4>Rediscovering the CheckTable Column</H4>
<P>
The CheckTable column on the Dictionary: Table/Structure screen
performs two functions: 
<UL>
<LI>If a field is a foreign key, the CheckTable column will contain
the name of the check table for that field.
<LI>An asterisk (*) in this column means that a check table has
not been defined for the field, but a value table exists in the
domain. 
</UL>
<P>
There is an exception to the second point above. If you are currently
displaying a value table, the asterisk will not appear in the
field whose domain references the value table you are viewing.
<H4>Using the Value Table as a List of Possible Values</H4>
<P>
If a field contains a value table but is not a foreign key, when
that field appears on a screen no validation is done on the field.
The value table does not perform validation. Only a foreign key
validates values.
<P>
With only a value table, a down-arrow will not appear at the end
of the field as it does for a foreign key field. However, if you
place your cursor in the field and press F4, the F4 key will still
display a list of values from the value table. There is no indication
on the screen that F4 functionality is available, and no checking
is done if a value is entered in the field.
<P>
This functionality could be useful when you want to provide the
user with a list of suggested values but want to allow other values
to be typed into the field as well.
<H2><A NAME="SpecialTableFields"><FONT SIZE=5 COLOR=#FF0000>
Special Table Fields</FONT></A></H2>
<P>
Two types of table fields need special treatment: 
<UL>
<LI>currency fields
<LI>quantity fields
</UL>
<H3><A NAME="CurrencyFields">
Currency Fields</A></H3>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
Assume you go to the bank and ask for 1000. The teller would probably
ask you &quot;1000 what?&quot;. You might reply &quot;1000 dollars.&quot;
Or you might be even more specific and ask for &quot;1000 U.S.
dollars.&quot; Monetary amounts in R/3 are stored in two fields:
one to hold the actual numeric amount (1000) and one to hold the
currency (USD). The numeric amount field is called the <I>currency
field</I> and the other field is called the <I>currency key field</I>.
<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>TIP</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
What many people refer to as currency is actually a currency code (USD for U.S. dollar, CAD for Canadian dollar, and so on). SAP uses the word &quot;key&quot; as a synonym for &quot;code,&quot; so it calls the field containing the currency code the &quot;currency key.&quot; This applies to most code fields in R/3; the country code is called the country key, the region code is the region key, and so on.</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<P>
<P>
Currency fields have these requirements:
<UL>
<LI>The data type in the domain must be <TT>CURR</TT>.
<LI>It must be linked to a field of type <TT>CUKY</TT> containing
the currency key, such as USD (US dollars), CAD (Canadian dollars),
ITL (Italian lira), and so on.
</UL>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
The currency key is known as the <I>reference field.</I> It is
another field in the same or another table. It must have the type
<TT>CUKY</TT> (currency key) in the domain. It indicates the currency
key for the currency field that it references.
<P>
For example, assume you create a table containing a list of payments
made to vendors. You would need a payment amount field (field
name <TT>wrbtr</TT>) and a currency key field (usually <TT>waers</TT>)
to completely indicate the amount and currency key used for that
payment. To link the two fields together, you would double-click
on the currency <I>field name</I> in the table and then enter
the currency key table and field name in the fields Reference
Table and Reference Field (see Figure 4.14).
<P>
<A HREF="javascript:popUp('f4-14.gif')"><B>Figure 4.14:</B> <I>The reference fields on the Display Field
screen</I>.</A>
<H3><A NAME="QuantityFields">
Quantity Fields</A></H3>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
A <I>quantity field</I> is a field that contains a numeric measurement.
For example, such a field might contain a measure of weight, length,
temperature, or electricity. To be meaningful, a unit of measure
such as pounds, inches, Fahrenheit, or kilovolts must accompany
it. Quantity fields have these requirements:
<UL>
<LI>The data type in the domain must be <TT>QUAN</TT>.
<LI>It must be linked to a field of type <TT>UNIT</TT>.
</UL>
<P>
The <TT>UNIT</TT> field is the reference field for the <TT>QUAN</TT>
field. The <TT>UNIT</TT> field can be in the same table or in
another table. The <TT>UNIT</TT> field contains the measurement
unit for the measurement in the quantity field.
<P>
For example, in table <TT>ztxmara</TT>, the <TT>ntgew</TT> field
contains the net weight of a material and the <TT>gewei</TT> field
contains the units, such as pounds or kilograms (see Figure 4.15).
The <TT>ntgew</TT> field has a data type of <TT>QUAN</TT> and
the data type of <TT>gewei</TT> is <TT>UNIT</TT>. If you double-click
on <TT>ntgew</TT>, you will see that the reference table is <TT>ztxmara</TT>
and the reference field is <TT>gewei</TT> (see Figure 4.16).
<P>
<A HREF="javascript:popUp('f4-15.gif')"><B>Figure 4.15: </B><I>This is the structure of the ztxmara table
showing the ntgew and gewei fields</I>.</A>
<P>
<A HREF="javascript:popUp('f4-16.gif')"><B>Figure 4.16:</B> <I>These are the field attributes for the
ntgew field. Notice that the two fields Reference Table and Reference
Field provide the link to the UNIT field</I>.</A>
<H2><A NAME="StructuresintheDataDictionary"><FONT SIZE=5 COLOR=#FF0000>
Structures in the Data Dictionary</FONT></A></H2>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
In addition to tables, <I>structures</I> can also be defined in
the Data Dictionary. As you might expect, a structure is a series
of fields grouped together under a common name. It is very similar
to a table. Like a table, it can be used within a program on the
<TT>tables</TT> statement to define a work area. 
<P>
The differences between a structure and a table are as follows:
<P>
A structure doesn't have an associated
database table.
<UL>
<LI>A structure doesn't have a primary key.
<LI>A structure doesn't have technical attributes.
</UL>
<P>
Structures follow the same naming conventions as transparent tables,
and you cannot have a table and structure of the same name.
<P>
You would create a structure in the DDIC if you wanted to define
the same work area in multiple programs. For example, if you wanted
to write records to a sequential file using one ABAP/4 program
and then read them in using another, both programs need to know
the layout of those records. You would create a structure in the
DDIC that defines the record layout, and then name that structure
on the <TT>tables</TT> statement in both programs. This would
create an identical work area in both programs.
<P>
The procedure for creating a structure is almost the same as for
creating a transparent table. (Please refer to the procedures
for creating a transparent table.) The only differences are the
following:
<UL>
<LI>Instead of the Tables radio button, choose the Structures
radio button.
<LI>The Delivery Class and Tab.Maint.Allowed fields do not appear.
<LI>Structures do not have a primary key.
<LI>No technical attributes can be specified, such as data class,
size category, or buffering.
</UL>
<H3><A NAME="UnderstandingIncludes">
Understanding Includes</A></H3>
<P>
A structure can contain another structure. In other words, you
can nest structures one within another. This can be used to reduce
maintenance by grouping fields together into a structure and then
including that structure within another structure, or even within
a table.
<P>
For example, a person's address is composed of a set of fields
such as street, city, region, country, and postal code. You might
need to keep such an address in multiple tables. Within the vendor
table you might want to keep the vendor's address, in the customer
master the customer's address, and in the employee table the employee's
address. If you create a structure to group the fields that form
the address together, you could then include that structure into
the table definitions. When the table is activated, the fields
of the structure are added to and exist in the database table
as if they were 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -