Powered By

Free XML Skins for Blogger

Powered by Blogger

Showing posts with label SAP ABAP Sample Project. Show all posts
Showing posts with label SAP ABAP Sample Project. Show all posts

Saturday, October 18, 2008

SAP ABAP The Employee Example - step by step example

1. Simple class

This example shows how to create a simple employee class. The constructor method is used to initialize number and name of thje employee when the object is created. A display_employee method can be called to show the attributes of the employee, and CLASS-METHOD dosplay_no_of_employees can be called to show the total number of employees (Number of instances of the employee class).

REPORT zbc404_hf_events_1.
*********************************************************************
* L C L _ E M P L O Y E E
*********************************************************************
*---- LCL Employee - Definition
CLASS lcl_employee DEFINITION.
PUBLIC SECTION.
*--------------------------------------------------------------------
* The public section is accesible from outside
*--------------------------------------------------------------------
    TYPES:
BEGIN OF t_employee,
no TYPE i,
name TYPE string,
END OF t_employee.
    METHODS:
constructor
IMPORTING im_employee_no TYPE i
im_employee_name TYPE string,
      display_employee.
*   Class methods are global for all instances       
CLASS-METHODS: display_no_of_employees.
  PROTECTED SECTION.
*--------------------------------------------------------------------
* The protecetd section is accesible from the class and its subclasses
*--------------------------------------------------------------------
*   Class data are global for all instances     
CLASS-DATA: g_no_of_employees TYPE i.
  PRIVATE SECTION.
*--------------------------------------------------------------------
* The private section is only accesible from within the classs
*--------------------------------------------------------------------
DATA: g_employee TYPE t_employee.
ENDCLASS.
*--- LCL Employee - Implementation
CLASS lcl_employee IMPLEMENTATION.
METHOD constructor.
g_employee-no = im_employee_no.
g_employee-name = im_employee_name.
g_no_of_employees = g_no_of_employees + 1.
ENDMETHOD.
  METHOD display_employee.
WRITE:/ 'Employee', g_employee-no, g_employee-name.
ENDMETHOD.
  METHOD display_no_of_employees.
WRITE: / 'Number of employees is:', g_no_of_employees.
ENDMETHOD.
ENDCLASS.
************************************************************************
* R E P O R T
*********************************************************************
DATA: g_employee1 TYPE REF TO lcl_employee,
g_employee2 TYPE REF TO lcl_employee.
START-OF-SELECTION.
CREATE OBJECT g_employee1
EXPORTING im_employee_no = 1
im_employee_name = 'John Jones'.
  CREATE OBJECT g_employee2
EXPORTING im_employee_no = 2
im_employee_name = 'Sally Summer'.
  CALL METHOD g_employee1->display_employee.
CALL METHOD g_employee2->display_employee.
  CALL METHOD g_employee2->display_no_of_employees.

2. Inheritance and polymorphism

This example uses a superclass lcl_company_employees and two subclasses lcl_bluecollar_employee and lcl_whitecollar_employee to add employees to a list and then display a list of employees and there wages. The wages are calcukated in the method add_employee, but as the wages are calculated differently for blue collar employees and white collar emplyees, the superclass method add_employee is redeifined in the subclasses.

Principles:

Create super class LCL_CompanyEmployees.

The class has the methods:

  • Constructor
  • Add_Employee - Adds a new employee to the list of employees
  • Display_Employee_List - Displays all employees and there wage
  • Display_no_of_employees - Displays total number of employees

Note the use of CLASS-DATA to keep the list of employees and number of employees the same from instance to instance.

Create subclasses lcl_bluecollar_employee and lcl_whitecollar_employee. The calsses are identical, except for the redifinition of the add_employee method, where the caclculation of wage is different.

Methodes:

  • Constructor. The constructor is used to initialize the attributes of the employee. Note that the constructor in the supclasss has to be called from within the constructor of the subclass.
  • Add_Employee. This is a redinition of the same method in the superclass. In the redefined class the wage is calcuated, and the superclass method is called to add the employees to the emploee list.:

The program

REPORT zbc404_hf_events_2 .
*******************************************************
* Super class LCL_CompanyEmployees
*******************************************************
CLASS lcl_company_employees DEFINITION.
PUBLIC SECTION.
TYPES:
BEGIN OF t_employee,
no TYPE i,
name TYPE string,
wage TYPE i,
END OF t_employee.
    METHODS:
constructor,
add_employee
IMPORTING im_no TYPE i
im_name TYPE string
im_wage TYPE i,
      display_employee_list,
display_no_of_employees.

PRIVATE SECTION.
CLASS-DATA: i_employee_list TYPE TABLE OF t_employee,
no_of_employees TYPE i.
ENDCLASS.
*-- CLASS LCL_CompanyEmployees IMPLEMENTATION
CLASS lcl_company_employees IMPLEMENTATION.
METHOD constructor.
no_of_employees = no_of_employees + 1.
ENDMETHOD.
  METHOD add_employee.
* Adds a new employee to the list of employees
DATA: l_employee TYPE t_employee.
l_employee-no = im_no.
l_employee-name = im_name.
l_employee-wage = im_wage.
APPEND l_employee TO i_employee_list.
ENDMETHOD.
  METHOD display_employee_list.
* Displays all employees and there wage
DATA: l_employee TYPE t_employee.
WRITE: / 'List of Employees'.
    LOOP AT i_employee_list INTO l_employee.
WRITE: / l_employee-no, l_employee-name, l_employee-wage.
ENDLOOP.
  ENDMETHOD.
  METHOD display_no_of_employees.
* Displays total number of employees
SKIP 3.
WRITE: / 'Total number of employees:', no_of_employees.
ENDMETHOD.
ENDCLASS.
*******************************************************
* Sub class LCL_BlueCollar_Employee
*******************************************************
CLASS lcl_bluecollar_employee DEFINITION
INHERITING FROM lcl_company_employees.

PUBLIC SECTION.
METHODS:
constructor
IMPORTING im_no TYPE i
im_name TYPE string
im_hours TYPE i
im_hourly_payment TYPE i,
add_employee REDEFINITION.
  PRIVATE SECTION.
DATA:no TYPE i,
name TYPE string,
hours TYPE i,
hourly_payment TYPE i.

