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

📄 ch15.htm

📁 这个是sap开发语言abap的教育文档
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<TR VALIGN=TOP><TD WIDTH=600><BLOCKQUOTE>
The SAP standard is to left-justify the header on the output list. As a result, the header <I>cannot</I> be centered. Even if you center it manually by putting leading spaces in front of it, it will appear left-justified in the output.
</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<P>
<H5>Translating Text Elements</H5>
<BLOCKQUOTE>
Creating titles and headers as text elements allows them to be
translated into foreign languages, usually by an someone who specializes
in the translation of technical or industry-specific phrases.
In this section you can try this yourself to get a feel for the
process.
</BLOCKQUOTE>
<P>
<img src="../button/screencam.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/screencam.gif">
<BLOCKQUOTE>
Start the ScreenCam &quot;Translating Titles and Headers&quot;
now.

<OL>
<LI>From the ABAP/4 Text Elements: Change Title and Heading screen,
choose the menu path Goto-&gt;Translation. The Target Language
For Translation screen is shown.
<LI>In the Target Language field, choose the language into which
you want to translate your text elements. The language you choose
must have been previously installed on your system by the Basis
Consultant. <I>Deutsch</I> (German) is installed on every system,
because it is the master language for all R/3 systems. Therefore,
choose D (<I>Deutsch</I>).
<LI>Click the Translate button. The Translate Title And Headers
For Program xxxxx screen is displayed. On this screen is the name
of the field, a Remark field into which the translator can enter
comments, followed by the original text and an input field for
the translation. When blank, this input field contains an underscore.
<LI>In the fields containing an underscore, type your German translations.
If you don't know German, just substitute Ks for all of your Cs,
and use lots of phrases ending with <I>schnitzel</I> or containing
the name <I>Wolfgang</I>.
<LI>Click the Save button on the standard toolbar. If you have
more translations to do, you will remain on the same screen. Click
the Back button to see the next set. When there is no more text
to be translated, you will be returned to the ABAP/4 Text Elements:
Change Title and Heading screen.
<LI>Now log on again, but this time enter <TT>D</TT> in the Language
field in the log on screen.
<LI>Run your program. The translated titles will appear. If you
display the program attributes, you will see the translated title
on the ABAP/4: Program attribute xxxxx screen.
</OL>

All translations are stored in a proposal pool from which you
can retrieve previous translations of a word or phrase. If you
enter a translation that differs from those stored in the pool,
the system will automatically prompt you with the previous translations.
You must then either save the new one or select a previous one.
<BR>
</BLOCKQUOTE>
<CENTER>
<TABLE BORDER=1>
<TR VALIGN=TOP><TD WIDTH=600><B>NOTE</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=600>
<BLOCKQUOTE>
The employee who does the translation will usually use the SE63 transaction. It provides a set of programs that allow all texts in the system to be translated. For example, the descriptions of the data elements, indexes, selection texts in programs, and so on can be translated here. Beginning at the ABAP/4 Development Workbench screen, the menu path is Utilities-&gt; Translation-&gt;Short/Long Texts.</BLOCKQUOTE>

