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

📄 ch07.htm

📁 这个是sap开发语言abap的教育文档
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<LI>When using the <TT>like</TT> addition, the value<I> </I>is
<I>not </I>obtained from the referenced variable. You can specify
the <TT>value</TT> addition to give the parameter a default value.
If you do not, it is assigned a default initial value of <TT>0</TT>
(or blank for a character data type).
<LI>Like <TT>data</TT>, the <TT>parameters</TT> statement can
appear anywhere in a program, but the definition must physically
come before the statements that access it.
<LI>Parameters appear on a selection screen in the same order
that they are defined in the program.
<LI>All <TT>parameters</TT> statements, no matter where they appear
in the program, are collected together by the ABAP/4 interpreter
and displayed on the selection screen <BR>
at the same time. Even if you put a <TT>parameter</TT> statement
in the middle of the program, that parameter will still be displayed
on the selection screen before the program executes.
<LI>The parameters are displayed in an SAP standard format. To
modify their appearance, for example, to move the input field
left or move the label right, use the <TT>selection-screen</TT>
statement, described in Day 21.
</UL>
</BLOCKQUOTE>
<H5>Using the Addition: lower case</H5>
<BLOCKQUOTE>
All  values entered into a parameter are translated into uppercase
by default. To turn off this translation, use the addition <TT>lower
case</TT>. This addition only applies to character fields.
</BLOCKQUOTE>
<H5>Using the Addition: as checkbox</H5>
<BLOCKQUOTE>
A check box has only two states: ticked and clear. You use them
when you want to present the user with an on/off or true/false
type of choice. You can use more than one check box on a screen.
If you have multiple check boxes on a screen, they operate completely
independently from each another.
</BLOCKQUOTE>
<BLOCKQUOTE>
To display a parameter as a check box, use the addition <TT>as
checkbox</TT>. You cannot specify a data type or length; it will
default to type <TT>c</TT> and length <TT>1</TT>. The parameter
will contain a capital <TT>X</TT> if the check box is ticked;
it will contain a blank if the check box is clear. If the check
box should initially contain a tickmark, use a default value of
capital <TT>X</TT>. Run program <TT>ztx506 to see the check box</TT>.
</BLOCKQUOTE>
<BLOCKQUOTE>
Space and capital <TT>X</TT> are the only valid values. No other
values are valid for a check box.
</BLOCKQUOTE>
<H5>Using the Addition: radiobutton group g</H5>
<BLOCKQUOTE>
Like check boxes, a radio button also has two states: selected
and not selected. Unlike check boxes, radio buttons never operate
alone, they operate only in groups. You can have any number of
radio buttons in a group, but only one can be selected at a time.
They are used when you need to present the user with a list of
alternatives in which only one option can be chosen.
</BLOCKQUOTE>
<BLOCKQUOTE>
To display a parameter as a radio button, use the addition <TT>radiobutton
group <I>g</I></TT>. You cannot
specify a data type or length; it will default to type <TT>c</TT>
and length <TT>1</TT>. <TT><I>g</I></TT>
is an arbitrary group name one to four characters long. You can
have more than one group in a program.
</BLOCKQUOTE>
<BLOCKQUOTE>
The parameter will contain a capital <TT>X</TT> if the radio button
is selected; it will contain a blank if it is not selected. To
be initially selected, the radio button should contain a default
value of capital <TT>X</TT>. No other values are valid for a radio
button. Try it by running program <TT>ztx006</TT>.
</BLOCKQUOTE>
<H4>Parameter Input Field Labels</H4>
<P>
On the selection screen to the left of each parameter's input
field is a label. By default, the label is the same as the name
of the parameter. You can set these labels manually. For parameters
defined like Data Dictionary fields, you can retrieve the label
automatically from the data element.
<H5>Changing Parameter Labels</H5>

<IMG SRC="../button/screencam.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/screencam.gif">
</BLOCKQUOTE>
<BLOCKQUOTE>
Start the ScreenCam &quot;How to Change Input Field Labels&quot;
now.
</BLOCKQUOTE>
<BLOCKQUOTE>
To change a parameter's input field label:

