ProgramPath:
ABAP documentation and examples-> BC-ABAP programming-> ABAP introduction-> the ABAP Hello World Program
(Note: When the program path is described later, the first two nodes are omitted, starting from the third-layer node)
Code:
Code
0001 report demo_hello_world.
0002
0003 * Selection screen
0004 parameters input ( 12 ) Type C default ' Hello world! ' .
0005
0006 * Dynpro
0007 call Screen 100 .
0008
0009 * List
0010 SKIP TO LINE 10 .
0011 position 40 .
0012 write input.
Resolution:
1. Line 1 starts with report, which indicates that this is a report program. If it is a module pool, it starts with program; function groups start with function-pool (nested in the include program, function group structure is special, please refer to the http://www.cnblogs.com/qiangsheng/archive/2009/01/14/1375761.html ); the Type pool starts with type-pool, the class pool starts with class-pool, and the interface pool starts with interface-pool.
2. * starts with a comment. The comments in line 3rd indicate the definition of the selection screen. Parameters defines an input field for a single value. input is the field name, type is C, length is 12, default value is Hello world !. In addition to defining an input field on the screen, parameters also implicitly defines a global variable with the same name, which can be used throughout the program.
3. The following figure shows how to call a dynpro screen (dynpro is a word invented by SAP, which can be understood as a screen). Call screen specifies the called screen number. Here is the call screen 6th.
4. The following table describes the list output at the beginning of Line 1. The list is an output interface unique to sap and is output only in an equal-width font, you can also output some icons and symbols as needed (refer to the http://www.cnblogs.com/qiangsheng/archive/2008/10/06/1304425.html), list does not have official Chinese terms, and now the sap Chinese interface is also mixed "list" or "list ", there is no uniformity. Based on my understanding, I will use the term "list" in future lines to distinguish it from the list or list.
5. The 10th rows show that the displayed cursor jumps to the 10th rows of the output interface. The 11th rows show that the displayed cursor jumps to the 40th columns of the output interface; the second line indicates that the global variable is output at the current cursor position (12th rows, 10th columns) (Note: Here is the global variable rather than the input field.
6. The definition of screen 100 is invisible in the code. You must switch to the ABAP editor and double-click the 100 button after the call screen to go to the screen maker, click the application toolbar (the screen of the sap gui is from top to bottom: menu bar, system toolbar, application title bar, application toolbar, main screen, and status bar. The main screen can be split as needed) the "format" button on the rightmost side opens the screen drawing interface and you can see the following interface:
Here we can see two screen elements: a text box named input, that is, the same as the global variable defined above; a button.
Running effect:
First, return to the program code interface and click the "execute" button (or press the keyboard shortcut key F8 ).
1. The selection screen is displayed as follows:
As you can see, an input box named input is displayed, and the content in it is Hello world! .
2. Click the "execute" button (or F8) on the toolbar of the application. The screen is displayed at 100 in the order of execution, for example:
This interface is the same as the screen designed on the screen drawing interface, but its value is filled with Hello world! This is because the ABAP runtime environment assigns the value of the input box to the global variable input. On this screen, the text field input has the same name as the global variable input, the system automatically assigns values, which is an important principle for SAP screen program development, namely:Mutual assignment between global variables with the same name and on-screen text fields is automatically completed.. In addition, we can see that both uppercase and lowercase texts in the previous interface are converted to uppercase letters, which is a special case for ABAP compared to other languages,If not specified, the entered English characters are automatically converted to uppercase letters.In the parameters (and select-options) definition, you can specify the lower case additional keyword to disable this conversion. For text fields on the screen, select the "Big/lowercase" check box in the text field attribute settings window to disable this conversion.
3. Click "second !" Or press enter to see the following interface,
This is the output value of input in 10th rows and 40th columns (the number of columns is calculated based on English characters, and a Chinese character occupies the width of two English characters. Click the return, exit, or cancel button in the system toolbar to return to the selection screen.
========================================================== ===
call ~ It took more than an hour to finally finish the simplest Hello World Program. The initial explanation will be detailed. We will focus on some details concerning general development principles and general directions. In the future, we will gradually reduce the basic concepts and focus on explaining specific statements. In addition, as the program grows, it is impossible to paste all program code in the future. You only need to analyze specific code lines as needed. Of course, the specific files and code lines will be clearly described.