Tuesday, January 31, 2017

Simple Write Report in SAP

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

Result:


Hello World!

Hello World! This is the first post i just published on the day i made this blog on 31th January 2017. I believe most of the readers here have been familiar with my "Hello World!" phrase which is used in your very first program with a particular new language and here I will share my knowledge in ABAP language in this blog for everyone to learn.

If you haven't heard of ABAP, it is stands for Advanced Business Application Programming, originally Allgemeiner Berichts-Aufbereitungs-Prozessor in German, a high-level programming language created by the German software company, SAP SE. Hence, it can only be used in its ERP Software's environment, SAP for customisations of feature implementation in it.

By the way, my name is Evan Christiawan, I am a graduate student from Murdoch University majoring in Computer Science and Cyber Forensics. Currently, I work as ABAP technical consultant at Soltius Indonesia, a subsidiary of Metrodata Group that focuses its business in dealing with SAP Solution to help companies run better.

I think that's all for the introduction and won't introduce more about me unless you want to know me more :). Hopefully i can keep updating posts/notes in this blog and help lots of people who are curious in learning ABAP, a language of SAP.