</TD></TR>
</TABLE>
</CENTER>
<P>
<H5>Using Variables in Standard Page Headers</H5>
<BLOCKQUOTE>
You can use up to 10 variables in the standard page headings for
one program. In your program, assign values to the variables named
<TT>sy-tvar0</TT> through <TT>sy-tvar9</TT>. In your headings,
use the variable names <TT>&amp;0</TT> through <TT>&amp;9</TT>
to correspond to the <TT>sy</TT> variables within your program.
For example, if in your program you code <TT>sy-tvar0 = 'AA'</TT>
and <TT>sy-tvar1 = 'BB'</TT>, <TT>&amp;0</TT> will be replaced
by AA and <TT>&amp;1</TT> will be replaced by BB in the header.
</BLOCKQUOTE>
<BLOCKQUOTE>
Although each <TT>sy-tvar</TT> variable can hold a value up to
20 characters long, the variable output length is 2 by default.
This means that for example, wherever <TT>&amp;0</TT> appears
in the header, exactly two spaces are reserved for the value of
<TT>sy-tvar0</TT>. If the value in <TT>sy-tvar0</TT> is <TT>'A'</TT>,
<TT>'A'</TT> appears. If the value is <TT>'AA'</TT>, <TT>'AA'</TT>
appears. If the value is <TT>'AAA'</TT>, <TT>'AA'</TT> appears.
</BLOCKQUOTE>
<BLOCKQUOTE>
The output length can be increased by appending periods to the
end of the output variable. For example, to increase the output
length of <TT>&amp;0</TT> from 2 to 4, code <TT>&amp;0..</TT>
(two periods have been appended). To increase the output length
to 7 append 5 periods (<TT>&amp;0.....)</TT>.
</BLOCKQUOTE>
<BLOCKQUOTE>
Listing 15.6 contains a program that uses standard page headings
containing variables. Figure 15.7 shows how to code these variables
on the ABAP/4 Text Elements: Change Title and Heading screen.
<BR>
<A HREF="javascript:popUp('f15-7.gif')"><B>Figure 15.7 :</B> <I>The ABAP/4 Text Elements: Change Title
And Heading screen for program ztx1506</I>.</A>
</BLOCKQUOTE>
<P>
<IMG SRC="../button/input.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/input.gif">
<HR>
<P>
<B>Listing 15.6&nbsp;&nbsp;Variables in Standard Page Headers
<BR>
</B>
<BLOCKQUOTE>
<PRE>
1  report ztx1506.
2  tables ztxlfa1.
3  parameters: p_land1 like ztxlfa1-land1 default 'US'.
4  sy-tvar0 = sy-uname.
5  write: sy-datum to sy-tvar1,
6         sy-uzeit to sy-tvar2.
7  sy-tvar3 = p_land1.
8  select * from ztxlfa1 where land1 = p_land1.
9      write: / ztxlfa1-lifnr, ztxlfa1-name1.
10     endselect.
</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.6 produces this output:
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>
KENGREENWOOD    1998/05/05 19:40:38          
------------------------------------------------
Country Code: US                          
------------------------------------------------
1040       Motherboards Inc.              
1080       Silicon Sandwich Ltd.          
1090       Consume Inc.                   
2000       Monitors and More Ltd.         
V1         Quantity First Ltd.            
V2         OverPriced Goods Inc.          
V3         Fluffy Bunnies Ltd.            
V4         Moo like a Cow Inc.            
V5         Wolfman Sport Accessories Inc. 
V7         The Breakfast Club Inc.        
</PRE>
</BLOCKQUOTE>
<P>
<IMG SRC="../button/analysis.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/analysis.gif">
<UL>
<LI>Line 3 defines <TT>p_land1</TT> and prompts the user for a
value.
<LI>Line 4 assigns the current user Id to <TT>sy-tvar0</TT>.
<LI>The <TT>write</TT> statement on line 5 moves the value of
<TT>sy-datum</TT> to <TT>sy-tvar1</TT>. An ordinary assignment
statement (using <B>=</B>) would have moved the value without
formatting it. Using <TT>write</TT> causes the field to be formatted
with separators according to the user's profile.
<LI>Line 6 formats the current time and moves it to <TT>sy-tvar2</TT>.
<LI>Line 7 assigns the value that was entered by the user to <TT>sy-tvar3</TT>.
<LI>Lines 8 through 10 write out a simple vendor report.
<LI>In Figure 15.7, <TT>&amp;0..........</TT> indicates where
the value of <TT>sy-tvar0</TT> will appear. The periods increase
the output length of the variable from 2 to 12. <TT>&amp;1........</TT>
indicates where the value of <TT>sy-tvar1</TT> will appear, <TT>&amp;2......</TT>
indicates where the value of <TT>sy-tvar2</TT> will appear, and
<TT>&amp;3.</TT> the value of <TT>sy-tvar3</TT>. The periods increase
the output lengths to 10, 8, and 3, respectively.
</UL>
<H4>Creating Manual Page Headers</H4>
<P>
Standard page headers are easy to create, but they have some limitations
too. They are limited to one line for the page header and four
lines for the column headers. A maximum of 10 variables can be
used, each with a minimum length of two characters. The header
is always left justified, and the colors are standard and cannot
be changed. Manual headings, however, have no such limitations.
<P>
To create manual headings, you need to
<UL>
<LI>Turn off standard page headers.
<LI>Use the <TT>top-of-page</TT> event to create custom headings.
</UL>
<P>
To turn off the standard page headings, add <TT>no standard page
heading</TT> to the end of the report statement.
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/newterm.gif">
<P>
An event in ABAP/4 is like a subroutine in other languages. It
is an independent section of code; it performs a task and then
returns to the point of invocation. However, unlike subroutines,
<I>you</I> do not code the call to an event. Instead, the system
triggers the event <I>for you</I> when a specific condition arises.
<P>
The <TT>top-of-page</TT> event is triggered when the first <TT>write</TT>
statement is executed. Before any values are written to the list,
the system branches to the code following <TT>top-of-page</TT>
and executes it. It then returns to the <TT>write</TT> statement
and writes out the values. Listing 15.7 and Figure 15.8 illustrate
this process.
<P>
<IMG SRC="../button/input.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/input.gif">
<HR>
<P>
<B>Listing 15.7&nbsp;&nbsp;The top-of-page Event<BR>
</B>
<BLOCKQUOTE>
<PRE>
1  report ztx1507 no standard page heading.
2  data f1(5) value 'Init'.
3  f1 = 'Title'.
4  write: / 'Hi'.
5 
6  top-of-page.
7    write: / 'My', f1.
8    uline.
</PRE>
</BLOCKQUOTE>
<HR>
<P>
<IMG SRC="../button/output.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/output.gif">
<P>
Figure 15.8 shows the output for Listing 15.7.
<P>
<A HREF="javascript:popUp('f15-8.gif')"><B>Figure 15.8 :</B> <I>Output of Listing 15.7</I>.</A>
<P>
<IMG SRC="../button/analysis.gif" tppabs="http://pbs.mcp.com/ebooks/0672312174/button/analysis.gif">
<UL>
<LI>On line 1, the <TT>report</TT> statement contains the <TT>no
standard page heading</TT> addition, so standard headers are not
written.
<LI>Line 2 defines <TT>f1</TT> as character length 5 and gives
it an initial value of <TT>'Init'</TT>.
<LI>Line 3 assigns the value <TT>'Title'</TT> to <TT>f1</TT>.
<LI>The <TT>write</TT> statement on line 4 triggers the <TT>top-of-page</TT>
event on line 6. Lines 7 and 8 are then executed, causing <TT>My
Title</TT> to be written to the first line of the list, followed
by an underline (written by the <TT>uline</TT> statement on line
8). Processing then returns to the <TT>write</TT> statement on
line 4 and <TT>Hi</TT> is written to line 3 of the output list.
<LI>After line 4 has been executed, the program ends and the output
is shown.
</UL>
<P>
Notice that the value of <TT>f1</TT> written out at the top of
the page is the value at the time the first <TT>write</TT> statement
is issued, not the value at the beginning of the program.
<H4>Creating Page Footers</H4>
<P>
As discussed earlier, after an online report has been generated,
the user can change his window size. To avoid mid-page breaks,
online reports always consist of a single very long virtual page,
so having footers doesn't make much sense because there would
be only one.
<P>
Batch reports are usually printed, and thus will have a definite
page size that doesn't change after the report is created, so
they can have page footers.
<P>
To create page footers you need
<UL>
<LI>To reserve space for the footer at the bottom of the page
using the <TT>line-count</TT> addition on the <TT>report</TT>
statement.
<LI>The <TT>end-of-page</TT> event.
</UL>
<P>
To reserve space for your footer, you can code <TT>line-count
<I>n</I>(<I>m</I>)</TT>
on the <TT>report</TT> statement, where <TT><I>n</I></TT>
is the number of lines per page, and <TT><I>m</I></TT>
is the number of lines to reserve for the footer. You don't want
to hard-code <TT><I>n</I></TT>,
because the user should be able to specify the number of lines
per page when printing the report. Therefore simply leave it off,
and enter <TT>report zxx line-count (<I>m</I>)</TT>.
<P>
During report processing, <TT>sy-pagno</TT> contains the current
page number and <TT>sy-linno</TT> contains the current line number
being written to.
<P>
Code <TT>end-of-page</TT> at the bottom of your program, as shown
in Listing 12.8. The statements following <TT>end-of-page</TT>
are executed before each new page is begun. A new page is begun
when a <TT>write</TT> statement is executed and if the output
will not fit on the current page. For example, you may have coded
<TT>report zxx line-count (3)</TT> leaving three rows for the
footer, and the user may have specified 60 lines per page. The
footer area is therefore contained within lines 58 through 60.
If you have just written to the 57th line, the next <TT>write</TT>
statement to a new line will trigger the <TT>end-of-page</TT>
event, followed by a page break, the <TT>top-of-page</TT> event,
and then write output to the next page.<P>

⌨️ 快捷键说明

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