May 13, 2016

ABAP Write Command


The write command used to be the bread and butter of SAP report writing where 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 this is no longer used but its use is more for batch programs so that message appear in the output log, 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.

  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

How to Compare Between Two Sapscript Forms

How to compare between two Sapscript forms? Here are the steps.

Steps:
1. Go to transaction SE38 and enter program name RSTXFCOM.

2. Put the clients, form names and the attributes.

3. The differences will be highlighted in red


May 12, 2016

Display Icon on List with Description


ABAP Codes:

REPORT z_icon_on_screen_field .

*********************************************************
* The icons on the list can be displayed using the      *
* statement WRITE <symbol-name> AS ICON           *
* but when we display the icons using the               *
* function module ICON_CREATE, we can get the           *
* description of the icon on moving the cursor          *
* over the icon                                         *
*********************************************************

* This program illustrates the differences between using
* the above two mentioned methods.......................

INCLUDE <icon>.

* declaring the work variables..........................................
DATA :
  icon_result   TYPE icons-text,
  icon_name(20TYPE c,
  icon_text(20TYPE c,
  icon_info     LIKE icont-quickinfo.

* to display the user name with an icon...
WRITE 'Using the statement WRITE <symbol-name> AS ICON'.
WRITE :/ icon_employee AS ICONsy-uname.
SKIP.

WRITE :'Using the function module ICON_CREATE'.

icon_name 'ICON_EMPLOYEE'.
icon_text =  sy-uname.
icon_info 'Employee Name'.

PERFORM iconcreation.
CONDENSE icon_result.
WRITE :/ icon_result.

*&---------------------------------------------------------------------*
*&      Form  iconcreation
*&---------------------------------------------------------------------*
* This subroutine is used to create the icons with the text
*----------------------------------------------------------------------*

FORM iconcreation.

  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name                  icon_name
      text                  icon_text
      info                  icon_info
      add_stdinf            ' '
    IMPORTING
      result                icon_result
    EXCEPTIONS
      icon_not_found        1
      outputfield_too_short 2
      OTHERS                3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM.                    " iconcreation



Source: saptechnical.com