<OL>
<LI>Begin at the ABAP/4 Editor: Edit Program screen.
<LI>Choose the menu path Goto-&gt;Text Elements<I>.</I> The ABAP/4
Text Elements screen is displayed. In the Program Field is your
current program name.
<LI>Select the Selection Texts radio button.
<LI>Press the Change button. The ABAP/4 Text Elements: Change
PARAMETERS/SELECT-OPTIONS screen is displayed. Here, you can manually
enter labels in the Text column.
<LI>Type field labels in the Text column.
<LI>For a parameter defined like a DDIC field, you can retrieve
labels from the data element. To retrieve a label from the data
element for a single field, position your cursor on the field
and choose the menu path Utilities-&gt;Copy DD Text<I>.</I> The
medium-length field label from the data element appears, the Text
field is protected, and the Type field changes to contain the
characters <TT>DDIC</TT>. At the bottom of the window the message
<TT>Dictionary texts transferred for selection <I>xxx</I></TT>
appears.
<LI>To remove protection from a single field, position your cursor
on the field and choose the menu path Utilities-&gt;No DD Text.
The Text field becomes unprotected and the characters <TT>DDIC</TT>
disappear from the Type field. At the bottom of the window the
message <TT>Text for <I>xxx</I>
no longer transferred from Dictionary.</TT> appears.
<LI>To retrieve field labels for all parameters that are defined
like DDIC fields, choose the menu path Utilities-&gt;Copy DD Texts.
Field labels for all DDIC fields are retrieved and protected.
Any existing values in the Text column are overwritten. At the
bottom of the window the message <TT>All selection texts transferred
from Dictionary</TT> appears.
<LI>Press the Save button on the Application toolbar. At the bottom
of the window, the message <TT>Text elements for program <I>xxxxx</I>
in language E accepted</TT> appears.
<LI>Press the Back button on the Application toolbar twice to
return to your program.
</OL>

If you want to override the DDIC label for some fields but not
others, type your labels in the Text column and then choose the
menu path Utilities-&gt;Supplement DD Texts. All blank Text fields
will be filled from the Data Dictionary, leaving the values you
entered alone.
</BLOCKQUOTE>
<BLOCKQUOTE>
If the label changes in the DDIC, the label onscreen is <I>not</I>
automatically updated. To update it, you must go to the ABAP/4
Text Elements: Change PARAMETERS/SELECT-OPTIONS screen and choose
either menu path Utilities-&gt;Copy DD Text or Utilities-&gt;Copy
DD Texts.<BR>
</BLOCKQUOTE>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>CAUTION</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
The <TT>value </TT>addition on the <TT>parameters </TT>statement, as with <TT>data</TT>, is not vali-dated for compatibility with the data type. Giving a check box or a radio button a default value other than space or capital <TT>X </TT>is invalid. Although a cursory evaluation might not disclose problems, in-depth testing has uncovered unpredictable behavior in test programs.
</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<BLOCKQUOTE>
</BLOCKQUOTE>
<H5>Effect of Parameter Definitions: type Versus like</H5>
<BLOCKQUOTE>
<I>Always use the </I><TT><I>like</I></TT><I>
addition to define a parameter</I>. When you use it, the parameter
acquires the following attributes from the Data Dictionary:

<UL>
<LI>F1 help is acquired from the Documentation button in the data
element.
<LI>F4 help is acquired if your parameter is like one that has
a check table.
</UL>

A field label is acquired from the data element.
</BLOCKQUOTE>
<BLOCKQUOTE>
In addition to the advantages provided by the above,

<UL>
<LI>A field label obtained from the Data Dictionary is guaranteed
to be consistent with the field label presented by other programs
for the same field (provided they also obtain them from the DDIC).
This eliminates the confusion of having two fields that are labeled
differently refer to the same data.
<LI>Modifications to the data type or length in the DDIC are automatically
reflected by your program.
</UL>
In view of all of these advantages, you should always use the
<TT>like</TT> addition to define a parameter. This applies even
to check boxes and radio buttons. If necessary, you should create
a structure in the DDIC so that you can use <TT>like</TT> and
at a minimum, provide F1 help. Note that F1 help is available
even for radio buttons and check boxes.
</BLOCKQUOTE>
<H5>Effect of a Check Table on a Parameter</H5>
<BLOCKQUOTE>
If you define a parameter using <TT>like st-f1</TT>, and <TT>st-f1</TT>
has a check table, a down arrow appears at the end of the input
field when you run the program. You can press the down arrow to
obtain a list of valid values for that field. However, the value
entered into a parameter input field is not validated against
the check table. Validation only occurs for dialog screens such
as those you have seen in transaction <TT>se16</TT>. The user
can type any value into the input field and it will be passed
to the program when he presses the Execute button.<BR>
</BLOCKQUOTE>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>NOTE</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
You can perform your own selection-screen validations. They are detailed on Day 21, &quot;Selection Screens.&quot;</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<BLOCKQUOTE>
</BLOCKQUOTE>
<H2><A NAME="Summary"><FONT SIZE=5 COLOR=#FF0000>
Summary</FONT></A></H2>
<UL>
<LI>Programs are buffered in a program buffer on the application
server. There is only one copy, so a roll area is necessary for
each execution. The roll area contains the values of program variables
and the current program pointer.
<LI>An ABAP/4 program is composed of statements, each of which
begins with a keyword and ends with a period. Statements can begin
in any column and can span several lines.
<LI>A data object is a memory location that contains data during
the runtime of the program. The non-modifiable data objects are
literals and constants. The modifiable data objects are variables,
field strings, and internal tables. Data objects are allocated
in the roll area of the program and are freed when the program
ends.
<LI>Data objects have three levels of visibility: local, global,
and external. The visibility of a data object indicates from where
the data object is accessible.
<LI>Literals are data that is hard-coded in your program. Constants
can be used to replace literals, thereby making the program easier
to maintain.
<LI>Data types are segregated into two broad categories: character
and numeric. The character data types are <TT>c</TT>, <TT>n</TT>,
<TT>d</TT>, <TT>t</TT>, and <TT>x</TT>; the numeric data types
are <TT>i</TT>, <TT>p</TT>, and <TT>f</TT>.
<LI>Variables can be defined using the <TT>data</TT> and <TT>parameters</TT>
statements. The difference is that when the program is executed,
the system displays an input field for each parameter on a selection
screen. The user can enter values or change default values.
<LI>Values entered into parameter input fields are by default
converted to uppercase. To stop the conversion, use the addition
<TT>lower case</TT>.
<LI>You can change the parameter input field labels via the menu
path Goto-&gt;Text Elements.
</UL>
<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>DO use an underscore to make your vari-able names easier to read.
</TD><TD WIDTH=288>DON'T use a dash in a variable name; a dash delimits the components of a field string.
</TD></TR>
</TABLE>
</CENTER>
<P>
<H2><A NAME="QampA"><FONT SIZE=5 COLOR=#FF0000>
Q&amp;A</FONT></A></H2>

