Learn SAP Free
Back to Dashboard
ABAP Programming

WRITE Statement in ABAP – How to Display Output in SAP Programs

Daksh | July 19, 2026 | 7 min read

WRITE Statement in ABAP

Once you have declared your variables and assigned values to them, the next obvious question is — how do you actually see the result on the screen? That is where the WRITE statement comes in.

The WRITE statement is probably the most used statement in ABAP reports. It is the primary way to display output on the screen in classical ABAP programs. Every beginner starts with it, and even experienced developers use it regularly for debugging and testing their code.

In this guide, we will cover everything about the WRITE statement — from basic usage to formatting tricks that will make your output look clean and professional.


What is the WRITE Statement?

The WRITE statement sends output to the list screen (also called the report output screen) in SAP. When you run a program using transaction code SE38, the output you see on the screen is generated using WRITE statements.

Think of it like the print function in Python or System.out.println in Java. It simply takes whatever value you give it and puts it on the screen.


Why is WRITE Important?

You might be wondering — why do I even need to learn this separately? Can’t I just run my program and see the output?

Well, in SAP ABAP, nothing gets displayed on the screen automatically. Even if you have a variable with a value stored in it, the user will not see anything unless you explicitly tell the program to show it using the WRITE statement.

Here are some common situations where you will use it:

  • Displaying results of database queries
  • Showing calculated values like totals, averages, and counts
  • Printing employee details, material numbers, or sales data
  • Debugging your code by printing variable values at different points
  • Building simple report outputs before moving to ALV grids

Basic Syntax

The simplest form of WRITE is straightforward:

WRITE 'Hello World'.

This displays the text Hello World on the output screen. That is it. No extra configuration needed.

You can also display the value of a variable:

DATA lv_name TYPE string.
lv_name = 'Daksh'.
WRITE lv_name.

Output:

Daksh

Your First WRITE Program

Let us build a complete working program step by step:

REPORT z_write_demo.

DATA lv_message TYPE string.

lv_message = 'Welcome to SAP ABAP Learning'.

WRITE lv_message.

Output:

Welcome to SAP ABAP Learning

Nothing complicated here. We declare a variable, assign a text value, and display it. This is the foundation of every ABAP report.


Writing Output on a New Line

By default, the WRITE statement puts everything on the same line. If you want to move to a new line, use the forward slash (/) before the text or variable:

REPORT z_newline_demo.

WRITE 'Line One'.
WRITE / 'Line Two'.
WRITE / 'Line Three'.

Output:

Line One
Line Two
Line Three

Without the /, all three texts would appear on the same line joined together. The slash tells the system to start a new line before printing the next value.


Displaying Multiple Values on One Line

You can print multiple values on one line using the colon (:) operator. This is called a chained statement:

REPORT z_chain_write.

DATA: lv_first TYPE string,
      lv_last  TYPE string.

lv_first = 'Daksh'.
lv_last  = 'Dedha'.

WRITE: 'Name:', lv_first, lv_last.

Output:

Name: Daksh Dedha

The colon lets you write multiple things after one WRITE keyword. Each item is separated by a comma. This keeps your code shorter and easier to read.


Mixing New Lines and Same Line Output

You can combine both approaches. Use / where you want a new line, and skip it where you want items on the same line:

REPORT z_mixed_output.

WRITE: / 'Employee Report',
       / '================',
       / 'Name:', 'Daksh Dedha',
       / 'Department:', 'ABAP Development',
       / 'Employee ID:', '10045'.

Output:

Employee Report
================
Name: Daksh Dedha
Department: ABAP Development
Employee ID: 10045

This is how most simple reports are structured in real SAP projects.


Displaying Numbers and Dates

The WRITE statement handles different data types automatically. You do not need to convert numbers or dates to text before displaying them:

REPORT z_types_demo.

DATA: lv_age    TYPE i,
      lv_salary TYPE p DECIMALS 2,
      lv_date   TYPE d.

lv_age    = 25.
lv_salary = 85000.
lv_date   = sy-datum.

WRITE: / 'Age:', lv_age,
       / 'Salary:', lv_salary,
       / 'Today:', lv_date.

The system knows how to format integers, decimals, and dates on its own. Dates are displayed based on the user’s SAP settings (DD.MM.YYYY or MM/DD/YYYY depending on the configuration).


Formatting Your Output

Plain text output works fine, but sometimes you need more control over how things look. ABAP gives you several formatting options that you can use directly with the WRITE statement.

Setting Column Positions

You can place output at a specific column position on the screen. This helps in aligning values neatly:

WRITE: 'Name' UNDER 'Name',
       AT 5 'Column 5 starts here',
       AT 30 'Column 30 starts here'.

Or more commonly, you specify position as a number before the value:

WRITE AT 10 'This text starts at column 10'.

Controlling Field Length

You can limit how many characters are displayed:

DATA lv_text TYPE string.
lv_text = 'ABAP Programming Language'.

WRITE AT /10(15) lv_text.

Output:

          ABAP Programmi

Here, 10 is the starting column and (15) means display only 15 characters. The rest gets cut off.


Useful Formatting Additions

ABAP provides several keywords you can add to the WRITE statement for better formatting:

AdditionWhat It DoesExample
LEFT-JUSTIFIEDAligns text to the leftWRITE lv_name LEFT-JUSTIFIED.
RIGHT-JUSTIFIEDAligns text to the rightWRITE lv_amount RIGHT-JUSTIFIED.
CENTEREDCenters the textWRITE lv_title CENTERED.
NO-ZEROHides leading zerosWRITE lv_id NO-ZERO.
NO-SIGNHides negative signWRITE lv_amount NO-SIGN.
USING EDIT MASKApplies a formatting maskWRITE lv_phone USING EDIT MASK '___-___-____'.
COLORChanges background colorWRITE / lv_name COLOR 5.

Color Codes in ABAP

You can add colors to your output to make important values stand out:

WRITE: / 'Normal Text',
       / 'Blue Background' COLOR 1,
       / 'Light Blue' COLOR 2,
       / 'Yellow' COLOR 3,
       / 'Blue Green' COLOR 4,
       / 'Green' COLOR 5,
       / 'Red' COLOR 6,
       / 'Orange' COLOR 7.

Each color number gives a different background. This is helpful when building reports where you want to highlight totals, errors, or important rows.


Blank Lines and Horizontal Lines

To add a blank line in your output, use SKIP:

WRITE 'Section One'.
SKIP.
WRITE 'Section Two'.

To draw a horizontal line separator, use ULINE:

WRITE 'Report Header'.
ULINE.
WRITE 'Report Data Here'.

Output:

Report Header
----------------------------------------------------------------------
Report Data Here

These are small things, but they make your reports look much more professional and easier to read.


Building a Simple Employee Report

Let us put everything together and build a proper looking report:

REPORT z_employee_report.

DATA: lv_emp_id   TYPE i,
      lv_emp_name TYPE string,
      lv_dept     TYPE string,
      lv_salary   TYPE p DECIMALS 2.

* Report Header
WRITE: / 'Employee Report' COLOR 1,
       / sy-datum.
ULINE.

SKIP.

* Employee 1
lv_emp_id   = 1001.
lv_emp_name = 'Rahul Sharma'.
lv_dept     = 'ABAP Development'.
lv_salary   = 72000.

WRITE: / 'ID:', lv_emp_id,
       / 'Name:', lv_emp_name,
       / 'Department:', lv_dept,
       / 'Salary:', lv_salary.

SKIP.
ULINE.

* Employee 2
lv_emp_id   = 1002.
lv_emp_name = 'Priya Patel'.
lv_dept     = 'Fiori UI'.
lv_salary   = 68000.

WRITE: / 'ID:', lv_emp_id,
       / 'Name:', lv_emp_name,
       / 'Department:', lv_dept,
       / 'Salary:', lv_salary.

SKIP.
ULINE.
WRITE: / 'End of Report' COLOR 5.

This program displays a formatted employee report with headers, separators, and color coding. It covers almost everything we learned in this guide.


Common Mistakes to Avoid

1. Forgetting the Period

Every ABAP statement must end with a period. Missing it will throw a syntax error.

  • Wrong: WRITE 'Hello'
  • Right: WRITE 'Hello'.

2. Confusing Single Quotes and Double Quotes

ABAP uses single quotes for text literals. Double quotes start a comment.

  • Wrong: WRITE "Hello". (This is treated as a comment)
  • Right: WRITE 'Hello'.

3. Not Using New Line Slash

If your output looks like one long jumbled line, you probably forgot the / to move to a new line.

  • Wrong: WRITE 'A'. WRITE 'B'. (Output: AB on same line)
  • Right: WRITE / 'A'. WRITE / 'B'. (Output: A and B on separate lines)

WRITE vs WRITE AT — When to Use Which

FeatureWRITEWRITE AT
PurposeSimple outputPositioned output
Column ControlNoYes
Length ControlNoYes
Best ForQuick debugging, simple reportsFormatted tabular reports

Use basic WRITE when you just want to see a value quickly. Use WRITE AT when you need values aligned in specific columns, like building a table layout.


Interactive Checkpoints

🙋‍♂️ Checkpoint 1: What is the difference between WRITE and WRITE / ?
WRITE prints the value on the current line at the current cursor position. WRITE / moves the cursor to a new line first and then prints the value. The slash acts as a line break before the output.
🙋‍♂️ Checkpoint 2: How do you display a variable value at column 20 with only 10 characters?
You use the AT clause: WRITE AT 20(10) lv_variable. Here, 20 is the starting column position and (10) limits the output to 10 characters. If the value is longer than 10 characters, it gets truncated.
🙋‍♂️ Checkpoint 3: Can you use WRITE inside a loop?
Yes, WRITE works perfectly inside DO loops, WHILE loops, and LOOP AT statements. In fact, this is one of the most common patterns in ABAP — looping through an internal table and using WRITE to display each row on the screen.

Summary

The WRITE statement is your go-to tool for displaying output in classical ABAP programs. Whether you are printing a simple text message or building a formatted employee report with colors and column alignment, WRITE handles it all. Start with the basics, get comfortable with new lines and chained statements, then gradually explore formatting options like colors and column positioning. Once you master WRITE, you will have no trouble reading and creating any ABAP list report.

Daksh Dedha - SAP Technical Consultant

Written by Daksh Dedha

SAP Technical Consultant

Daksh is an SAP Technical Consultant specializing in ABAP programming, SAP S/4HANA migrations, Fiori development, and BTP cloud architecture. He authors free, hands-on tutorials to make enterprise SAP education accessible to all developers.

Test Your Knowledge

SAP Challenge Question 1 of 10

Loading question...

Found this tutorial useful? Share it with your SAP development team.