📜 ⬆️ ⬇️

Introduction to ABAP

Hi, Habr!

Since there are very few articles about ABAP on Habré, and there are absolutely no articles like “Hello, World!”, I decided to write a little about it. If you are interested in learning about this language or are thinking about developing on ABAP, then welcome under cat.

ABAP (Advanced Business Application Programming) is an internal high-level programming language in the SAP environment. I don’t really want to delve into the history, but I would just note that the language syntax of the language is closest to the programming language COBOL.
')
The language allows working with internal data structures, user interfaces, transactions, reports, download interfaces, data uploads (word, excel, pdf, ...); It should be noted that object-oriented constructions (ABAP Objects) can be used; There are many communication technologies with other systems (BAPI, RFC, ...) for uploading and downloading data (or third-party processing).

Typing

Variables in ABAP are usually declared using the DATA construct.

DATA: count TYPE i. "   count  integer 

I would like to note that the operators in the code begin with reserved words and end with a period.

You can shorten the declaration of several variables, separated by a comma and using the colon symbol:

 DATA: count TYPE i, sum TYPE i. 

Inside the program, you can use the types embedded in the ABAP dictionary, as well as create your own types and structures using the TYPES construct.

 TYPES: person_code(15) TYPE c. "     15  DATA: iv_person_code TYPE person_code. "      

Example with structure:

 TYPES: BEGIN OF struct, name(10) type C, "    10  post(15) type C, END OF struct. DATA: wa_struct TYPE STANDARD TABLE OF struct. "     DATA: name_person LIKE wa_struct-name. "    name   

In dynamic programming, it is customary to use fields of type FIELD SYMBOLS (analogue of the pointer):

 FIELD-SYMBOLS <fs> TYPE ANY. DATA: field TYPE string VALUE 'Bob Marley'. ASSIGN field TO <fs>. WRITE <fs>. 

Tables can be declared both from the ABAP dictionary, as well as from their internal structure types:

 DATA: gt_0001 TYPE TABLE OF pa0001. "   DATA: BEGIN OF t_tab, name TYPE string, count TYPE I, END OF t_tab. DATA: gt_tab LIKE TABLE OF T_TAB WITH HEADER LINE. "         ,        (  ..). 

Development environment

ABAP has its own development environment called ABAP Workbench, which has a debugger, tracing tools, version control system, buffer management tools, usage logs, and so on.
In 2012, the developers integrated ABAP with the well-known IDE Eclipse. The truth is it works on the latest versions of the kernel, which is not on all projects.



Preface before “Hello, World”

I really don't want the article to be long. In short, I will write that ABAP supports work with all arithmetic, string operations, has a standard set of condition statements, cycles, exception handling, has many reporting technologies, supports working with a database (OPEN SQL), and so on.

There are routines, function modules, macros, work with the web (Web Dynpro, BSP), uploading data to word, excel (via OLE), user interfaces, dialogs, and so on. There are even a few developer certifications. I will try to tell everyone about this in the following posts.

Hello, World!

So, if you were lucky to get access to the SAP development system or you found a virtual machine on all your favorite Russian tracker on the request “mini sap on vmware (abap)” , then I will show you how to create your own program.

First of all, go to the SAP system (via the SAP GUI):


Next, in the window, enter the transaction se38:


In accordance with the name of the user program (starting with Z), enter the name of your program:



and push the create button. Next, enter the program header, select the type and click save.



Choose a save package (for tests, I advise you to choose the $ TMP package or save with the "Local object" button)



Next we get to the ABAP-editor window. Enter the code of our program:

 REPORT Z_TEST_4. "  DATA: write_it TYPE string. write_it = 'Hello, World!'. WRITE: write_it. *    WRITE:/ 'Hello, World!'. 

Activate the program:


And run:


Result:


Conclusion

In this article I wrote a little about ABAP, its syntax and, of course, Hello, World!
In the following articles I plan to describe arithmetic, string operations, work with the database and introduce the ABAP reporting with specific examples and manuals. Well, then how it goes.

Some literature:

For beginners:
Courses:

Books:

For advanced:
Courses:

Books:

Internet sources:

Source: https://habr.com/ru/post/161751/


All Articles