ENDCLASS.
*---- CLASS LCL_BlueCollar_Employee IMPLEMENTATION
CLASS lcl_bluecollar_employee IMPLEMENTATION.
METHOD constructor.
* The superclass constructor method must be called from the subclass
* constructor method

CALL METHOD super->constructor.
no = im_no.
name = im_name.
hours = im_hours.
hourly_payment = im_hourly_payment.
  ENDMETHOD.
  METHOD add_employee.
* Calculate wage an call the superclass method add_employee to add
* the employee to the employee list

DATA: l_wage TYPE i.
l_wage = hours * hourly_payment.
    CALL METHOD super->add_employee
EXPORTING im_no = no
im_name = name
im_wage = l_wage.
ENDMETHOD.
ENDCLASS.
*******************************************************
* Sub class LCL_WhiteCollar_Employee
*******************************************************

CLASS lcl_whitecollar_employee DEFINITION
INHERITING FROM lcl_company_employees.

PUBLIC SECTION.
METHODS:
constructor
IMPORTING im_no TYPE i
im_name TYPE string
im_monthly_salary TYPE i
im_monthly_deductions TYPE i,
add_employee REDEFINITION.
  PRIVATE SECTION.
DATA:
no TYPE i,
name TYPE string,
monthly_salary TYPE i,
monthly_deductions TYPE i.
ENDCLASS.
*---- CLASS LCL_WhiteCollar_Employee IMPLEMENTATION
CLASS lcl_whitecollar_employee IMPLEMENTATION.
METHOD constructor.
* The superclass constructor method must be called from the subclass
* constructor method
CALL METHOD super->constructor.
no = im_no.
name = im_name.
monthly_salary = im_monthly_salary.
monthly_deductions = im_monthly_deductions.
ENDMETHOD.
  METHOD add_employee.
* Calculate wage an call the superclass method add_employee to add
* the employee to the employee list

DATA: l_wage TYPE i.
l_wage = monthly_salary - monthly_deductions.
    CALL METHOD super->add_employee
EXPORTING im_no = no
im_name = name
im_wage = l_wage.
  ENDMETHOD.
ENDCLASS.
*******************************************************
* R E P O R T
*******************************************************

DATA:
* Object references
o_bluecollar_employee1 TYPE REF TO lcl_bluecollar_employee,
o_whitecollar_employee1 TYPE REF TO lcl_whitecollar_employee.
START-OF-SELECTION.
* Create bluecollar employee obeject
CREATE OBJECT o_bluecollar_employee1
EXPORTING im_no = 1
im_name = 'Gylle Karen'
im_hours = 38
im_hourly_payment = 75.
* Add bluecollar employee to employee list
CALL METHOD o_bluecollar_employee1->add_employee
EXPORTING im_no = 1
im_name = 'Gylle Karen'
im_wage = 0.
* Create whitecollar employee obeject
CREATE OBJECT o_whitecollar_employee1
EXPORTING im_no = 2
im_name = 'John Dickens'
im_monthly_salary = 10000
im_monthly_deductions = 2500.
* Add bluecollar employee to employee list
CALL METHOD o_whitecollar_employee1->add_employee
EXPORTING im_no = 1
im_name = 'Karen Johnson'
im_wage = 0.
* Display employee list and number of employees. Note that the result
* will be the same when called from o_whitecollar_employee1 or
* o_bluecolarcollar_employee1, because the methods are defined
* as static (CLASS-METHODS)
  CALL METHOD o_whitecollar_employee1->display_employee_list.
CALL METHOD o_whitecollar_employee1->display_no_of_employees.

The resulting report

List of Employees
1 Karen Johnson 2.850
2 John Dickens 7.500


Total number of employees: 2
3. Interfaces

This example is similiar to th eprevious example, however an interface is implemented with the method add_employee. Note that the interface is only implemented in the superclass ( The INTERFACE stament), but also used in the subclasses.

The interface in the example only contains a method, but an iterface can also contain attrbutes, constants, types and alias names.

The output from example 3 is similiar to the output in example 2.

All changes in the program compared to example 2 are marked with red.

REPORT zbc404_hf_events_3 .
*---------------------------------------------------------------------*
* INTERFACE lif_employee
*---------------------------------------------------------------------*
INTERFACE lif_employee.
METHODS:
add_employee
IMPORTING im_no TYPE i
im_name TYPE string
im_wage TYPE i.
ENDINTERFACE.
*******************************************************
* Super class LCL_CompanyEmployees
*******************************************************
CLASS lcl_company_employees DEFINITION.
PUBLIC SECTION.
INTERFACES lif_employee.
TYPES:
BEGIN OF t_employee,
no TYPE i,
name TYPE string,
wage TYPE i,
END OF t_employee.
    METHODS:
constructor,
* add_employee "Removed
IMPORTING im_no TYPE i
im_name TYPE string
im_wage TYPE i,
      display_employee_list,
display_no_of_employees.

PRIVATE SECTION.
CLASS-DATA: i_employee_list TYPE TABLE OF t_employee,
no_of_employees TYPE i.
ENDCLASS.
*-- CLASS LCL_CompanyEmployees IMPLEMENTATION
CLASS lcl_company_employees IMPLEMENTATION.
METHOD constructor.
no_of_employees = no_of_employees + 1.
ENDMETHOD.
  METHOD lif_employee~add_employee.
* Adds a new employee to the list of employees
DATA: l_employee TYPE t_employee.
l_employee-no = im_no.
l_employee-name = im_name.
l_employee-wage = im_wage.
APPEND l_employee TO i_employee_list.
ENDMETHOD.
  METHOD display_employee_list.
* Displays all employees and there wage
DATA: l_employee TYPE t_employee.
WRITE: / 'List of Employees'.
    LOOP AT i_employee_list INTO l_employee.
WRITE: / l_employee-no, l_employee-name, l_employee-wage.
ENDLOOP.
  ENDMETHOD.
  METHOD display_no_of_employees.
* Displays total number of employees
SKIP 3.
WRITE: / 'Total number of employees:', no_of_employees.
ENDMETHOD.
ENDCLASS.
*******************************************************
* Sub class LCL_BlueCollar_Employee
*******************************************************
CLASS lcl_bluecollar_employee DEFINITION
INHERITING FROM lcl_company_employees.

PUBLIC SECTION.
METHODS:
constructor
IMPORTING im_no TYPE i
im_name TYPE string
im_hours TYPE i
im_hourly_payment TYPE i,
lif_employee~add_employee REDEFINITION..
  PRIVATE SECTION.
