📄 ch02.htm
字号:
<LI>New features of the ABAP/4 language
<LI>Display function modules
<LI>Display table structures
<LI>Display logical databases
<LI>Display authorization objects
<LI>Display infotypes
</UL>
<H2><A NAME="FindingYourDevelopmentObjects"><FONT SIZE=5 COLOR=#FF0000>
Finding Your Development Objects</FONT></A></H2>
<P>
<img src="../button/screencam.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/screencam.gif">
<P>
Start the ScreenCam "Finding Your Development Objects"
now.
<P>
To display all of the development objects you have created in
the R/3 system:
<OL>
<LI>From the ABAP/4 Development Workbench screen, press the Object
Browser button. The Object Browser: Initial Screen is displayed.
<LI>Choose the radio button Local Priv. Objects.
<LI>Press the Display pushbutton. The Object Browser: Development
Class $TMP screen is displayed. Here you will see a list of development
object categories. To the left of each category is a plus sign.
<LI>Click once on a plus sign to expand the node.
<LI>Double-click on an object name to display it. If the object
you double-clicked on was a program, a tree view of the program
and its components is displayed.
<LI>To display the program source code, double-click on the name
of the program at the top of the tree. The ABAP/4 Editor: Display
Program screen is displayed.
</OL>
<P>
You are now in display mode on the selected object. You can press
the Display <-> Change button to switch into edit mode.
<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>NOTE</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
This method only works for objects that have been saved as local objects. They will be displayed here only if you pressed the Local Object button on the Create Object Catalog Entry screen when you created the object.</BLOCKQUOTE>
</TD></TR>
</TABLE>
</CENTER>
<P>
<P>
If you are looking for a program and you know the first few characters
of its name, you can find it from the ABAP/4 Editor: Initial Screen.
To do this:
<OL>
<LI>Go to the ABAP/4 Editor: Initial Screen.
<LI>In the Program field, type the first few characters of your
program name followed by an asterisk. For example, to display
all programs beginning with <TT>ztx</TT>, type <TT>ztx*</TT>.
<LI>Click on the down-arrow to the right of the Program field.
The Programs screen is displayed. A list of matching program names
appears on this screen. To the right of each program name is the
Short description from the program attributes.
<LI>Double-click on the program name you want to edit. The ABAP/4
Editor: Initial Screen is displayed, and the program name you
double-clicked on appears in the Program field.
</OL>
<H2><A NAME="IntroducingtheRDataDictionary"><FONT SIZE=5 COLOR=#FF0000>
Introducing the R/3 Data Dictionary</FONT></A></H2>
<P>
The <I>R/3 Data Dictionary</I> (or <I>DDIC</I> for short) is a
utility for defining data objects. Using the DDIC, you can create
and store objects such as tables, structures, and views. To invoke
the Data Dictionary, perform these steps:
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<OL>
<LI>Go to the ABAP/4 Development Workbench screen.
</OL>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
<OL start=2>
<LI>Press the ABAP/4 Dictionary button in the Standard toolbar.
The Dictionary: Initial Screen is displayed, as shown in Figure
2.8.
</OL>
<P>
<A HREF="javascript:popUp('f2-8.gif')"><B>Figure 2.8.</B><I>The Dictionary: Initial Screen</I>.</A>
<P>
The DDIC is within the R/3 system. You can think of it as sitting
on top of a database such as Oracle or Informix and acting like
a remote control, generating and sending SQL statements to it.
For example, you might create a table definition in the DDIC.
When you <I>activate</I> the table definition, SQL statements
are generated and sent to the RDBMS, causing it to create the
actual table in the database. When you want to modify the table,
you must modify the table definition in the DDIC. When you activate
the table again, more SQL is generated causing the RDBMS to modify
the table.<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1>
<TR VALIGN=TOP><TD WIDTH=288><CENTER><B>DO</B></CENTER></TD><TD WIDTH=288><CENTER><B>DON'T</B></CENTER>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=288>you must modify the table definition in the DDIC. When you activate the table again, more SQL is generated causing the RDBMS to modify the table.
</TD><TD WIDTH=288>DO use the DDIC to create and modify all database objects.
</TD></TR>
</TABLE>
</CENTER>
<BLOCKQUOTE>
DON'T modify a table or anything else at the RDBMS level. The
Data Dictionary definition cannot update itself and it will be
out of sync with the database. This can cause application errors
and even lead to a loss of data integrity.<BR>
</BLOCKQUOTE>
<H3><A NAME="ExploringTablesandStructures">
Exploring Tables and Structures</A></H3>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
In R/3 a <I>table</I> is a collection of rows. Each row contains
fields, also called <I>columns</I>. Normally, within a table,
each row has the same number of columns as the other rows of the
table.
<P>
A table holds persistent data. In other words, if you put data
into a table, it remains there after your program ends. It will
remain there until it is changed or deleted by your program or
another program. The name of a table is unique within the entire
R/3 system.
<P>
When you look at a table in the DDIC, you are looking at the description
of a table in the underlying database. You are not looking directly
at the database table itself. Figure 2.9 shows how a table definition
appears in the R/3 DDIC.
<P>
<A HREF="javascript:popUp('f2-9.gif')"><B>Figure 2.9.</B><I>The DDIC definition for table lfa1</I>.</A>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
In R/3 a <I>structure</I> is a description of a group of fields.
It describes the field names, their sequence, and their data types
and lengths. Each structure has a name that is unique within the
entire R/3 system. A structure cannot have the same name as a
table.
<P>
A structure name can be used in two ways:
<UL>
<LI>In a program, a structure name can be used to allocate memory
for a group of fields.
<LI>In a table, a structure name can be used to describe a set
of fields.
</UL>
<P>
Strictly speaking, a structure is something that only exists within
the R/3 Data Dictionary. If you see the word <I>structure</I>,
you should immediately think "DDIC structure." However,
some SAP documentation uses the word structure to also refer to
a group of variables within a program. The structure <TT>emara</TT>
is shown in Figure 2.10 as an example of how a structure appears
in the DDIC.
<P>
<A HREF="javascript:popUp('f2-10.gif')"><B>Figure 2.10.</B><I>The DDIC definition for structure emara</I>.</A>
<P>
In R/3, tables and structures are both defined in the DDIC. You
will notice however, when viewing them, there is very little difference
between them. That is because in R/3, a table is just a <I>description</I>
of an actual database table. It is the <I>structure of the table
in the database</I>. So, both tables and structures within the
DDIC define a layout-a series of fields. The major difference
between the two is that a table has an underlying database table
associated with it. A structure does not.
<P>
Some people find the R/3 documentation confusing at times, since
SAP occasionally uses these two terms interchangeably.
<H3><A NAME="DisplayingaTableorStructureDefinition">
Displaying a Table or Structure Definition</A></H3>
<P>
To display a table or structure definition in the DDIC:
<OL>
<LI>Go to the Dictionary: Initial Screen.
<LI>Enter the table or structure name in the Object Name field.
<LI>Click the Tables or Structures radio button.
<LI>Click the Display button. The Dictionary: Table/Structure:
Display Fields screen is displayed, as shown in Figures 2.9 and
2.10.
</OL>
<P>
What you see in Figure 2.9 is the <I>structure</I> of table <TT>lfa1</TT>
in the R/3 Data Dictionary, not the actual database table. In
R/3, only a table's<I> </I>structure can be defined, along with
some attributes such as the primary key fields.
<H3><A NAME="DisplayingDataintheTable">
Displaying Data in the Table</A></H3>
<P>
R/3 also provides a utility to enable you to display data that
exists within a table. To use it:
<OL>
<LI>Go to the Dictionary: Table/Structure: Display Fields screen.
<LI>Choose the menu path Utilities->Table contents. The Data
Browser: Table: Selection Screen is displayed.
<LI>To display <I>all</I> of the rows in the table, press the
Execute button without entering any search criteria. The Data
Browser: Table Select Entries screen is displayed (see Figure
2.11).
</OL>
<P>
<P>
<A HREF="javascript:popUp('f2-11.gif')"><B>Figure 2.11.</B><I>The Data Browser: Table Select Entries
screen</I>.</A>
<P>
The number of records displayed is limited by the value in the
Maximum No. Of Hits field on the Data Browser: Table: Selection
Screen.<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>CAUTION</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
Don't blank out the Maximum No. Of Hits field to display all records unless you actually intend to look through the entire list. For large tables, this can consume a lot of CPU on both the database and application servers and also significantly increase network traffic, thereby slowing down the system. If such a large report is needed, it should usually be run in batch. The preferred approach is to narrow down your search by entering values into the fields on the Data Browser: Table: Selection Screen. This will be covered in detail in a later chapter.</BLOCKQUOTE>
</TD></TR>
</TABLE>
</CENTER>
<P>
<H3><A NAME="DeterminingDisplayedFields">
Determining Displayed Fields</A></H3>
<P>
You can control which fields are displayed on the Data Browser:
Table: Selection Screen. To do so:
<OL>
<LI>Go to the Data Browser: Table: Selection Screen.
<LI>Choose the menu path Settings->Fields for selection. The
Choose Fields For Selection screen is displayed.
<LI>Tickmark the fields you want included on the Data Browser:
Table: Selection Screen. Uncheck any that you don't want to appear.
<LI>Press the Execute button. The Data Browser: Table: Selection
Screen is displayed and contains the fields you selected.
</OL>
<H2><A NAME="UnderstandingABAPSyntax"><FONT SIZE=5 COLOR=#FF0000>
Understanding ABAP/4 Syntax</FONT></A></H2>
<P>
Before continuing, you should now run the exercise setup utility
supplied on the CD-ROM. It will create the tables and data needed
for the exercises in this book. For instructions, see the <TT>readme.txt</TT>
file located in the root directory of the CD-ROM.
<H3><A NAME="IntroducingtheTTFONTSIZEselectFONTTTFONTSIZEStatementFONT">
Introducing the <TT>select</TT>Statement</A></H3>
<P>
The <TT>select</TT> statement retrieves records from the database.
<H4>Syntax for the <TT>select</TT> Statement</H4>
<P>
The following code shows simplified syntax for the <TT>select</TT>
statement:
<BLOCKQUOTE>
<PRE>
select * from <I>t1</I> [into <I>wa</I>] [where <I>f1</I> <I>op</I> <I>v1</I> and/or <I>f2</I> <I>op</I> <I>v2</I> ...]
[order by <I>f1</I>].
(other abap/4 statements)
endselect.
</PRE>
</BLOCKQUOTE>
<P>
where:
<BLOCKQUOTE>
<TT>*</TT> indicates that all fields in the table should be retrieved.
</BLOCKQUOTE>
<BLOCKQUOTE>
<TT><I>t1</I></TT> is the name
of a table previously defined on a <TT>tables</TT> statement.
<BR>
<TT><I>wa</I></TT> is the name
of work area that matches the structure of the table.<BR>
<TT><I>f1</I></TT> is the name
of a field in table <TT><I>t1</I></TT>.
<BR>
<TT><I>op</I>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -