📄 ch15.htm
字号:
</BLOCKQUOTE>
<HR>
<P>
<IMG SRC="../button/output.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/output.gif">
<P>
The code in Listing 15.2 produces the output shown in Figure 15.2.
<P>
<A HREF="javascript:popUp('f15-2.gif')"><B>Figure 15.2 :</B> <I>This is a sample of list output containing
icons</I>.</A>
<P>
<IMG SRC="../button/analysis.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/analysis.gif">
<UL>
<LI>Lines 6 through 9 write out a sample of four different icons.
<LI>Line 4 defines a variable named <TT>ico</TT> to contain an
icon to be written out. Any icon name can appear after <TT>like</TT>.
<LI>Line 15 selects records from the materials table <TT>ztxmara</TT>.
<LI>For each record, line 17 looks up the hazardous material number
in <TT>ztxmgef</TT>.
<LI>Line 19 determines if the material is radioactive. If so,
the icon named <TT>icon_generate</TT> is assigned to variable
<TT>ico</TT>.
<LI>Line 23 writes the value of <TT>ico</TT> using <TT>as icon</TT>
to cause the value to be interpreted as an icon. Additional fields
from <TT>ztxmara</TT> are also written.
</UL>
<H3><A NAME="UsingtheaslineAddition">
Using the as line Addition</A></H3>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/newterm.gif">
<P>
A <I>line-draw character</I> is a character that can be used to
draw lines on a list. You can use them to create horizontal or
vertical lines, a box, a grid, or a tree-like structure.
<P>
Typically, to create a horizontal line you would use <TT>sy-uline</TT>.
Simply write it out and specify the length needed. For example,
to write a horizontal line beginning at position 5 for a length
of 10, you would code <TT>write 5(10) sy-uline</TT>. To create
a vertical line use <TT>sy-vline</TT>; for example, <TT>write:
sy-vline, 'X', sy-vline</TT> would write a vertical line on either
side of an X. If lines intersect in the output, the system will
insert the appropriate connecting character. For example, where
the edge of a horizontal line and vertical line meet, a box corner
will be drawn. To provide absolute control of the line drawing
there are additional <TT>line-draw</TT> characters available.
<P>
<IMG SRC="../button/input.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/input.gif">
<HR>
<P>
<B>Listing 15.3 Symbols and line-draw Characters<BR>
</B>
<BLOCKQUOTE>
<PRE>
1 report ztx1503.
2 include <list>.
3 tables: ztxlfa1, ztxlfb1, ztxlfc3.
4 data: line1 like line_horizontal_line,
5 line2 like line_horizontal_line.
6
7 select * from ztxlfa1.
8 select single * from ztxlfb1 where lifnr = ztxlfa1-lifnr.
9 if sy-subrc = 0.
10 write: / sy-vline, sym_open_folder as symbol.
11 else.
12 write: / sy-vline, sym_folder as symbol.
13 endif.
14 write: ztxlfa1-lifnr, 30 sy-vline.
15 select * from ztxlfb1 where lifnr = ztxlfa1-lifnr.
16 select single lifnr from ztxlfb1 into (ztxlfb1-lifnr)
17 where lifnr = ztxlfb1-lifnr
18 and bukrs > ztxlfb1-bukrs.
19 if sy-subrc = 0.
20 line1 = line_left_middle_corner.
21 line2 = line_vertical_line.
22 else.
23 line1 = line_bottom_left_corner.
24 clear line2.
25 endif.
26 write: / sy-vline,
27 4 line1 as line,
28 ztxlfb1-bukrs,
29 30 sy-vline.
30 select * from ztxlfc3 where lifnr = ztxlfb1-lifnr
31 and bukrs = ztxlfb1-bukrs.
32 write: / sy-vline,
33 4 line2 as line,
34 8 line_left_middle_corner as line,
35 ztxlfc3-gjahr, ztxlfc3-shbkz,
36 30 sy-vline.
37 endselect.
38 if sy-subrc = 0.
39 write 8(2) line_bottom_left_corner as line.
40 endif.
41 endselect.
42 write: /(30) sy-uline.
43 endselect.
</PRE>
</BLOCKQUOTE>
<HR>
<P>
<IMG SRC="../button/output.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/output.gif">
<P>
The code in Listing 15.3 produces the output shown in Figure 15.3.
<P>
<A HREF="javascript:popUp('f15-3.gif')"><B>Figure 15.3 :</B> <I>This is a sample of list output containing
line-draw characters</I>.</A>
<P>
<IMG SRC="../button/analysis.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/analysis.gif">
<UL>
<LI>Line 2 includes the definitions for all symbols and line-draw
characters so they can be used in this program.
<LI>Line 4 defines two variables that can hold line-draw characters.
<LI>Line 7 reads all rows from <TT>ztxlfa1</TT>.
<LI>Line 8 reads <TT>ztxlfb1</TT> to see if there are any child
records for the current <TT>ztxlfa1</TT> record.
<LI>If child records exist, line 10 writes a vertical line and
an open folder symbol. If none are found, a vertical line and
closed folder are written.
<LI>Line 14 writes the vendor number on the same line, and then
a vertical line at position 30.
<LI>Line 15 reads the child records from <TT>ztxlfb1</TT>.
<LI>Line 16 performs a look-ahead to determine if this is the
last child record or if there are more.
<LI>If there are more child records, line 19 sets the <TT>line1</TT>
variable to hold a left middle corner line-draw character, and
<TT>line2</TT> to hold a vertical line. <TT>Sy-vline</TT> could
have been used here instead of <TT>line_vertical_line</TT>.
<LI>Line 26 writes out the <TT>line1</TT> variable using the <TT>as
line</TT> addition so that the value is interpreted as a line-draw
character.
<LI>Lines 30 through 37 write out the children of the current
<TT>ztxlfb1</TT> record using appropriate line-draw characters.
<LI>Line 42 writes an underline having a length of 30 characters.
</UL>
<H3><A NAME="DisplayingtheAvailableSymbolsIconsandlinedrawCharacters">
Displaying the Available Symbols, Icons, and line-draw Characters
</A></H3>
<P>
Use steps 1 through 8 of the following procedure to display the
available symbols, icons, and line-draw characters. Following
all steps causes a <TT>write</TT> statement to be generated that
writes the selected item to the list.
<OL>
<LI>Begin by editing any program in the ABAP/4 Editor. You should
be on the ABAP/4 Editor: Edit Program XXXXX screen.
<LI>Place your cursor on a blank line.
<LI>Click the Pattern button, or choose the menu path Edit->Insert
Statement. The system displays the Insert Statement screen.
<LI>Select the Write radio button.
<LI>Click the Continue button. The system displays the Assemble
a Write Statement screen.
<LI>Choose Symbol, Icon, or Line.
<LI>Place your cursor in the input field to the right of the radio
button you chose.
<LI>Press the F4 key. The system displays a list of the available
items.
<LI>Double-click one to choose it. You are returned to the Assemble
A Write Statement screen.
<LI>Click the Copy button. You are returned to the ABAP/4 Editor:
Edit Program XXXXX screen, and a <TT>write</TT> statement is inserted
that will write the item out.
</OL>
<P>
<CENTER>
<TABLE BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>CAUTION</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
Not all icons can be printed. When you display them using the previous steps, you can see that the printable ones are flagged in the list.</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.4 Symbols, Icons, and line-draw Characters
<BR>
</B>
<BLOCKQUOTE>
<PRE>
1 report ztx1504.
2 include <list>. "definitions for icons, symbols + line-draw
3 tables: ztxlfa1, ztxlfc3.
4 data: it like ztxlfc3 occurs 100 with header line,
5 ico_l like icon_green_light.
6 select * from ztxlfc3 into table it.
7 sort it by lifnr bukrs gjahr shbkz.
8 loop at it.
9 if it-saldv < 1000.
10 ico_l = icon_green_light.
11 elseif it-saldv between 1000 and 3000.
12 ico_l = icon_yellow_light.
13 else.
14 ico_l = icon_red_light.
15 endif.
16 at new lifnr.
17 if sy-tabix > 1.
18 write: /5(82) sy-uline,
19 19 line_bottom_middle_corner as line,
20 21 line_bottom_middle_corner as line.
21 skip.
22 endif.
23 write: /5(15) sy-uline,
24 /5 sy-vline, sym_documents as symbol,
25 it-lifnr, 19 sy-vline,
26 /5(82) sy-uline,
27 19 line_cross as line,
28 21 line_top_middle_corner as line.
29 endat.
30 write: / ico_l as icon,
31 5 sy-vline, it-bukrs, sy-vline,
32 it-gjahr, line_left_middle_corner as line no-gap,
33 it-shbkz no-gap, line_right_middle_corner as line,
34 it-saldv,
35 it-solll,
36 it-habnl, sy-vline.
37 at last.
38 write /5(84) sy-uline.
39 endat.
40 endloop.
</PRE>
</BLOCKQUOTE>
<HR>
<P>
<IMG SRC="../button/output.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/output.gif">
<P>
The code in Listing 15.4 produces the output shown in Figure 15.4.
<P>
<A HREF="javascript:popUp('f15-4.gif')"><B>Figure 15.4 :</B> <I>This is a sample of list output containing
symbols, icons, and line-draw characters</I>.</A>
<H2><A NAME="ReportFormattingandPrinting"><FONT SIZE=5 COLOR=#FF0000>
Report Formatting and Printing</FONT></A></H2>
<P>
This section covers the following report formatting techniques:
<UL>
<LI>Controlling page size
<LI>Report titles, headers, and footers
<LI>Common position and formatting statements
</UL>
<H3><A NAME="ControllingPageSize">
Controlling Page Size</A></H3>
<P>
To control the size of the output page, use the following additions
on the <TT>report</TT> statement:
<UL>
<LI><TT>line-size</TT>
<LI><TT>line-count</TT>
</UL>
<P>
The <TT>line-size</TT> addition controls the width of the output
list; <TT>line-count</TT> controls the number of lines per page.
<H4>Syntax for the line-size and line-count Additions to the report
Statement</H4>
<P>
The syntax for the <TT>line-size</TT> and <TT>line-count</TT>
additions to the <TT>report</TT> statement is as follows:
<BLOCKQUOTE>
<PRE>
report line-size <I>i</I> line-count <I>j</I>(<I>k</I>).
</PRE>
</BLOCKQUOTE>
<P>
where:
<UL>
<LI><TT><I>i</I></TT>,<I> </I><TT><I>j</I></TT>,<I>
</I>and<I> </I><TT><I>k</I></TT><I>
</I>are numeric constants. Variables are not allowed.
<LI><TT><I>i</I></TT> specifies
the width of the output list (in characters).
<LI><TT><I>j</I></TT> specifies
the number of lines per page in the output list.
<LI><TT><I>k</I></TT> specifies
the number of lines reserved for a footer at the bottom of each
page.
<LI>Do not enclose <TT><I>i</I></TT>,
<TT><I>j</I></TT>, or <TT><I>k</I></TT>
in quotes.
</UL>
<H4>Using line-size and line-count</H4>
<P>
By default, the width of the output list is equal to the maximized
window width. For example, if your window is maximized before
you execute a report, the system will use that width as the output
width of your program. If your window has been resized to be less
than the maximum, the system will still use the maximized size.
A scroll bar will appear at the bottom of the window to allow
you to scroll right and see the rest of the report.
<P>
To override this behavior, specify the list output width by using
<TT>line-size</TT>. Valid values are 2 through 255.<P>
<CENTER>
<TABLE BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>TIP</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -