Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Character String and Byte String Processing →  Expressions and Functions for String Processing →  string_exp - String Expressions →  string_exp - String Templates →  Examples of string templates 

String Templates, Alignments, and Padding

This example demonstrates how to specify an alignment and how to pad embedded expressions.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA pad TYPE c LENGTH 1.
    cl_demo_input=>request( CHANGING field = pad ).

    cl_demo_output=>new(
      )->write( |{ 'Left'   WIDTH = 20 ALIGN = LEFT   PAD = pad }<---|
      )->write( |{ 'Center' WIDTH = 20 ALIGN = CENTER PAD = pad }<---|
      )->write( |{ 'Right'  WIDTH = 20 ALIGN = RIGHT  PAD = pad }<---|
      )->display( ).

Description

The alignment of three character string templates is declared statically. The character used to pad the superfluous places can be entered using an input field.