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

📄 ch15.htm

📁 这个是sap开发语言abap的教育文档
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<CENTER>
<TABLE BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>NOTE</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
Technically, events can appear in any order or position within your program. For now code them as shown. A subsequent chapter will explain more about how to code events.</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<P>
<P>
<IMG SRC="../button/input.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/input.gif">
<HR>
<P>
<B>Listing 15.8&nbsp;&nbsp;top-of-page and end-of-page Events
<BR>
</B>
<BLOCKQUOTE>
<PRE>
1  report ztx1508 line-count 20(3) no standard page heading.
2  do 80 times.
3      write: / 'Please kick me', sy-index, 'times'.
4      enddo.
5 
6  top-of-page.
7    write: / 'CONFIDENTIAL',
8           / 'This page begins with number', sy-index.
9    uline.
10
11 end-of-page.
12   write: / sy-uline,
13          / 'The number of kicks at the top of the next page will be',
14             sy-index,
15          / 'Copyright 1998 by the ALA (Abuse Lovers Of America)'.
</PRE>
</BLOCKQUOTE>
<HR>
<P>
<IMG SRC="../button/output.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/output.gif">
<P>
The first part of the output for Listing 15.8 appears as follows:
<BLOCKQUOTE>
<PRE>
CONFIDENTIAL                                                            
This page begins with number          1
------------------------------------------------------------------
Please kick me          1  times                                        
Please kick me          2  times                                        
Please kick me          3  times                                        
Please kick me          4  times                                        
Please kick me          5  times                                        
Please kick me          6  times                                        
Please kick me          7  times                                        
Please kick me          8  times                                        
Please kick me          9  times                                        
Please kick me         10  times                                        
Please kick me         11  times                                        
Please kick me         12  times                                        
Please kick me         13  times                                        
Please kick me         14  times                                        
------------------------------------------------------------------
The number of kicks at the top of the next page will be         15      
Copyright 1998 by the ALA (Abuse Lovers Of America)
CONFIDENTIAL                                                            
This page begins with number         15
------------------------------------------------------------------
Please kick me         15  times
Please kick me         16  times
Please kick me         17  times
Please kick me         18  times
</PRE>
</BLOCKQUOTE>
<P>
<IMG SRC="../button/analysis.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/analysis.gif">
<UL>
<LI>Line 1 suppresses the use of standard page headers because
we only want the manual page headers to be shown. It also sets
the number of lines in the footer area to <TT>3</TT>. The number
of lines per page is set to <TT>20</TT> so we can test the page
footer code online. Normally an online report does not specify
the number of lines per page.
<LI>The first time through the loop, line 2 triggers the <TT>top-of-page</TT>
event on line 6, causing lines 7 through 9 to write two header
lines followed by an underline. Control returns to line 3 and
the <TT>write</TT> statement writes to the fourth line in the
output list.
<LI>After looping 14 times, the 15th <TT>write</TT> statement
triggers the <TT>end-of-page</TT> statement on line 11. Lines
12 through 15 are executed, writing out the footer. The <TT>top-of-page</TT>
statement on line 6 is then executed, and lines 7 through 9 write
the page heading at the top of the next page. Then control returns
to line 3 and the <TT>write</TT> statement writes to the fourth
line on page 2.
<LI>No page footer is written at the bottom of the last page.
</UL>
<H4>Using the reserve Statement</H4>
<P>
Sometimes you may need to write out information that belongs together,
but spread over multiple lines. For example, you may write the
vendor number and name on one line, followed by the address on
the next line, and the telephone numbers on the line after that.
It would make sense to keep these lines together as a group in
the output, and prevent them from being spread across two pages.
<P>
Use the <TT>reserve</TT> statement to keep a group of lines together
in the output list.
<H5>Syntax for the reserve Statement</H5>
<BLOCKQUOTE>
<PRE>
reserve <I>n</I> lines.
</PRE>
</BLOCKQUOTE>
<BLOCKQUOTE>
where:

<UL>
<LI><TT><I>n</I></TT> is a numeric
literal or variable.
</UL>

When the <TT>reserve</TT> statement is executed, the system checks
to see if there are <TT><I>n</I></TT>
lines available on the current page. If there are fewer than <TT><I>n</I></TT>
lines left on the current page, a page break is generated. This
triggers the <TT>end-of-page</TT> event (if it exists), followed
by the <TT>top-of-page</TT> event (if it exists). The next <TT>write</TT>
statement begins at the top of the new page.
</BLOCKQUOTE>
<BLOCKQUOTE>
If at least <TT><I>n</I></TT>
lines are available when the <TT>reserve</TT> statement is executed,
it does nothing.
</BLOCKQUOTE>
<BLOCKQUOTE>
Listing 15.9 shows a sample program that uses the <TT>reserve</TT>
statement.
</BLOCKQUOTE>
<P>
<IMG SRC="../button/input.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/input.gif">
<HR>
<P>
<B>Listing 15.9&nbsp;&nbsp;The reserve Statement<BR>
</B>
<BLOCKQUOTE>
<PRE>
1  report ztx1509 line-count 18(2) no standard page heading.
2  tables ztxlfa1.
3 
4  select * from ztxlfa1.
5      reserve 3 lines.
6      write: / ztxlfa1-lifnr, ztxlfa1-name1,
7             / ztxlfa1-stras, ztxlfa1-regio, ztxlfa1-land1,
8             / ztxlfa1-telf1.
9      skip.
10     endselect.
11
12 top-of-page.
13     write / 'Vendor Report'.
14     uline.
15
16 end-of-page.
17     uline.
18     write: / 'Report', sy-repid, ' Created by', sy-uname.
</PRE>
</BLOCKQUOTE>
<HR>
<P>
<IMG SRC="../button/output.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/output.gif">
<BLOCKQUOTE>
The code in Listing 15.9 produces the following output:
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>
Vendor Report                                         
-----------------------------------------------
1000       Parts Unlimited                            
111 Queen St.                       ON  CA            
416-255-1212                                          
                                                      