DATA:no TYPE i,
name TYPE string,
hours TYPE i,
hourly_payment TYPE i.

ENDCLASS.
*---- CLASS LCL_BlueCollar_Employee IMPLEMENTATION
CLASS lcl_bluecollar_employee IMPLEMENTATION.
METHOD constructor.
* The superclass constructor method must be called from the subclass
* constructor method

CALL METHOD super->constructor.
no = im_no.
name = im_name.
hours = im_hours.
hourly_payment = im_hourly_payment.
  ENDMETHOD.
  METHOD lif_employee~add_employee.
* Calculate wage an call the superclass method add_employee to add
* the employee to the employee list

DATA: l_wage TYPE i.
l_wage = hours * hourly_payment.
    CALL METHOD super->lif_employee~add_employee
EXPORTING im_no = no
im_name = name
im_wage = l_wage.
ENDMETHOD.
ENDCLASS.
*******************************************************
* Sub class LCL_WhiteCollar_Employee
*******************************************************

CLASS lcl_whitecollar_employee DEFINITION
INHERITING FROM lcl_company_employees.

PUBLIC SECTION.
METHODS:
constructor
IMPORTING im_no TYPE i
im_name TYPE string
im_monthly_salary TYPE i
im_monthly_deductions TYPE i,
lif_employee~add_employee REDEFINITION.
  PRIVATE SECTION.
DATA:
no TYPE i,
name TYPE string,
monthly_salary TYPE i,
monthly_deductions TYPE i.
ENDCLASS.
*---- CLASS LCL_WhiteCollar_Employee IMPLEMENTATION
CLASS lcl_whitecollar_employee IMPLEMENTATION.
METHOD constructor.
* The superclass constructor method must be called from the subclass
* constructor method
CALL METHOD super->constructor.
no = im_no.
name = im_name.
monthly_salary = im_monthly_salary.
monthly_deductions = im_monthly_deductions.
ENDMETHOD.
  METHOD lif_employee~add_employee.
* Calculate wage an call the superclass method add_employee to add
* the employee to the employee list

DATA: l_wage TYPE i.
l_wage = monthly_salary - monthly_deductions.
    CALL METHOD super->lif_employee~add_employee
EXPORTING im_no = no
im_name = name
im_wage = l_wage.
  ENDMETHOD.
ENDCLASS.
*******************************************************
* R E P O R T
*******************************************************

DATA:
* Object references
o_bluecollar_employee1 TYPE REF TO lcl_bluecollar_employee,
o_whitecollar_employee1 TYPE REF TO lcl_whitecollar_employee.
START-OF-SELECTION.
* Create bluecollar employee obeject
CREATE OBJECT o_bluecollar_employee1
EXPORTING im_no = 1
im_name = 'Gylle Karen'
im_hours = 38
im_hourly_payment = 75.
* Add bluecollar employee to employee list
CALL METHOD o_bluecollar_employee1->lif_employee~add_employee
EXPORTING im_no = 1
im_name = 'Karen Johnson'
im_wage = 0.
* Create whitecollar employee obeject
CREATE OBJECT o_whitecollar_employee1
EXPORTING im_no = 2
im_name = 'John Dickens'
im_monthly_salary = 10000
im_monthly_deductions = 2500.
* Add bluecollar employee to employee list
CALL METHOD o_whitecollar_employee1->lif_employee~add_employee
EXPORTING im_no = 1
im_name = 'Gylle Karen'
im_wage = 0.
* Display employee list and number of employees. Note that the result
* will be the same when called from o_whitecollar_employee1 or
* o_bluecolarcollar_employee1, because the methods are defined
* as static (CLASS-METHODS)
  CALL METHOD o_whitecollar_employee1->display_employee_list.
CALL METHOD o_whitecollar_employee1->display_no_of_employees.

4. Events

This is the same example as example 4. All changes are marked with red. There have been no canges to the subclasses, only to the superclass and the report, sp the code for th esubclasses is not shown.

For a simple example refer to Events in Examples.

REPORT zbc404_hf_events_4 .
*---------------------------------------------------------------------*
* INTERFACE lif_employee
*---------------------------------------------------------------------*

INTERFACE lif_employee.
  METHODS:
add_employee
IMPORTING im_no TYPE i
im_name TYPE string
im_wage TYPE i.
ENDINTERFACE.
*******************************************************
* Super class LCL_CompanyEmployees
*******************************************************

CLASS lcl_company_employees DEFINITION.
PUBLIC SECTION.
TYPES:
BEGIN OF t_employee,
no TYPE i,
name TYPE string,
wage TYPE i,
END OF t_employee.
*   Declare event. Note that declaration could also be placed in the
* interface

EVENTS: employee_added_to_list
EXPORTING value(ex_employee_name) TYPE string.
* CLASS-EVENTS: Events can also be defined as class-events
    INTERFACES lif_employee.
METHODS:
constructor,
display_employee_list,
display_no_of_employees,
*     Declare event method
on_employee_added_to_list FOR EVENT employee_added_to_list OF lcl_company_employees
IMPORTING ex_employee_name sender.
  PRIVATE SECTION.
CLASS-DATA:
i_employee_list TYPE TABLE OF t_employee,
no_of_employees TYPE i.
ENDCLASS.
*-- CLASS LCL_CompanyEmployees IMPLEMENTATION
CLASS lcl_company_employees IMPLEMENTATION.
METHOD constructor.
no_of_employees = no_of_employees + 1.
ENDMETHOD.
  METHOD lif_employee~add_employee.
* Adds a new employee to the list of employees
DATA: l_employee TYPE t_employee.
l_employee-no = im_no.
l_employee-name = im_name.
l_employee-wage = im_wage.
APPEND l_employee TO i_employee_list.
*   Raise event employee_added_to_list
RAISE EVENT employee_added_to_list
EXPORTING ex_employee_name = l_employee-name.
  ENDMETHOD.
  METHOD display_employee_list.
* Displays all employees and there wage
DATA: l_employee TYPE t_employee.
WRITE: / 'List of Employees'.
    LOOP AT i_employee_list INTO l_employee.
WRITE: / l_employee-no, l_employee-name, l_employee-wage.
ENDLOOP.
  ENDMETHOD.
  METHOD display_no_of_employees.