<TABLE>
<TR VALIGN=TOP><TD WIDTH=48><CENTER><B>Q</B></CENTER></TD><TD><B>Why do I need to code uppercase between quotes? How will I know if I need to code lowercase?</B>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=48><CENTER><B>A</B></CENTER></TD><TD>Most of the time, the system automatically converts data to upper case before it is stored in the database. This conversion is performed by the domain. You can determine if the data is converted by looking at the domain. If the data type of the field is CHAR, and if the Lower Case checkbox is tickmarked, only then does the field contains mixed case.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=48><CENTER><B>Q</B></CENTER></TD><TD><B>Can I define a parameter that accepts multiple values from the user?</B>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=48><CENTER><B>A</B></CENTER></TD><TD>Yes, the select-options statement enables the user to enter multiple values and complex criteria. 
</TD></TR>
</TABLE>
<H2><A NAME="Workshop"><FONT SIZE=5 COLOR=#FF0000>
Workshop</FONT></A></H2>
<P>
The Workshop provides you two ways for you to affirm what you've
learned in this chapter. The Quiz section poses questions to help
you solidify your understanding of the material covered and the
Exercise section provides you with experience in using what you
have learned. You can find answers to the quiz questions and exercises
in Appendix B, &quot;Answers to Quiz Questions and Exercises.&quot;
<H3><A NAME="Quiz">
Quiz</A></H3>
<P>
What is wrong with these literals, if anything? (There can be
more than one error in each, and some do not have errors.) Write
the correct definitions.
<OL>
<LI>Character string literal: <TT>&quot;Don't bite.&quot;</TT>
<LI>Floating-point literal: <TT>'+2.2F03.3'</TT>
<LI>Numeric literal: <TT>-99</TT>
<LI>Hexadecimal literal: <TT>x'0000f'</TT>
<LI>Numeric literal: <TT>9.9-</TT>
<LI>Floating-point literal: <TT>'1.1E308'</TT>
<LI>Hexadecimal literal: <TT>'HA'</TT>
<LI>Character string literal: <TT>''''</TT>
<LI>Character string literal: <TT>'''&quot;'''</TT>
</OL>
<P>
What is wrong with these data definitions? (There can be more
than one error in each, and some do not have errors.) Write the
correct definitions.
<OL>
<LI><TT>data first-name(5) type c.</TT>
<LI><TT>data f1 type character.</TT>
<LI><TT>data f1 (20) type c.</TT>
<LI><TT>data 1a(5) type i.</TT>
<LI><TT>data per-cent type p value 55.5.</TT>
<LI>data f1(2) type p decimals 2 value '12.3'.
</OL>
<H3><A NAME="Exercise">
Exercise 1</A></H3>
<P>
Write a program using parameters for Figure 7.4.
<P>
<A HREF="javascript:popUp('f7-4.gif')"><B>Figure 7.4 :</B> <I>  </I>.</A>
<P>
<CENTER>
<HR SIZE=4>
<A HREF="../ch06/ch06.htm" tppabs="http://pbs.mcp.com/ebooks/0672312174/ch06/ch06.htm"><IMG SRC="../button/previous.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/previous.gif" BORDER="0"></A>
<A HREF="../index.htm" tppabs="http://pbs.mcp.com/ebooks/0672312174/index.htm"><IMG SRC="../button/contents.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/contents.gif" BORDER="0"></A> 
<A HREF="rev01.htm" tppabs="http://pbs.mcp.com/ebooks/0672312174/ch07/rev01.htm"><IMG SRC="../button/next.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/next.gif" BORDER="0"></A>
</P>
&#169; <A HREF="../copy.htm" tppabs="http://pbs.mcp.com/ebooks/0672312174/copy.htm">Copyright</A>, Macmillan Computer Publishing. All rights reserved.
</CENTER>
</BODY>
</HTML>

⌨️ 快捷键说明

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