Friday, 1 July 2022

Getting Started With ABAP: PART 2

This is the second blog post in this series. Here is the previous blog post Get Started with ABAP Programming From Scratch

In the first blog post, we learn how to create package and how to write your first program.

In this blog post you will learn how to print multiple text on same line and multiple line as well as how to give comments.

In previous blog post we have seen how to create package and program from transaction SE80. So, once you open SE80 (Transaction Code for ABAP Editor) you have already created the package so need to create it every time. Just right click on existing package name and create new program.

While creating program you will see the below window.

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

Here you can see that type of the program is Executable program. We can create other type of the program that we will learn in later part. Here we are creating Executable Program that is one of the types of program.

How to write multiple text on same line


We can do these two ways.

First Method:

Step 1: As we learned how to print text in previous blog post. Now I want to print two text on the same line.

Code:

Write ‘This is my first Program.’.
write ‘I am learning SAP ABAP.’.

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

Step 2: Check, Activate and Execute the program.

Output:

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

Second Method:

Step 1: Write Code.

Code:

Write: ‘This is my first Program.’,’ I am learning SAP ABAP.’.

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

Step 2: Check, Activate and Execute.

Output

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

In second method we used colon (:) just after write keyword. So, we don’t need to write two statement to print two or multiple text on same line. In this way you can print multiple text with just one statement.

How to print text on next line


Suppose I want to print second text on next line.

Step 1: Write code.

Code:

Write: ‘This is my first Program.’,/’I am learning SAP ABAP.’.

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

Output:

In this way we can print text on next line by using forward slash (/).

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

How to give comments


Full Line Comments:

We can give full line comments by using *.

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

Partial Line Comment:

We can give partial comment using “.

SAP ABAP, SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP News, SAP ABAP Programming

Here we have completed the second part of learning SAP ABAP programming.

Source: sap.com

No comments:

Post a Comment