* Displays total number of employees
SKIP 3.
WRITE: / 'Total number of employees:', no_of_employees.
ENDMETHOD.
  METHOD on_employee_added_to_list.
* Event method
WRITE: / 'Employee added to list', ex_employee_name.
ENDMETHOD.
ENDCLASS. 
*******************************************************
* Sub class LCL_BlueCollar_Employee
*******************************************************
CLASS lcl_bluecollar_employee DEFINITION
INHERITING FROM lcl_company_employees.
See code in example 3...
ENDCLASS.
CLASS lcl_bluecollar_employee IMPLEMENTATION.
See code in example 3...
ENDCLASS.
*******************************************************
* Sub class LCL_WhiteCollar_Employee
*******************************************************
CLASS lcl_whitecollar_employee DEFINITION
See code in example 3...
ENDCLASS.
CLASS lcl_whitecollar_employee IMPLEMENTATION.
See code in example 3...
ENDCLASS.
*******************************************************
* R E P O R T
*******************************************************

DATA:
* Object references
o_bluecollar_employee1 TYPE REF TO lcl_bluecollar_employee,
o_whitecollar_employee1 TYPE REF TO lcl_whitecollar_employee.
START-OF-SELECTION.
* Create bluecollar employee obeject
CREATE OBJECT o_bluecollar_employee1
EXPORTING im_no = 1
im_name = 'Karen Johnson'
im_hours = 38
im_hourly_payment = 75.
* Register event for o_bluecollar_employee1
SET HANDLER o_bluecollar_employee1->on_employee_added_to_list
FOR o_bluecollar_employee1.
* Add bluecollar employee to employee list
CALL METHOD o_bluecollar_employee1->lif_employee~add_employee
EXPORTING im_no = 1
im_name = 'Gylle Karen'
im_wage = 0.
* Create whitecollar employee obeject
CREATE OBJECT o_whitecollar_employee1
EXPORTING im_no = 2
im_name = 'John Dickens'
im_monthly_salary = 10000
im_monthly_deductions = 2500.
* Register event for o_whitecollar_employee1
SET HANDLER o_whitecollar_employee1->on_employee_added_to_list
FOR o_whitecollar_employee1.´

* Add bluecollar employee to employee list
CALL METHOD o_whitecollar_employee1->lif_employee~add_employee
EXPORTING im_no = 1
im_name = 'Gylle Karen'
im_wage = 0.
* Display employee list and number of employees. Note that the result
* will be the same when called from o_whitecollar_employee1 or
* o_bluecolarcollar_employee1, because the methods are defined
* as static (CLASS-METHODS)
CALL METHOD o_whitecollar_employee1->display_employee_list.
CALL METHOD o_whitecollar_employee1->display_no_of_employees.

Result:


Employee added to list Karen Johnson
Employee added to list John Dickens
List of Employees
1 Karen Johnson 2.850
2 John Dickens 7.500

Total number of employees: 2

SAP Finding the user-exits of a SAP transaction code

* Finding the user-exits of a SAP transaction code
*
* Enter the transaction code in which you are looking for the user-exit
* and it will list you the list of user-exits in the transaction code.
* Also a drill down is possible which will help you to branch to SMOD.
report zuserexit no standard page heading.
tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
tables : tstct.
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
parameters : p_tcode like tstc-tcode obligatory.

select single * from tstc where tcode eq p_tcode.
if sy-subrc eq 0.
select single * from tadir where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.
move : tadir-devclass to v_devclass.
if sy-subrc ne 0.
select single * from trdir where name = tstc-pgmna.
if trdir-subc eq 'F'.
select single * from tfdir where pname = tstc-pgmna.
select single * from enlfdir where funcname =
tfdir-funcname.
select single * from tadir where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name eq enlfdir-area.

move : tadir-devclass to v_devclass.
endif.
endif.
select * from tadir into table jtab
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.
select single * from tstct where sprsl eq sy-langu and
tcode eq p_tcode.
format color col_positive intensified off.
write:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
if not jtab[] is initial.
write:/(95) sy-uline.
format color col_heading intensified on.
write:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
write:/(95) sy-uline.
loop at jtab.
select single * from modsapt
where sprsl = sy-langu and
name = jtab-obj_name.
format color col_normal intensified off.
write:/1 sy-vline,
2 jtab-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table jtab.
skip.
format color col_total intensified on.
write:/ 'No of Exits:' , sy-tfill.
else.
format color col_negative intensified on.
write:/(95) 'No User Exit exists'.
endif.
else.
format color col_negative intensified on.
write:/(95) 'Transaction Code Does Not Exist'.
endif.

at line-selection.
get cursor field field1.
check field1(4) eq 'JTAB'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen.

*---End of Program

SAP A comparison between enhancement techniques

Due to the necessity of adjusting R/3 to meet the specific needs of a variety of customers, several different enhancement techniques were developed in the past. A short description of each of the various enhancement techniques follows.

Business Transaction Events (Open FI)
The Open FI enhancement technique was developed in the Financial Accounting component. Open FI is based upon the following principles:

Application developers must define their interface in a function module, an assignment table is read in the accompanying (generated) code, and the customer modules assigned are called dynamically.
This technique differentiates between enhancements that are only allowed to have one implementation and enhancements that can call multiple implementations in any sequence desired. Both industry-specific and country-specific enhancements may be defined.
The concepts behind the Business Add-Ins enhancement technique and Open FI are basically the same. However, the two enhancement techniques do differ from each other in the following points:

  • Open FI can only be used to make program enhancements, that is, you can only enhance source code using Open FI. You cannot enhance user interface elements with Open FI like you can with Business Add-Ins.
  • Open FI assumes that enhancement will only take place on three levels (SAP - partners - customers), whereas with Business Add-Ins you can create and implement enhancements in as many software layers as you like.
  • Open FI uses function modules for program enhancements. With Business Add-Ins, ABAP Objects is used to enhance programs.
Enhancements in Transactions SMOD/CMOD

Making enhancements using the transactions SMOD/CMOD has the following disadvantages:
  1. This enhancement technique assumes a two-tiered system infrastructure (SAP – customers).
  2. The naming conventions in effect do not tolerate name extension.

Conclusion:
None of the techniques mentioned above can easily be extended to fulfill the requirements of a system infrastructure containing country versions, industry solutions, partners, and customers.Business Add-Ins should be considered generalized Business Transaction Events that can be used to bundle program, menu and screen enhancements into a single add-in. Business Add-Ins can be created and employed in each of the various software levels.