1010       Industrial Pumps Inc.                      
1520 Avenue Rd.                     ON  CA            
416-535-2341                                          
                                                      
1020       Chemical Nation Ltd.                       
123 River Ave.                      ON  CA            
416-451-7787                                          
                                                      
                                                      
                                                      
-----------------------------------------------
Report ZTX1209   Created by KENGREENWOOD              

Vendor Report                                         
-----------------------------------------------
1030       ChickenFeed Ltd.                           
8718 Wishbone Lane                  AB  CA            
393-565-2340                                          
                                                      
1040       Motherboards Inc.                          
64 BitBus Blvd.                     MA  US            
617-535-0198                                          
</PRE>
</BLOCKQUOTE>
<P>
<IMG SRC="../button/analysis.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/analysis.gif">
<P>
Line 5 determines if there is space for three more lines on the
current page. If there is, it does nothing and line 6 writes out
vendor information over the next lines. If there isn't, it triggers
the <TT>end-of-page</TT> event (lines 15 through 17), and then
issues a page break. It then triggers the <TT>top-of-page</TT>
event (lines 11 through 13). Then the <TT>write</TT> statement
on line 6 is executed and the lines are written at the top of
the new page.
<H2><A NAME="Summary"><FONT SIZE=5 COLOR=#FF0000>
Summary</FONT></A></H2>
<UL>
<LI>You can create simple graphical output in the list using the
<TT>as symbol</TT>, <TT>as icon</TT>, and <TT>as line</TT> additions
on the <TT>write</TT> statement. When using these additions, you
must use the <TT>include</TT> statement to bring the symbol, icon
and <TT>line-draw</TT> character definitions into your program.
<LI>Use the <TT>line-size</TT> addition on the <TT>report</TT>
statement to set the width of the output list. Use the <TT>line-count</TT>
addition to set the number of lines per page in the output list.
You can also use it to specify the number of lines reserved for
the footer. You cannot use variables on the <TT>report</TT> statement,
so use the <TT>new-page</TT> statement for these additions if
you want to set these attributes at run time.
<LI>To create page headers you can use either standard page headers
or the <TT>top-of-page</TT> statement.
<LI>Up to 10 variables can be used in standard page headers. Values
assigned to <TT>sy-tvar0</TT> through <TT>sy-tvar9</TT> replace
<TT>&amp;0</TT> through <TT>&amp;9</TT> in the list. Use periods
to extend the output length of these replacement variables.
<LI>To suppress output of the standard page header, use the <TT>no
standard page heading</TT> addition on the <TT>report</TT> statement.
<LI>If you include the <TT>top-of-page</TT> event in your program,
it is triggered when the first <TT>write</TT> statement is executed.
The statements following it are executed, then control returns
to the <TT>write</TT> statement.
<LI>Use the <TT>end-of-page</TT> event to create footers. You
must also use <TT>line-count</TT> on the <TT>report</TT> or <TT>new-page</TT>
statement to specify the number of lines per page and reserve
space for the footer.
<LI>Use the <TT>reserve</TT> statement to keep a group of lines
together in the list.
</UL>
<H2><A NAME="QampABR"><FONT SIZE=5 COLOR=#FF0000>
Q&amp;A<BR>
</FONT></A></H2>

<TABLE>
<TR VALIGN=TOP><TD WIDTH=48><CENTER><B>Q</B></CENTER></TD><TD><B>Which is the preferred method of creating customer titles-using <TT><B>sy-tvar</B></TT> variables or the <TT><B>top-of-page</B></TT> event?</B>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=48><CENTER><B>A</B></CENTER></TD><TD>The <TT>top-of-page</TT> event is more flexible, so more programmers prefer to use that method. Provided you use text symbols for your text literals, both can be translated so there aren't any advantages to <TT>sy-tvar</TT> variables.
</TD></TR>
</TABLE>
<P>
<H2><A NAME="Workshop"><FONT SIZE=5 COLOR=#FF0000>
Workshop</FONT></A></H2>
<P>
The Workshop provides 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>
<OL>
<LI>What are the three graphical additions that are used with
the write statement? What statement must also be included in order
to write the graphical additions? Give an example of an include
statement.
<LI>What are the two additions that are used with report statement
to control size of the output page? Can the variable used for
the two additions be variable?
</OL>
<H3><A NAME="Exercise">
Exercise 1</A></H3>
<P>
Write out a program that will display the following symbols: square,
diamond, circle, glasses, pencil, phone, note, and folder.
<P>
<CENTER>
<HR SIZE=4>
<A HREF="gla03.htm" tppabs="http://pbs.mcp.com/ebooks/0672312174/ch15/gla03.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="../ch16/ch16.htm" tppabs="http://pbs.mcp.com/ebooks/0672312174/ch16/ch16.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 + -