sapdev logo background
sapdev logo sapdev logo

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 :                                   *
*&  SAP ABAP development                                       *


  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.

  write:/10 sy-uline(67). "display a line 67 chars long

comments powered by Disqus