ABAP WRITE statement command with in SAP to display data report to users

The write statement was once the bread and butter of SAP report writing if a user wanted to view the data on screen. This is not used as much for report writing as easier more advanced techniques are available such as the Advance List Viewer (ALV). This does not mean the write statement is no longer used but its use has become more specialised. For example it is still very effective within backgropund batch programs so that output messages appear within the output log report, reports that only need a simple message output and other output uses where a report consisting of columns of data is not appropriate.

Below is an ABAP code extract that demonstrates and explains the basic functionally of the write command.

*&-Code extract to demonstrate the SAP write command-----------*
*&                                                             *
*& Author : www.SAP Development                                   *
*&  SAP ABAP development                                       *
*&-------------------------------------------------------------*
****************************************************************
*End-OF-selection.
End-OF-selection.

  write:/10(45) 'Total No of Employees entered:', gd_records,  "/10 indents 10 chars
        /10(45) 'Number of Employees processed successfully:', "(45) sets field lenth
                gd_success. "displays variable
  NEW-LINE.  "moves to a new line
  describe table it_error lines gd_lines. "gets number of records in a table
  check gd_lines gt 0.  "check there are some error records
  skip 2. "skips 2 lines
  write:/10 'Unsuccessful Employee records'.  "(10) makes field take up 10 chars
  write:/10 sy-uline(67).   "sy-uline(67) display a line 67 chars long
  write:/10  sy-vline,   "sy-vline creates a vertical line
        (10) 'Employee' COLOR COL_HEADING, sy-vline, "COLOR changes background colour
        (50) 'Description'  COLOR COL_HEADING, sy-vline.
  write:/10 sy-uline(67).     "display a line 67 chars long
  loop at it_error into wa_error.  "loops at err table
    write:/10  sy-vline,      "sy-vline creates a vertical line
          (10) wa_error-pernr, sy-vline,  "(10) makes field take up 10 chars
          (50) wa_error-text, sy-vline.
  endloop.
  write:/10 sy-uline(67). "display a line 67 chars long


Related Articles

ABAP COLLECT statement syntax to add up all numeric internal table values within SAP
ABAP DELETE statement keyword to delete data from SAP internal and database tables
ABAP DESCRIBE statement keyword to get information about tables and fields
PERFORM TABLES command passing internal table as parameter
ABAP read command to read line of internal table in SAP
ABAP UPDATE command to modify database field values
AUTHORITY-CHECK abap Statement / command
ABAP delete command in SAP
ABAP MODIFY statement to update SAP data within database and internal tables
SAP ABAP Statement syntax including basic implementation code
Concatenate ABAP statement syntax for concatenating data objects, sting values or rows of an SAP internal table
ABAP EXPORT data TO MEMORY ID and import it back again
IF, CHECK & WHEN ABAP commends example source code and information
Call Function module IN BACKGROUND TASK - Execute abap code in seperate background process
Function module IN UPDATE TASK statement - Execute abap code in seperate unit of work
ABAP STRLEN command to get the value length of a SAP field
SAP ABAP SELECT command and its different uses
SELECT..ENDSELECT command
ABAP FOR ALL ENTRIES SELECT statement addition in SAP data retrieval
ABAP SELECT inner join statement to select from two tables at the same time
SELECT directly into an internal table
SELECT directly into an internal table when field order is different
Function module STARTING NEW TASK statement - Execute abap code in seperate work process