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

📄 ch20.htm

📁 这个是sap开发语言abap的教育文档
💻 HTM
📖 第 1 页 / 共 5 页
字号:
want to change the interface, you only need to press the Display
<-> Change button and you will be allowed to change it in
any way you want. Remember, however, that you should not make
changes that can cause existing programs to abnormally terminate
or return different results.<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>
If you accidentally release a function module and want to cancel the release, go to the Function Module Display: Administation screen, press the Display &lt;-&gt;Change button, and choose the menu path Function Module-&gt;Release -&gt;Cancel Release. After choosing this menu path, press the Enter key to com-plete the cancellation process.</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<P>
<H2><A NAME="TestingaFunctionModule"><FONT SIZE=5 COLOR=#FF0000>
Testing a Function Module</FONT></A></H2>
<P>
If you want to test a function module without writing an ABAP/4
program, you can do it using the test environment within the Function
Library. Use the following procedure to access the test environment.
<P>
<img src="../button/screencam.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/screencam.gif">
<P>
Start the ScreenCam &quot;How to Use the Test Environment for
Function Modules&quot; now.
<OL>
<LI>Begin at the Function Library: Initial Screen. Type the name
of the function module you want to test in the Function Module
field.
<LI>Press the Test pushbutton. You will see the Test Environment
For Function Modules screen (shown in Figure 20.3).<BR>
<A HREF="javascript:popUp('f20-3.gif')"><B>Figure 20.3 : </B><I>The Test Environment for Function Modules
screen</I>.</A>
<LI>Type the parameters you want to supply for the test. To fill
an internal table, double-click on the internal table name. A
screen will be shown that enables you to enter data into the internal
table. (If you specified a Ref. Structure for the internal table,
the columns of the structure will be shown.) Type your data and
press the Enter key. You will be returned to the Test Environment
For Function Modules screen.
<LI>Press the Execute button on the Application toolbar to execute
the function module. You will see the Test Function Module: Result
Screen (see Figure 20.4). The output from <TT>write</TT> statements
within the function module appear first. In Figure 20.4, <TT>You
passed A</TT> is the result of a <TT>write</TT> statement within
the function module. Then, the length of time taken to execute
the function module (in microseconds) is shown. Following that,
the values of the parameters are shown, and the <TT>changing</TT>
and <TT>tables</TT> parameters have two values: the before and
after. For <TT>changing</TT> parameters, the &quot;before&quot;
value is shown first and the &quot;after&quot; value appears below
it. For <TT>tables</TT> parameters, the &quot;after&quot; contents
appear above the &quot;before&quot; (original) contents. In Figure
20.4, internal table <TT>it</TT> contained two lines after processing
and three lines before. To see the before or after contents of
the internal table, double-click on either line.<BR>
<A HREF="javascript:popUp('f20-4.gif')"><B>Figure 20.4 : </B><I>The Test Function Module: Result screen
showing the before and after values for the changing and tables
parameters</I>.</A>
</OL>
<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>
To save your test data and/or results, press the Save button either on the Test Environment screen or on the Result screen. To retrieve your saved information, press the Test Data Directory button on either screen. Test sequences can also be built using the Test Sequence button.</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<P>
<H2><A NAME="FindingExistingFunctionModules"><FONT SIZE=5 COLOR=#FF0000>
Finding Existing Function Modules</FONT></A></H2>
<P>
As stated before, SAP supplies more than 5,000 pre-existing function
groups containing more than 30,000 function modules. Often the
functionality you require is already covered by these SAP-supplied
function modules-you only need to find the right one. To find
an existing function module, use the Repository Information system.
The following procedure shows you how.
<P>
<img src="../button/screencam.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/screencam.gif">
<P>
Start the ScreenCam &quot;How to Search for Function Modules&quot;
now.
<OL>
<LI>From the ABAP/4 Development Workbench screen, choose the menu
path Overview -&gt; Repository Infosys. You see the ABAP/4 Repository
Information System screen shown in Figure 20.5.<BR>
<A HREF="javascript:popUp('f20-5.gif')"><B>Figure 20.5 : </B><I>The ABAP/4 Repository Information System
screen as it appears initially</I>.</A>
<LI>Expand the Programming line by clicking on the plus sign (<B>+</B>)
to the left of it. A subtree is shown below it.
<LI>Expand the Function Library line by clicking on the plus sign
(<B>+</B>) to the left of it. A subtree is shown below it. Your
screen should now look like Figure 20.6.<BR>
<A HREF="javascript:popUp('f20-6.gif')"><B>Figure 20.6 : </B><I>The ABAP/4 Repository Information System
screen with the Function Modules left exposed</I>.</A>
<LI>Double-click on the Function Modules line. The ABAP/4 Repository
Information System: Function Module screen is shown. Press the
All Selections button on the Application toolbar to display all
possible selection fields. Your screen should now appear as shown
in Figure 20.7. This is a selection screen in which you can enter
search criteria for finding function modules. All fields are case-insensitive
with the exception of the Short Description field, which is case
sensitive! <BR>
<A HREF="javascript:popUp('f20-7.gif')"><B>Figure 20.7 : </B><I>The ABAP/4 Repository Information System:
Function Module screen with all selections shown</I>.</A>
<LI>To search for a function module, either words or character
strings might be entered in the search fields. Use <B>+</B> and
* as wildcard characters. <B>+</B> will match any single character,
and * will match any sequence of characters. For example, enter
<B>*DATE*</B> in the Function Module field. This will find all
function modules that contain the characters <TT>DATE</TT> anywhere
in their name. Or, you might either enter <B>*Date*</B> or <B>*date*</B>
in the short description field (only one string is allowed in
this field).
<LI>To enter more than one value to search for, press the arrow
at the end of the field. The Multiple Selection screen is shown
(see Figure 20.8). The values you enter on this screen are <TT>OR</TT>ed
together. Type multiple selection criteria here. These values
are known as the included values, or simply the &quot;includes.&quot;
(This is a different usage of the term than when it refers to
include programs.)<BR>
<A HREF="javascript:popUp('f20-8.gif')"><B>Figure 20.8 : </B><I>The Multiple Selection screen</I>.</A>
<LI>Press the Options button to specify selection operators such
as equal, not equal, greater than, less than, and so on. You will
see the Maintain Selection Options screen, as shown in Figure
20.9. To be able to specify Pattern or Exclude Pattern, your value
must contain a pattern-matching character: either <B>+</B> or
*. Press the Copy button to return to the Multiple Selection screen.
<BR>
<A HREF="javascript:popUp('f20-9.gif')"><B>Figure 20.9 : </B><I>The Maintain Selection Options screen</I>.</A>
<LI>On the Multiple Selection screen, press the Complex Selection
button. The Multiple Selection screen is reshown, but this time
there is a scroll bar on the right side and Ranges fields appear
(see Figure 20.10). To specify values that should be excluded
from the search, scroll down and enter them within the box titled
...But Not (see Figure 20.11). These values are known as the excluded
values, or more simply, the excludes.<BR>
<A HREF="javascript:popUp('f20-10.gif')"><B>Figure 20.10: </B><I>The Multiple Selection screen with a scroll
bar on the right side and Ranges fields</I>.</A><BR>
<A HREF="javascript:popUp('f20-11.gif')"><B>Figure 20.11: </B><I>The ...But Not box</I>.</A>
<LI>Press the Copy button to copy your selection criteria back
to the selection screen. You are returned to the ABAP/4 Repository
Information System screen, and if you entered multiple selection
criteria, the arrow at the end of the line is green to show that
more than one selection criterion exists (see Figure 20.12).<BR>
<A HREF="javascript:popUp('f20-12.gif')"><B>Figure 20.12: </B><I>The ABAP/4 Repository Information System
screen. The green arrow at the end of the line shows that more
than one selection criterion exists</I>.</A>
<LI>To begin the search, press the Execute button. The search
results are determined as if separate searches had been done for
all of the include criteria, and then the results <TT>OR</TT>ed
together. Then, if excludes have been specified, they are applied
one entry after the other. For example, in the Short Description
field, suppose you specified the includes *Date* and *date* and
excludes of *Update* and *update*. All of the descriptions containing
*Date* will be found, and then all of the descriptions contains
*date* will be <TT>OR</TT>ed with the first result set. Then all
of the descriptions containing *Update* will be removed, and then
all of those containing *update* will be removed. The result will
contain the strings &quot;Date&quot; or &quot;date&quot; without
&quot;Update&quot; and &quot;update.&quot; You see the results
on the Function Modules screen (see Figure 20.13). The number
of function modules found is indicated in the title bar within
parentheses.<BR>
<A HREF="javascript:popUp('f20-13.gif')"><B>Figure 20.13: </B><I>The Function Modules screen</I>.</A>
<LI>To display a function module, double-click on it. The Function
Module Display: Documentation screen is shown (see Figure 20.14).
This screen shows you all the interface parameters and their documentation.
To see more documentation, double-click on a parameter name (see
Figure 20.15). To return to the interface documentation, press
the Back button. To return to the function module list, press
the Back button again.<BR>
<A HREF="javascript:popUp('f20-14.gif')"><B>Figure 20.14: </B><I>The Function Module Display: Documentation
screen</I>.</A><BR>
<A HREF="javascript:popUp('f20-15.gif')"><B>Figure 20.15: </B><I>The additional documentation for a parameter</I>.</A>
</OL>
<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>
Not all parameters have additional documentation. If the parameter you double-clicked on doesn't have any more documentation, nothing happens when you double-click on it.</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<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>
If, when you look at the title bar on the Function Modules screen, the number of function modules found is exactly 500, then you have probably hit the maximum list size. Return to the selection screen and look in the Maximum No. of Hits field. If it is also 500, you hit the maximum. You might be tempted to increase the maximum number of hits, but this will rarely be productive because you probably won't read an entire list of 500 function modules. Refine your search criteria to reduce the number of hits.</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<P>
<P>

