ABAP offers programmers a variety of types of programs that define the essential technical attributes of the application. When building a program from scratch, our first concern is to figure out what type of program we’re making. Each program type calls its processing blocks differently, as we’ll see as we delve into them in more detail.
Type 1 programs are controlled exclusively by the runtime environment. These programs can be run using the SUBMIT keyword followed by the program name in another ABAP code block or simply entering the program name to ABAP. Because they’re run in this way, we refer to Type 1 programs as “executables,” not unlike *.exe programs in Windows. Type 1 programs lean towards reporting. They read data from the database, process it, and display the results to the user. Because of this function, most non-specialists refer to Type 1 programs as reports.
Type M programs are the opposite of Type 1 programs in that they are run exclusively through user input. They’re usually started using a transaction code that leads the user to the screens they’ll use for their interaction. Because they use dialog modules in their interaction, specialists refer to Type M programs as module pools.
These programs are collections of function calls that can be run explicitly (through calling the program name) or implicitly (through a transaction code). Type F programs are called function groups because they’re made up of individual functions bundled together. The ABAP Workbench has a handy feature called the Function Builder to help you put these function modules together.
These cannot be called like the previously mentioned program types. Type K programs contain the definition of global classes that can be shared throughout your ABAP programs. The ABAP Workbench also offers support in the form of a Class Builder for putting them together.
Type J programs are global interface structures that house interface objects. Like Type K programs, they can’t be called implicitly or explicitly. They house a collection of interface definitions that can be used in other programs. The Class Builder is also used to create interface definitions.
Similar to Types J and K, Type S programs are containers for something else, in this case, subroutines. They can’t be called implicitly or explicitly, but other programs can access their internal subroutines. Type S programs are typically known as subroutine pools.
Type I programs are known as INCLUDE programs since they can be brought into another ABAP program by using the INCLUDE keyword. The ABAP Workbench can automatically handle splitting up module pools and function groups into their own separate includes.
When writing in ABAP, we use statements to tell SAP what we want it to do. A statement is divided up into a keyword and a literal. Sometimes the literal is a program name if you’d like ABAP to run a program, for example. ABAP keywords determine the statement type. There are several different types of statements that can be used in an ABAP program.
1. Database Statements
These statements are used to interact with SAP’s databases. They can come in one of two types: Native SQL and Open SQL. If you’ve ever dealt with databases in the past, the statements here shouldn’t be much of a surprise. The syntax largely follows what a user would expect from an SQL-based language, including keywords like SELECT, DELETE, INSERT, etc.
2. Operational Statements
Operations statements are used to process data and generate a result. Users who have dealt with other languages can think of these as console output statements or data manipulation statements. Some of the commands you’re likely to find in this category include WRITE, ADD, and MOVE.
3. Call Statements
When you’re working with processing blocks and need to call them to perform an action or a function, the call statements are what you’ll use. A user can call processing blocks from within the same program that they’re defined or from a completely different application altogether. These commands include the CALL, PERFORM, and SUBMIT keywords.
4. Control Statements
Control statements deal with the flow of a program’s block execution. They are similar to flow statements in other languages and include keywords such as IF…ELSE, WHILE, and CASE…WHEN.
5. Defining Statements
These are used to define an array of blocks. Functions, modules, and forms are usually defined within the boundaries of these keywords. For example, defining the process within a function takes place between the FUNCTION and ENDFUNCTION keywords.
6. Event Statements
Events are a type of processing block that a user can define. When events fire, all the elements subscribed to the said event are notified and can perform actions based on the event’s state. Common examples of event statements include START-OF-SELECTION and AT USER-COMMAND.
7. Declarative Statements
These statements are used in declaring variables that other ABAP objects can later use. These keywords are the core component of declarative statements. For example, these may include DATA, TABLES, etc.
Learning ABAP Starts With Practice
A lot of ABAP coding is just referencing things that already exist in the definitions and guidelines provided by SAP. However, doing it yourself isn’t a recipe for success either. Learning from your mistakes usually requires someone else’s help to get you through the complex parts of the language. ABAP forums can be a valuable and helpful tool to help you overcome your issues with ABAP and become a better programmer. Don’t be afraid to ask for help. We all started as beginners at some point. Getting started with ABAP doesn’t have to be complicated, even if you have no prior coding experience. However, as you learn, you’ll realize that ABAP is relatively intuitive. All it really takes is time.