SAP Toolbar Control Object

Note: To get a list of all icons, use program SHOWICON.

Add method

Adds a new button to the toolbar
   CALL METHOD go_toolbar->add_button
      EXPORTING fcode       = 'EXIT'     
    "Function Code for button
                icon                       = icon_system_end         
    "ICON name, You can use type pool ICON
                is_disabled          = ' '                                    
     "Disabled = X
                butn_type             = gc_button_normal         
    "Type of button, see below
                text                        = 'Exit'                                
    "Text on button
                quickinfo              = 'Exit program'                 
    "Quick info
                is_checked          = ' '.                                     
    "Button selected

Toolbar button types used in method ADD_BUTTON:

Value

Constant

Meaning

0

cntb_btype_button

Button (normal)

1

cntb_btype_dropdown

Pushbutton with menu

2

cntb_btype_menu

Menu

3

cntb_btype_sep

Seperator

4

cntb_btype_group

Pushbutton group

5

cntb_btype_check

Checkbox

6


Menu entry

Add_button_group method

This method is used to add a list of buttons to the toolbar. The buttons are defined in a table of type TTB_BUTTON, and it can be filled witha button definitions using method fill_buttons_data_table of the cl_gui_toolbar class. The button group is added to the toolbar using method add_button_group of the toolbar object.

* 1. Declare a table for buttons
DATA: gi_button_group            TYPE ttb_button.
* 2.  Create buttons in button table
  CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
  EXPORTING
    fcode            = 'Disable'
*    icon            =
*    DISABLED        =
     butn_type       =  cntb_btype_group
*    TEXT            =
*    QUICKINFO       =
*    CHECKED         =
  changing
    data_table       =  gi_button_group
*  EXCEPTIONS
*    CNTB_BTYPE_ERROR = 1
*    others           = 2
.
CALL METHOD cl_gui_toolbar=>fill_buttons_data_table..... 
   add more buttons to the table
*3.  Add button group to toolbar
  CALL METHOD go_toolbar->add_button_group
    EXPORTING data_table = gi_button_group.

Set_button state method

Used to change the state of individual buttons at runtime. If the button should be removed, use the delete_button method.

CALL METHOD go_toolbar->set_button_state
  EXPORTING
*    ENABLED          = 'X'
*     CHECKED         = ' '
     fcode                 =                      
 "Note: This is the function code 
 " of the button that should be changed
*  EXCEPTIONS
*    CNTL_ERROR       = 1
*    CNTB_ERROR_FCODE = 2
*    others           = 3
        .

Simple example

This example shows how to create a toolbar with a single Exit button, used to exit the program.

Steps:

  • Create a screen and add a custom container named TOOLBAR_CONTAINER

Code:

   REPORT sapmz_hf_toolbar .

   TYPE-POOLS: icon.

   CLASS cls_event_handler DEFINITION DEFERRED.


   * G L O B A L   D A T A
   DATA:
     ok_code                    LIKE sy-ucomm,
   * Reference for container
     go_toolbar_container
  TYPE REF TO cl_gui_custom_container,
   * Reference for SAP Toolbar
     go_toolbar                 
 TYPE REF TO cl_gui_toolbar,
   * Event handler
     go_event_handler    
 TYPE REF TO cls_event_handler.
   * G L O B A L   T A B L E S
   DATA:
   * Table for registration of events. Note that a TYPE REF
   * to cls_event_handler must be created before you can
   * reference types cntl_simple_events and cntl_simple_event.
     gi_events                  TYPE cntl_simple_events,
   * Workspace for table gi_events
     g_event                    TYPE cntl_simple_event.


   *--------------------------------------------------------
   *       CLASS cls_event_handler DEFINITION
   *--------------------------------------------------------
   *       .....
   *--------------------------------------------------------
   CLASS cls_event_handler DEFINITION.
     PUBLIC SECTION.
       METHODS:
         on_function_selected
           FOR EVENT function_selected OF cl_gui_toolbar
             IMPORTING fcode,
         on_dropdown_clicked
           FOR EVENT dropdown_clicked OF cl_gui_toolbar
             IMPORTING fcode posx posy.

   ENDCLASS.

   *--------------------------------------------------------
   *       CLASS cls_event_handler IMPLEMENTATION
   *--------------------------------------------------------
   
   CLASS cls_event_handler IMPLEMENTATION.
     METHOD on_function_selected.
       CASE fcode.
         WHEN 'EXIT'.
           LEAVE TO SCREEN 0.
       ENDCASE.
     ENDMETHOD.

     METHOD on_dropdown_clicked.
*      Not implented yet
     ENDMETHOD.
   ENDCLASS.


   START-OF-SELECTION.
     SET SCREEN '100'.

   *&--------------------------------------------------------
   *&      Module  STATUS_0100  OUTPUT
   *&--------------------------------------------------------
   *       text
   *---------------------------------------------------------
   MODULE status_0100 OUTPUT.

     IF go_toolbar_container IS INITIAL.
   * Create container
       CREATE OBJECT go_toolbar_container
         EXPORTING
           container_name = 'TOOLBAR_CONTAINER'.

   * Create toolbar
       CREATE OBJECT go_toolbar
         EXPORTING
           parent = go_toolbar_container.

   * Add a button
       CALL METHOD go_toolbar->add_button
         EXPORTING fcode       = 'EXIT'      "Function Code
                   icon        = icon_system_end "ICON name
                   is_disabled = ' '        "Disabled = X
                   butn_type   = cntb_btype_button"Type of button
                   text        = 'Exit'   "Text on button
                   quickinfo   = 'Exit program'  "Quick info
                   is_checked  = ' '."Button selected

   * Create event table. The event ID must be found in the
   * documentation of the specific control
       CLEAR g_event.
       REFRESH gi_events.
       g_event-eventid    = go_toolbar->m_id_function_selected.
       g_event-appl_event = 'X'.    "This is an application event
       APPEND g_event TO gi_events.

       g_event-eventid    = go_toolbar->m_id_dropdown_clicked.
       g_event-appl_event = 'X'.
       APPEND g_event TO gi_events.

   *   Use the events table to register events for the control
       CALL METHOD go_toolbar->set_registered_events
           EXPORTING
              events = gi_events.


   *  Create event handlers
       CREATE OBJECT go_event_handler.

       SET HANDLER go_event_handler->on_function_selected
         FOR go_toolbar.

       SET HANDLER go_event_handler->on_dropdown_clicked
          FOR go_toolbar.

     ENDIF.
   ENDMODULE.                 " STATUS_0100  OUTPUT
  

