📄 ch02.htm
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function popUp(pPage) {
popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394');
figDoc= popUpWin.document;
zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>';
zhtm += '</head>';
zhtm += '<BODY bgcolor="#FFFFFF">';
zhtm += '<IMG SRC="' + pPage + '">';
zhtm += '<P><B>' + pPage + '</B>';
zhtm += '</BODY></HTML>';
figDoc.write(zhtm);
figDoc.close();
popUpWin.focus();
}
//-->
</SCRIPT>
<META NAME="GENERATOR" Content="Symantec Visual Page 1.0.1">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
<TITLE>Sams Teach Yourself ABAP/4® in 21 Days -- Day 2- Your First ABAP/4 Program</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
<CENTER>
<H1><IMG SRC="../button/sams.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/sams.gif" BORDER="0"></H1>
</CENTER>
<CENTER>
<P><A HREF="../ch01/ch01.htm" tppabs="http://ebooks.cs.biu.ac.il/0672312174/ch01/ch01.htm"><IMG SRC="../button/previous.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/previous.gif" BORDER="0"></A>
<A HREF="../index.htm" tppabs="http://ebooks.cs.biu.ac.il/0672312174/index.htm"><IMG SRC="../button/contents.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/contents.gif" BORDER="0"></A>
<A HREF="../ch03/ch03.htm" tppabs="http://ebooks.cs.biu.ac.il/0672312174/ch03/ch03.htm"><IMG SRC="../button/next.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/next.gif" BORDER="0"></A>
<H1>Sams Teach Yourself ABAP/4<sup>®</sup> in 21 Days</H1></CENTER>
<HR SIZE=4>
<H1>Day 2</H1>
<H1>Your First ABAP/4 Program</H1>
<UL>
<LI><A HREF="#BeforeProceeding">
Before Proceeding</A>
<LI><A HREF="#ExploringtheDevelopmentEnvironment">
Exploring the Development Environment</A>
<LI><A HREF="#DiscoveringProgramTypes">
Discovering Program Types</A>
<UL>
<LI><A HREF="#DefiningReports">
Defining Reports</A>
<LI><A HREF="#DefiningDialogPrograms">
Defining Dialog Programs</A>
</UL>
<LI><A HREF="#DiscoveringReportComponents">
Discovering Report Components</A>
<UL>
<LI><A HREF="#DiscoveringtheProgramRuntimeObject">
Discovering the Program Runtime Object</A>
<LI><A HREF="#IntroducingProgramNamingConventions">
Introducing Program Naming Conventions</A>
</UL>
<LI><A HREF="#CreatingYourFirstProgram">
Creating Your First Program</A>
<LI><A HREF="#ExploringtheSourceCodeEditor">
Exploring the Source Code Editor</A>
<UL>
<LI><A HREF="#UsingtheEditorInitialScreen">
Using the Editor: Initial Screen</A>
<LI><A HREF="#ExploringtheFunctionalityoftheSourceCodeEditor">
Exploring the Functionality of the Source Code Editor</A>
</UL>
<LI><A HREF="#GettingHelp">
Getting Help</A>
<UL>
<LI><A HREF="#ObtainingFHelp">
Obtaining F1 Help</A>
<LI><A HREF="#ObtainingRLibraryHelp">
Obtaining R3 Library Help</A>
</UL>
<LI><A HREF="#FindingYourDevelopmentObjects">
Finding Your Development Objects</A>
<LI><A HREF="#IntroducingtheRDataDictionary">
Introducing the R/3 Data Dictionary</A>
<UL>
<LI><A HREF="#ExploringTablesandStructures">
Exploring Tables and Structures</A>
<LI><A HREF="#DisplayingaTableorStructureDefinition">
Displaying a Table or Structure Definition</A>
<LI><A HREF="#DisplayingDataintheTable">
Displaying Data in the Table</A>
<LI><A HREF="#DeterminingDisplayedFields">
Determining Displayed Fields</A>
</UL>
<LI><A HREF="#UnderstandingABAPSyntax">
Understanding ABAP/4 Syntax</A>
<UL>
<LI><A HREF="#IntroducingtheTTFONTSIZEselectFONTTTFONTSIZEStatementFONT">
Introducing the <TT>select</TT>
Statement</A>
<LI><A HREF="#UnderstandingTableWorkAreas">
Understanding Table Work Areas</A>
<LI><A HREF="#IntroducingtheTTFONTSIZEwhereFONTTTFONTSIZEClauseFONT">
Introducing the <TT>where</TT>
Clause</A>
<LI><A HREF="#WorkingwithSystemVariables">
Working with System Variables</A>
<LI><A HREF="#UsingtheChainOperator">
Using the Chain Operator</A>
<LI><A HREF="#UsingtheTTFONTSIZEselectsingleFONTTTFONTSIZEStatementFONT">
Using the <TT>select single</TT>
Statement</A>
<LI><A HREF="#CommentingCodeandFormalDocumentation">
Commenting Code and Formal Documentation</A>
</UL>
<LI><A HREF="#Summary">
Summary</A>
<LI><A HREF="#QampA">
Q&A</A>
<LI><A HREF="#Workshop">
Workshop</A>
<UL>
<LI><A HREF="#Quiz">
Quiz</A>
<LI><A HREF="#EditorExercises">
Editor Exercises</A>
<LI><A HREF="#ProgrammingExercises">
Programming Exercises</A>
</UL></UL>
<HR>
<P>
After you complete this chapter, you should be able to:
<UL>
<LI>Create and modify simple ABAP/4 programs.
<LI>Use standard functions in the ABAP/4 editor.
<LI>Use F1 and R/3 Library help functions.
<LI>Find your programs using the Object Browser and the editor.
<LI>Display a table and its contents using the Data Dictionary.
<LI>Use the <TT>tables</TT> and <TT>select</TT> statements.
<LI>Chain statements together using the chain operator.
<LI>Add comments and documentation to your programs.
</UL>
<H2><A NAME="BeforeProceeding"><FONT SIZE=5 COLOR=#FF0000>
Before Proceeding</FONT></A></H2>
<P>
Before proceeding, you should:
<UL>
<LI>Be comfortable with a programming language such as C, COBOL,
or Visual Basic. To obtain the full benefit from this and all
following chapters, you should also have two or more years of
previous development experience.
<LI>Set up your interface as recommended in Day 1 in the section
"The Interface Menu," if you have not done so already.
<LI>Perform the install procedure for the ScreenCams on the CD-ROM.
The install procedure is described in the <TT>readme.txt</TT>
file found in the root directory of the CD-ROM.
</UL>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
Many of the procedures in this book are demonstrated using <I>ScreenCams</I>.
ScreenCams are like movies; they show a series of screens, including
keystrokes and mouse movements, with a descriptive voiceover.
They can be found on the CD-ROM that comes with this book. See
the <TT>readme.txt</TT> file found in the root directory of the
CD-ROM for more information.
<P>
<H2><A NAME="ExploringtheDevelopmentEnvironment"><FONT SIZE=5 COLOR=#FF0000>
Exploring the Development Environment</FONT></A></H2>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
A <I>development object</I> is anything created by a developer.
Examples of development objects are programs, screens, tables,
views, structures, data models, messages, and includes.
<p>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
The R/3 system contains tools for creating and testing development
objects. These tools are located in the <I>R/3 Development Workbench</I>.
To access any development tool, you go to the workbench.
<P>
The workbench contains these tools to help you create development
objects:
<UL>
<LI>The ABAP/4 program editor where you can create and modify
ABAP/4 source code and other program components
<LI>The Data Dictionary where you can create tables, structures,
and views
<LI>The Data modeler where you can document the relationships
between tables
<LI>The Function library where you can create global ABAP/4 function
modules
<LI>The screen and menu painters where you can create a user interface
for your programs
</UL>
<P>
The following testing and search tools are also available:
<UL>
<LI>the ABAP/4 Debugger
<LI>the SQL trace tool used to tune SQL statements
<LI>the runtime analyzer for optimizing your program's performance
<LI>a where-used tool for impact analysis
<LI>a computer-aided test tool for regression testing
<LI>a repository search tool for finding development objects
<LI>the Workbench Organizer for recording changes to objects and
promoting them into production
</UL>
<P>
All development objects are portable, meaning that you can copy
them from one R/3 system to another. This is usually done to move
your development objects from the development system to the production
system. If the source and target systems are on different operating
systems or use different database systems, your development objects
will run as-is and without any modification. This is true for
all platforms supported by R/3. (For a list of supported hardware
and operating systems, refer to Table 1.1.)
<H2><A NAME="DiscoveringProgramTypes"><FONT SIZE=5 COLOR=#FF0000>
Discovering Program Types</FONT></A></H2>
<P>
There are two main types of ABAP/4 programs:
<UL>
<LI>reports
<LI>dialog programs
</UL>
<H3><A NAME="DefiningReports">
Defining Reports</A></H3>
<P>
The purpose of a report is to read data from the database and
write it out. It consists of only two screens (see Figure 2.1).
<BR>
<P>
<A HREF="javascript:popUp('f2-1.gif')"><B>Figure 2.1:</B><i>The selection screen and the output screen</I>.</A>
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
The first screen is called the <I>selection screen</I>. It contains
input fields allowing the user to enter criteria for the report.
For example, the report may produce a list of sales for a given
date range, so the date range input fields would appear on the
report's selection screen.
<P>
<IMG SRC="../button/newterm.gif" tppabs="http://ebooks.cs.biu.ac.il/0672312174/button/newterm.gif">
<P>
The second screen is the output screen. It contains the <I>list</I>.
The list is the output from the report, and usually does not have
any input fields. In our example, it would contain a list of the
sales that occurred within the specified date range.
<P>
The selection screen is optional. Not all reports have one. However,
all reports generate a list.
<P>
In this book, you will learn how to create report programs.
<H3><A NAME="DefiningDialogPrograms">
Defining Dialog Programs</A></H3>
<P>
Dialog programs are more flexible than reports, and so are more
complex at the program level. They can contain any number of screens,
and the screen sequence can be changed dynamically at run time.
On each screen, you can have input fields, output fields, pushbuttons,
and more than one scrollable area.
<H2><A NAME="DiscoveringReportComponents"><FONT SIZE=5 COLOR=#FF0000>
Discovering Report Components</FONT></A></H2>
<P>
ABAP/4 reports consist of five components (shown in Figure 2.2):
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -