- SAP ABAP - Web Dynpro
- SAP ABAP - Business Add-Ins
- SAP ABAP - User Exits
- SAP ABAP - Customer Exits
- SAP ABAP - SAPscripts
- SAP ABAP - Smart Forms
- SAP ABAP - Dialog Programming
- SAP ABAP - Report Programming
- SAP ABAP - Object Events
- SAP ABAP - Interfaces
- SAP ABAP - Encapsulation
- SAP ABAP - Polymorphism
- SAP ABAP - Inheritance
- SAP ABAP - Classes
- SAP ABAP - Objects
- SAP ABAP - Object Orientation
- SAP ABAP - Deleting Internal Tables
- SAP ABAP - Reading Internal Tables
- SAP ABAP - Copying Internal Tables
- ABAP - Populating Internal Tables
- SAP ABAP - Creating Internal Tables
- SAP ABAP - Internal Tables
- SAP ABAP - Native SQL Overview
- SAP ABAP - Open SQL Overview
- SAP ABAP - Include Programs
- SAP ABAP - Function Modules
- SAP ABAP - Macros
- SAP ABAP - Subroutines
- SAP ABAP - Modularization
- SAP ABAP - Lock Objects
- SAP ABAP - Search Help
- SAP ABAP - Views
- SAP ABAP - Structures
- SAP ABAP - Tables
- SAP ABAP - Data Elements
- SAP ABAP - Domains
- SAP ABAP - Dictionary
- SAP ABAP - Exception Handling
- SAP ABAP - Formatting Data
- SAP ABAP - Date & Time
- SAP ABAP - Strings
- SAP ABAP - Decisions
- SAP ABAP - Loop Control
- SAP ABAP - Operators
- SAP ABAP - Constants & Literals
- SAP ABAP - Variables
- SAP ABAP - Data Types
- SAP ABAP - Basic Syntax
- SAP ABAP - Screen Navigation
- SAP ABAP - Environment
- SAP ABAP - Overview
- SAP ABAP - Home
SAP ABAP Useful Resources
- SAP ABAP - Discussion
- SAP ABAP - Useful Resources
- SAP ABAP - Quick Guide
- SAP ABAP - Questions Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SAP ABAP - Formatting Data
ABAP offers various types of formatting options to format the output of programs. For example, you can create a pst that includes various items in different colors or formatting styles.
The WRITE statement is a formatting statement used to display data on a screen. There are different formatting options for the WRITE statement. The syntax of the WRITE statement is −
WRITE <format> <f> <options>.
In this syntax, <format> represents the output format specification, which can be a forward slash (/) that indicates the display of the output starting from a new pne. In addition to the forward slash, the format specification includes a column number and column length. For example, the WRITE/04 (6) statement shows that a new pne begins with column 4 and the column length is 6, whereas the WRITE 20 statement shows the current pne with column 20. The parameter <f> represents a data variable or numbered text.
The following table describes various clauses used for formatting −
S.No. | Clause & Description |
---|---|
1 | LEFT-JUSTIFIED Specifies that the output is left-justified. |
2 | CENTERED Denotes that the output is centered. |
3 | RIGHT-JUSTIFIED Specifies that the output is right-justified. |
4 | UNDER <g> The output starts directly under the field <g>. |
5 | NO-GAP Specifies that the blank after field <f> is rejected. |
6 | USING EDIT MASK <m> Denotes the specification of the format template <m>. Using No EDIT Mask: This specifies that the format template specified in the ABAP Dictionary is deactivated. |
7 | NO-ZERO If a field contains only zeroes, then they are replaced by blanks. |
Following are the formatting options for Numeric Type fields −
S.No. | Clause & Description |
---|---|
1 | NO-SIGN Specifies that no leading sign is displayed on the screen. |
2 | EXPONENT <e> Specifies that in type F (the floating point fields), the exponent is defined in <e>. |
3 | ROUND <r> The type P fields (packed numeric data types) are first multipped by 10**(-r) and then rounded off to an integer value. |
4 | CURRENCY <c> Denotes that the formatting is done according to the currency <c> value that is stored in the TCURX database table. |
5 | UNIT <u> Specifies that the number of decimal places is fixed according to the <u> unit as specified in the T006 database table for type P. |
6 | DECIMALS <d> Specifies that the number of digits <d> must be displayed after the decimal point. |
For instance, the following table shows different formatting options for the date fields −
Formatting Option | Example |
---|---|
DD/MM/YY | 13/01/15 |
MM/DD/YY | 01/13/15 |
DD/MM/YYYY | 13/01/2015 |
MM/DD/YYYY | 01/13/2015 |
DDMMYY | 130115 |
MMDDYY | 011315 |
YYMMDD | 150113 |
Here, DD stands for the date in two figures, MM stands for the month in two figures, YY stands for the year in two figures, and YYYY stands for the year in four figures.
Let’s take a look at an example of ABAP code that implements some of the above formatting options −
REPORT ZTest123_01. DATA: n(9) TYPE C VALUE Tutorials , m(5) TYPE C VALUE Point . WRITE: n, m. WRITE: / n, / m UNDER n. WRITE: / n NO-GAP, m. DATA time TYPE T VALUE 112538 . WRITE: / time, /(8) time Using EDIT MASK __:__:__ .
The above code produces the following output −
Tutorials Point Tutorials Point TutorialsPoint 112538 11:25:38Advertisements