Advanced example

The toolbar in this example contains an Exit button, two buttons that enables/and disables a Print button, and a Menu button with a context menu.

The Disable/Enable buttons are of type Pushbutton group which makes them act together, so when one of the buttons are selected (Down) the other is deselected (Up).

Note that the context menu for the Menu button, must be created as a GUI status. You can create an empty GUI status of type context, and then manually add menus. The context menu instance is created with type reference to class cl_ctmenu.

Steps:

  • Create a screen and add a custom container named TOOLBAR_CONTAINER
  • Create a GUI status of type Context and name it TOOLBAR. Note that you can not add any buttons to the GUI sttaus at design time.

The screen:

In this screen shot the Disable button is activated which makes the Print button disabled:

This screenshot shows the context menu and sub menu:

The code:

   REPORT sapmz_hf_toolbar .
   TYPE-POOLS: icon.
   CLASS cls_event_handler DEFINITION DEFERRED. 
   *--- G L O B A L   D A T A
   DATA:
     ok_code                    LIKE sy-ucomm,
   * Global varables for position of context menu
     g_posx                     TYPE i,
     g_posy                     TYPE i,
   * Reference for conatainer
     go_toolbar_container       
   TYPE REF TO cl_gui_custom_container,
   * Reference for SAP Toolbar
     go_toolbar                 
 TYPE REF TO cl_gui_toolbar,
   * Event handler
     go_event_handler           
 TYPE REF TO cls_event_handler,
   * Context menu
     go_context_menu            
 TYPE REF TO cl_ctmenu.

   *--- G L O B A L   T A B L E S
   DATA:
   * Table for registration of events. Note that a TYPE REF
   * to cls_event_handler must be created before you can
   * reference types cntl_simple_events and cntl_simple_event
     gi_events                  
 TYPE cntl_simple_events,
   * Workspace for table gi_events
     g_event                   
 TYPE cntl_simple_event,
   * Table for button group
     gi_button_group            
 TYPE ttb_button.
   *--------------------------------------------------------
   *       CLASS   CLS_EVENT_HANDLER
   *--------------------------------------------------------
   * This class handles the function_selected 
   * and dropdow_clicked events
   * from the toolbar
   *--------------------------------------------------------
   CLASS cls_event_handler DEFINITION.
     PUBLIC SECTION.
       METHODS:
         on_function_selected
           FOR EVENT function_selected OF cl_gui_toolbar
             IMPORTING fcode,
         on_dropdown_clicked
           FOR EVENT dropdown_clicked OF cl_gui_toolbar
             IMPORTING fcode posx posy.  
   ENDCLASS.
   CLASS cls_event_handler IMPLEMENTATION.
     METHOD on_function_selected.
   *-- Actions for buttons and context menus
       CASE fcode.
         WHEN 'EXIT'.
           LEAVE TO SCREEN 0.
         WHEN 'ENABLE'.
   *     Enable the PRINT button
           CALL METHOD go_toolbar->set_button_state
             EXPORTING
               enabled = 'X'
               fcode   = 'PRINT'.
         WHEN 'DISABLE'.
   *     Disable the PRINT button
           CALL METHOD go_toolbar->set_button_state
             EXPORTING
               enabled = ' '
               fcode   = 'PRINT'.
   *     Other menus and context menus
         WHEN 'PRINT'.
           CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
                EXPORTING
                     textline1 = 'Printing'.
         WHEN 'CONTEXT1'.
           CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
                EXPORTING
                     textline1 = 'Menu: Do something funny'.
         WHEN 'CONTEXT2'.
           CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
                EXPORTING
                     textline1 = 'Menu: Do something crazy'.
         WHEN 'SUB1'.
           CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
                EXPORTING
                     textline1 = 'Submenu: Do something boring'.
         WHEN 'SUB2'.
           CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
                EXPORTING
                     textline1 = 'Submenu: Do something good'.
       ENDCASE.
     ENDMETHOD.  
     METHOD on_dropdown_clicked.
   *-- Fires when a dropdown menu is clicked. After it has been
   *-- clicked a context menu is shown beside the button.
   *   Save x and y position of button for use with context menu
       CLEAR: g_posx, g_posy.
       g_posx = posx.
       g_posy = posy.
   * Create context menu for menu button
       PERFORM create_context_menu.  
     ENDMETHOD.
   ENDCLASS.
   START-OF-SELECTION.
     SET SCREEN '100'.
   *&--------------------------------------------------------
   *&      Module  STATUS_0100  OUTPUT
   *&--------------------------------------------------------
   MODULE status_0100 OUTPUT.  
     IF go_toolbar_container IS INITIAL.
   * Create container
       CREATE OBJECT go_toolbar_container
         EXPORTING
           container_name = 'TOOLBAR_CONTAINER'.
   * Create toolbar
       CREATE OBJECT go_toolbar
         EXPORTING
           parent = go_toolbar_container.  
   * Add a button to the toolbar
       PERFORM add_button.
   * Add a button group to the toolbar
       PERFORM add_button_group.
   * Create event table. Note that the event ID 
   * must be found in the
   * documentation of the specific control
       CLEAR g_event. REFRESH gi_events.
       g_event-eventid    = go_toolbar->m_id_function_selected.
       g_event-appl_event = 'X'.    "This is an application event
       APPEND g_event TO gi_events.  
       CLEAR g_event.
       g_event-eventid    = go_toolbar->m_id_dropdown_clicked.
       g_event-appl_event = 'X'.
       APPEND g_event TO gi_events.
   *   Use the events table to register events for the control
       CALL METHOD go_toolbar->set_registered_events
           EXPORTING
              events = gi_events. 
   *  Create event handlers
       CREATE OBJECT go_event_handler.
       SET HANDLER go_event_handler->on_function_selected
         FOR go_toolbar.  
       SET HANDLER go_event_handler->on_dropdown_clicked
          FOR go_toolbar.
     ENDIF.
   ENDMODULE.                 " STATUS_0100  OUTPUT
   *&--------------------------------------------------------
   *&      Form  add_button
   *&--------------------------------------------------------
   *  Adds one pushbutton to the toolbar
   *---------------------------------------------------------
   FORM add_button.
     CALL METHOD go_toolbar->add_button
       EXPORTING fcode       = 'EXIT'            "Function Code
                 icon        = icon_system_end   "ICON name
                 is_disabled = ' '               "Disabled = X
                 butn_type   = cntb_btype_button "Type of button
                 text        = 'Exit'            "Text on button
                 quickinfo   = 'Exit program'    "Quick info
                 is_checked  = ' '.              "Button selected 
   ENDFORM.                    " add_button
   *&--------------------------------------------------------
   *&      Form  add_button_group
   *&--------------------------------------------------------
   * Adds a button group to the toolbar.
   * The buttons are added to table gi_button_group, 
   * and the table is used
   * as input to the Add_button_group method. 
   * Note that method Fill_buttons
   * is used to fill the table.
   *---------------------------------------------------------
   FORM add_button_group.
   * Add a seperator
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode            = 'SEP1'
         icon             = ' '
         butn_type        = cntb_btype_sep
       CHANGING
         data_table       = gi_button_group     .
   * Add an Enable button
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode            = 'ENABLE'
         icon             = ' '
         butn_type        =  cntb_btype_group
         text             = 'Enable'
         quickinfo        = 'Enable a print button'
        checked            = 'X'
       CHANGING
         data_table       = gi_button_group.
   * Add a Disable button
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode            = 'DISABLE'
         icon             = ''
         butn_type        = cntb_btype_group
         text             = 'Disable'
         quickinfo        = 'Disable print button'
         checked          = ' '
       CHANGING
         data_table       = gi_button_group.
   * Add a seperator
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode            = 'SEP2'
         icon             = ' '
         butn_type        = cntb_btype_sep
       CHANGING
         data_table       = gi_button_group.  
   * Add print button
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'PRINT'
         icon               = icon_print
         butn_type          = cntb_btype_button
         text               = 'Print'
         quickinfo          = 'Print something'
       CHANGING
         data_table         = gi_button_group.
   * Add a menu button
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'MENU'
         icon               = ' '
         butn_type          = cntb_btype_menu
         text               = 'Menu'
         quickinfo          = 'A menu buttonz'
       CHANGING
         data_table         = gi_button_group. 
   * Add button group to toolbar
     CALL METHOD go_toolbar->add_button_group
       EXPORTING data_table = gi_button_group.
   ENDFORM.                    " add_button_group
   *&--------------------------------------------------------
   *&      Form  create_context_menu
   *&--------------------------------------------------------
   * This form creates a context menu and 
   * a submenu for the menu button.
   *---------------------------------------------------------
   FORM create_context_menu.
     DATA: lo_submenu TYPE REF TO cl_ctmenu.
     IF go_context_menu IS INITIAL.
    *-- Create context menu
       CREATE OBJECT go_context_menu. 
       CALL METHOD go_context_menu->add_function
            EXPORTING
                fcode = 'CONTEXT1'
                text  = 'Do something funny'.
       CALL METHOD go_context_menu->add_function
            EXPORTING
                fcode = 'CONTEXT2'
                text  = 'Do something crazy'.
       CALL METHOD go_context_menu->add_separator.  
   *   Create sub menu for the context menu
       CREATE OBJECT lo_submenu.
       CALL METHOD lo_submenu->add_function
              EXPORTING
                  fcode = 'SUB1'
                  text  = 'Do something boring'.
       CALL METHOD lo_submenu->add_function
              EXPORTING
                  fcode = 'SUB2'
                  text  = 'Do something good'.  
   *-- Add sub menu to the context menu
       CALL METHOD go_context_menu->add_submenu
          EXPORTING
              menu = lo_submenu
              text  = 'Do something else.....'.
     ENDIF. 
   * Link menu to toolbar button. 
   * To position the context menu the
   * x and y positions of the menu button is used.
   * These values was retrieved in the On_dropdown_clicked
   * method of cls_event_handler
     CALL METHOD go_toolbar->track_context_menu
           EXPORTING
               context_menu = go_context_menu
               posx         = g_posx
               posy         = g_posy.  
   ENDFORM.                    " create_context_menu

