Hello World in ABAP
Your first ABAP program - the classic Hello World example running on Node.js via the open-abap transpiler
Every programming journey starts with Hello World. While ABAP traditionally requires SAP system access, the open-abap project lets us run ABAP code on Node.js by transpiling it to JavaScript.
The Code
Create a file named hello.abap:
| |
That’s it - just two lines for ABAP Hello World!
Understanding the Code
Let’s break down this simple program:
REPORT Statement
| |
REPORT- Declares this is an executable program (report)zhello- The program name (Z prefix indicates custom/customer namespace in SAP).- ABAP statements end with a period
In SAP systems, program names must start with Z or Y for customer-developed programs. The standard SAP namespace uses other prefixes.
WRITE Statement
| |
WRITE- Outputs text to the list buffer'Hello, World!'- A character literal (string).- Statement terminator
Unlike most languages that print directly to console, ABAP writes to a “list” - a buffer that displays when the program finishes. This design comes from ABAP’s origins as a report generator.
Running with Docker
Running ABAP outside SAP requires the open-abap transpiler. Here’s a Docker command that sets up everything:
| |
Understanding the Docker Command
This command does several things:
- Mounts current directory -
-v $(pwd):/workmakes yourhello.abapavailable - Creates project structure - Sets up npm project with required dependencies
- Installs transpiler -
@abaplint/transpiler-cliconverts ABAP to JavaScript - Creates config files - Sets up the transpiler configuration
- Adds abapGit metadata - The XML file describes the ABAP object
- Transpiles and runs - Converts ABAP to JS and executes it
The open-abap transpiler requires files in abapGit format (.prog.abap for programs, with matching .xml metadata).
Expected Output
Hello, World!
How open-abap Works
The open-abap project transpiles ABAP to JavaScript:
ABAP Source → Transpiler → JavaScript → Node.js Runtime
For example, our WRITE statement becomes:
| |
The @abaplint/runtime package provides the abap object with all ABAP statement implementations.
Alternative: Simplified Runner Script
For repeated development, create a runner script. Save as run_abap.sh:
| |
Usage:
| |
ABAP Syntax Basics
Even in Hello World, we can explore ABAP’s distinctive syntax:
Statement Structure
| |
- Keywords are uppercase (though ABAP is case-insensitive)
- Statements end with periods
- Multiple statements per line are allowed but discouraged
Variations on WRITE
| |
The colon (:) after WRITE allows multiple outputs with a single keyword - a common ABAP pattern.
Comments
| |
Data Types Preview
ABAP has rich data types built for business applications:
| |
The ABAP List System
WRITE doesn’t immediately print - it writes to a “list buffer”:
| |
This design enables:
- Scrollable reports
- Print-ready output
- Page headers/footers
- Interactive reports (in SAP GUI)
String Templates (Modern ABAP)
ABAP 7.40+ introduced string templates:
| |
Note: String templates use | delimiters and { } for embedded expressions.
Real SAP vs open-abap
Feature comparison:
| Feature | SAP System | open-abap |
|---|---|---|
| Core ABAP syntax | Full | Most of 7.02+ |
| Database (Open SQL) | Full | SQLite/PostgreSQL |
| WRITE statement | Yes | Yes |
| ALV grids | Yes | No |
| SAP GUI dialogs | Yes | No |
| Web services | Yes | Partial |
| Unit tests | ABAP Unit | Yes |
open-abap is excellent for:
- Learning ABAP syntax
- Algorithm practice
- Unit testing logic
- Running on platforms like Exercism
For full SAP development, you’ll need SAP system access.
Getting SAP Access
For complete ABAP development:
SAP Learning Hub
- Free trial systems from SAP
- Web-based access
- Good for certification prep
ABAP Platform Trial (Docker)
- Full SAP system in Docker
- Requires 16GB+ RAM
- Large download (~23GB)
| |
SAP BTP Trial
- Cloud-based ABAP environment
- Free tier available
- Modern ABAP Cloud development
Historical Note
ABAP was created in 1983 by Gerd Rodé at SAP. The name originally stood for “Allgemeiner Berichts-Aufbereitungs-Prozessor” (German for “General Report Preparation Processor”), reflecting its origins as a report generation language for SAP R/2 mainframes.
The WRITE statement and list buffer concept come directly from this report-generation heritage - ABAP was designed to create formatted business reports, not interactive console applications.
Today, ABAP powers critical systems at 90% of Fortune 500 companies, processing trillions of dollars in transactions annually.
Next Steps
Continue to Variables and Data Types to learn about ABAP’s rich type system designed for business applications.
Key Takeaways
- REPORT declares an executable program
- WRITE outputs to the list buffer
- Periods terminate all ABAP statements
- Z/Y prefix indicates customer namespace
- open-abap transpiles ABAP to JavaScript for Node.js
- ABAP’s list buffer comes from its report-generation origins
- Modern ABAP (7.40+) includes string templates and inline declarations