Preparation
Although I have posted my very first Hello World post, I haven't demonstrate any tutorial yet. Therefore, i will guide you to create your very first report Program at SAP with ABAP. First of all, you will need: - SAP GUI on your computer - Authenticated SAP account to access an SAP Server If you do not have an access to SAP, I am afraid you have to create your very own SAP Server known as SAP IDES (Internet Demonstration and Evaluation System) for the purpose of training and learning by following one of two tutorials here:Where to Start?
Once you managed to logged on SAP System, you can start go to ABAP Editor with t-code SE38 in the command field at the top left of the SAP screen.Type your program name starting with letter Y or Z (OBLIGATORY) like Y_MY_PROGRAM, then press Create Button and type the Program title and choose Executable Program as the type. After that save and choose $TMP (Local Object) as the package unless you need to transport this program.
PRINT, I mean WRITE
Once you are in ABAP Editor, you can start create your very first program in the next ABAP Editor Window, simply write these two lines of codes:
REPORT y_my_program. WRITE 'Hello World!'.Once you are done, Press Direct Processing Button (F8) And voila, your Hello World! Report Program in SAP :D On any other language, you might end your programming statement with semicolon (;), in ABAP, you use dot (.) just like a sentence. You can write more words or variable in the write sentence using semicolon (:), it is used to input multiple data in many ABAP syntax like write.
Example:
WRITE: 'This', 'is' , 'my', 'first', 'program'.This is the same like writing the following statements
WRITE 'This'. WRITE 'is'. WRITE 'my'. WRITE 'first'. WRITE 'program'.
Next Line Please
These statement will give the same exact result like this, continuing the previous Hello World, it seems that it gives a space to every word
To enter a new line you can use slash (/) in the write syntax.
WRITE / 'This is my second line'.
However, using slash seems too redundant to have some line spacing, hence you can use
SKIP [number of lines] to skip some lines.
SKIP 2.
Stick Your Notes
Another important thing to know is commenting in your ABAP code, you can use asterisk (*) to give a full commend in a line and double quote (") to give partial commend at the end of a statement. Last tips to do a block commenting, you can make the use of ctrl + (<) to comment and ctrl + (>) to uncomment.*Write any bullshit in the line when there is an asterisk in the front WRITE 'End of my Hello World Report'. "This is the end
Compilation
To give the whole idea of this tutorial, please mind to look and try yourself compiled code below.Source Code:
REPORT y_my_program. WRITE 'Hello World!'. WRITE: 'This', 'is' , 'my', 'first', 'program'. *Next line WRITE / 'This is my second line'. *Another method to make new line SKIP 2. *Write any bullshit in the line when there is an asterisk in the front WRITE 'End of my Hello World Report'. "This is the end * _ ____ _ ____ * / \ | __ ) / \ | _ \ Block Comment * / _ \ | _ \ / _ \ | |_) | Use CTRL + < * / ___ \| |_) / ___ \| __/ will automatically put asterisk */_/ \_\____/_/ \_\_| in the front of the block