SAP HTML Viewer Control

Note that the SAP HTML viewer uses internet Explorer 4.0 or higher.

This example uses the SAP HTML viewer to browse the internet. The navigation buttons are placed on a SAP Toolbar control. The Goto URL button and field are normal dynpro elements, and so is the Show URL field.

Steps:

  • Create a screen and place a container named go_html_container for the HTML viewer.
  • Create a dynpro button with ethe text GGoto url and functioncode GOTOURL.
  • Create a dynpro input/output field named G_SCREEN100_URL_TEXT. This field is used to key in the URLl.
  • Create a dynpro input/output field named G_SCREEN100_DISPLAY_URL. This field is used to show the current URL

The screen:

The code

SAPMZ_HF_HTML_CONTROL

   REPORT sapmz_hf_html_control .
   TYPE-POOLS: icon.
   CLASS cls_event_handler DEFINITION DEFERRED.
   *--------------------------------------
   * G L O B A L  V A R I A B L E S
   *--------------------------------------
   DATA:
     ok_code                 LIKE sy-ucomm,
   * Container for html vieaer
     go_html_container       TYPE REF TO cl_gui_custom_container,
   * HTML viewer
     go_htmlviewer           TYPE REF TO cl_gui_html_viewer,
   * Container for toolbar
     go_toolbar_container    TYPE REF TO cl_gui_custom_container,
   * SAP Toolbar
     go_toolbar              TYPE REF TO cl_gui_toolbar,
   * Event handler for toolbar
     go_event_handler        TYPE REF TO cls_event_handler,
   * Variable for URL text field on screen 100
     g_screen100_url_text(255) TYPE c,
     g_screen100_display_url(255) TYPE c.  
   *--------------------------------------
   * I N T E R N A L   T A B L E S
   *--------------------------------------
   DATA:
   * Table for button group
     gi_button_group            TYPE ttb_button,
   * Table for registration of events. Note that a TYPE REF
   * to cls_event_handler must be created before you can
   * reference types cntl_simple_events and cntl_simple_event.
     gi_events                  TYPE cntl_simple_events,
   * Workspace for table gi_events
     g_event                    TYPE cntl_simple_event.

   START-OF-SELECTION.
     SET SCREEN '100'.
   *-------------------------------------------
   *       CLASS cls_event_handler DEFINITION
   *-------------------------------------------
   * Handles events for the toolbar an the HTML viewer
   *------------------------------------------
   CLASS cls_event_handler DEFINITION.
     PUBLIC SECTION.
       METHODS:
   * Handles method function_selected  for the toolbar control
         on_function_selected
           FOR EVENT function_selected OF cl_gui_toolbar
             IMPORTING fcode,
   * Handles method navigate_complete for the HTML viewer control
         on_navigate_complete
           FOR EVENT navigate_complete OF cl_gui_html_viewer
             IMPORTING url.
   ENDCLASS.
   CLASS cls_event_handler IMPLEMENTATION.
   * Handles method function_selected  for the toolbar control
     METHOD on_function_selected.
       CASE fcode.
         WHEN 'BACK'.
           CALL METHOD go_htmlviewer->go_back
             EXCEPTIONS cntl_error = 1.
         WHEN 'FORWARD'.
           CALL METHOD go_htmlviewer->go_forward
             EXCEPTIONS cntl_error = 1.
         WHEN 'STOP'.
           CALL METHOD go_htmlviewer->stop
             EXCEPTIONS cntl_error = 1.
         WHEN 'REFRESH'.
           CALL METHOD go_htmlviewer->do_refresh
             EXCEPTIONS cntl_error = 1.
         WHEN 'HOME'.
           CALL METHOD go_htmlviewer->go_home
             EXCEPTIONS cntl_error = 1.
         WHEN 'EXIT'.
           LEAVE TO SCREEN 0.
       ENDCASE.
     ENDMETHOD.
   * Handles method navigate_complete for the HTML viewer control
     METHOD on_navigate_complete.
   *   Display current URL in a textfield on the screen
       g_screen100_display_url = url.
     ENDMETHOD.
   ENDCLASS. 
   *&-----------------------------------------------
   *&      Module  STATUS_0100  OUTPUT
   *&-----------------------------------------------
   MODULE status_0100 OUTPUT.
     IF go_html_container IS INITIAL.
   * Create container for HTML viewer
       CREATE OBJECT go_html_container
         EXPORTING
           container_name = 'HTML_CONTAINER'.
   * Create HTML viewer
       CREATE OBJECT go_htmlviewer
         EXPORTING parent = go_html_container.
   * Create container for toolbar
       CREATE OBJECT go_toolbar_container
         EXPORTING
              container_name = 'TOOLBAR_CONTAINER'.
   * Create toolbar
       CREATE OBJECT go_toolbar
         EXPORTING
           parent = go_toolbar_container.
   * Add buttons to the toolbar
       PERFORM add_button_group.
   * Create event table. The event ID must be found in the
   * documentation of the specific control
       CLEAR g_event.
       REFRESH gi_events.
       g_event-eventid    = go_toolbar->m_id_function_selected.
       g_event-appl_event = 'X'.    "This is an application event
       APPEND g_event TO gi_events.
       g_event-eventid    = go_htmlviewer->m_id_navigate_complete.
       APPEND g_event TO gi_events.
   * Use the events table to register events for the control
       CALL METHOD go_toolbar->set_registered_events
           EXPORTING
              events = gi_events.
       CALL METHOD go_htmlviewer->set_registered_events
           EXPORTING
              events = gi_events.
   * Create event handlers
       CREATE OBJECT go_event_handler.
       SET HANDLER go_event_handler->on_function_selected
         FOR go_toolbar.
       SET HANDLER go_event_handler->on_navigate_complete
         FOR go_htmlviewer.
     ENDIF.
   ENDMODULE.                 " STATUS_0100  OUTPUT
   *&----------------------------------------
   *&      Module  USER_COMMAND_0100  INPUT
   *&----------------------------------------
   MODULE user_command_0100 INPUT.
   * Handles the pushbutton for goto url
     CASE ok_code.
       WHEN 'GOTOURL'.
         PERFORM goto_url.
     ENDCASE.
   ENDMODULE.                 " USER_COMMAND_0100  INPUT
   *&-------------------------------------
   *&      Form  add_button_group
   *&-------------------------------------
   *  Adds a button group to the toolbar   
   *--------------------------------------
   FORM add_button_group.
   * BACK botton
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'BACK'
         icon               = icon_arrow_left
         butn_type          = cntb_btype_button
         text               = ''
         quickinfo          = 'Go back'
       CHANGING
         data_table         = gi_button_group.
   * FORWARD botton
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'FORWARD'
         icon               = icon_arrow_right
         butn_type          = cntb_btype_button
         text               = ''
         quickinfo          = 'Go forward'
       CHANGING
         data_table         = gi_button_group.
   * STOP button
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'STOP'
         icon               = icon_breakpoint
         butn_type          = cntb_btype_button
         text               = ''
         quickinfo          = 'Stop'
       CHANGING
         data_table         = gi_button_group.
   * REFRESH button
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'REFRESH'
         icon               = icon_refresh
         butn_type          = cntb_btype_button
         text               = ''
         quickinfo          = 'Refresh'
       CHANGING
         data_table         = gi_button_group.
   * Home button
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'HOME'
         icon               = ''
         butn_type          = cntb_btype_button
         text               = 'Home'
         quickinfo          = 'Home'
       CHANGING
         data_table         = gi_button_group.
   * Separator
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'SEP1'
         icon               = ' '
         butn_type          = cntb_btype_sep
       CHANGING
         data_table         = gi_button_group.
   * EXIT button
     CALL METHOD cl_gui_toolbar=>fill_buttons_data_table
       EXPORTING
         fcode              = 'EXIT'
         icon               =  icon_close
         butn_type          =  cntb_btype_button
         text               = ''
         quickinfo          = 'Close porgram'
       CHANGING
         data_table         = gi_button_group.
   * Add button group to toolbar
     CALL METHOD go_toolbar->add_button_group
       EXPORTING data_table = gi_button_group.
   ENDFORM.                    " add_button_group
   *&------------------------------------------------
   *&      Form  goto_url
   *&------------------------------------------------
   *  Calls method SHOW_URL to navigate to an URL
   *--------------------------------------------------
   FORM goto_url.
     CALL METHOD go_htmlviewer->show_url
          EXPORTING url = g_screen100_url_text.
   ENDFORM.                    " goto_url

Archives