<OL START=12>
<LI>To test a function module, put your cursor on it and press
the Test/Execute button (it looks like a little monkey wrench).
You will be shown the Test Environment Screen for that function
module.
</OL>
<H2><A NAME="ExploringtheComponentsofyourFunctionGroup"><FONT SIZE=5 COLOR=#FF0000>
Exploring the Components of your Function Group</FONT></A></H2>
<P>
After creating your first function module, use the following procedure
and take a few minutes to explore the components of the function
group. You should become familiar with the structure that you
have just created.
<P>
<img src="../button/screencam.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/screencam.gif">
<P>
Start the ScreenCam &quot;Exploring the Components of Your Function
Group&quot; now.
<OL>
<LI>Begin on the Function Library Initial Screen. If it is not
already there, type the name of your function module in the Function
Module field.
<LI>Choose the Administration radio button and then press the
Change pushbutton. The Function Module Change: Administration
screen is displayed (see Figure 20.16). At the top of the screen
in the Function Group field you can see the ID of the function
group to which this function module belongs. In the bottom right
corner in the Program field, you can see the name of the main
program for the function group. In the Include field is the name
of the <TT>include</TT> that contains the source code for the
function module. The last field shows the status of the function
module: Active or Inactive. Press the Back button to return to
the Function Library Initial Screen.<BR>
<A HREF="javascript:popUp('f20-16.gif')"><B>Figure 20.16: </B><I>This is the way the Function Module Create:
Administration screen appears after the function module has been
created</I>.</A>
<LI>Choose the Import/Export Parameter Interface radio button
and then press the Change pushbutton. The Import/Export Parameters
screen is shown. Press the Back button to return to the Function
Library Initial Screen.
<LI>Choose the Table Parameters/Exceptions Interface radio button
and then press the Change pushbutton. The Function Module Change:
Table Parameters/Exceptions screen is shown. Here you can enter
or change internal table parameters and exception names. Press
the Back button to return.
<LI>Choose the Documentation radio button and then press the Change
pushbutton. The Function Module Change: Documentation screen is
shown. Here you can enter a short description for each parameter
and exception in the interface. Press the Back button to return.
<LI>Choose the Source Code radio button and then press the Change
pushbutton. The Function Module: Edit screen is shown. Press the
Back button to return.
<LI>Choose the Global Data radio button and then press the Change
pushbutton. <BR>
The Function Module: Edit screen is shown. This time, however,
you are editing the top <TT>include</TT>. Notice the name of the
top <TT>include</TT> in the title bar. It conforms to the naming
convention <TT>l<I>fgid</I>top</TT>,
where <TT><I>fgid</I></TT> is
the name of your function group. Here you can define global variables
and <TT>tables</TT> work areas that are common to all function
modules within the function group. If your function modules use
the <TT>message</TT> statement, you can also define the default
message class (on the <TT>function-pool</TT> statement). Press
the Back button to return.
<LI>Choose the Main Program radio button and press the Change
pushbutton. The Function Module: Edit screen is shown. This time,
you are editing the main program (refer to Figure 20.17). Notice
the name within the title bar begins with <TT>sapl</TT> followed
by your function group ID. The two <TT>include</TT> statements
incorporate the top <TT>include</TT> and the UXX into the main
program. Double-clicking on the top <TT>include</TT> name will
enable you to edit it. Press the Back button to return to the
main program. Double-clicking on the UXX will display the include
program source code-it contains the statements that include the
function modules into the group. Their names are indicated within
comments at the end of each <TT>include</TT> statement. You are
not allowed to modify the UXX. Double-clicking on any of the <TT>include</TT>
statements will display the source code for a function module
within the group. Press the Back button to return.
</OL>
<P>
<A HREF="javascript:popUp('f20-17.gif')"><B>Figure 20.17: </B><I>This is the main program for the z_tx_div
function module</I>.</A><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>
To copy, rename, or delete a function module, use the Copy, Rename, or Delete buttons on the Function Library: Initial Screen.</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<P>
<H2><A NAME="FindingandFixingErrorsinFunctionModules"><FONT SIZE=5 COLOR=#FF0000>
Finding and Fixing Errors in Function Modules</FONT></A></H2>
<P>

⌨️ 快捷键说明

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