‎2014 Dec 19 12:19 PM
Dear Experts,
which syntax is the correct one. According to Abap OOP Tutorials is Example 1 the common kind of syntax, isn' it?
Because I am getting this error massage with example1: PUBLIC addition of the CLASS statement is missing
-----------------------------------------------------------------------------------------------
Example 1
CLASS ZCL_EMPLOYEE definition.
* compare this section with below example 2
public section.
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.
protected section.
CLASS-DATA: g_no_of_employees TYPE i.
private section.
DATA: g_employee TYPE t_employee.
ENDCLASS.
-----------------------------------------------------------------------------------------------
This works well with the part after DEFINITION.
Example 2
CLASS ZCL_EMPLOYEE definition
public
final
create public .
public section.
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.
protected section.
CLASS-DATA: g_no_of_employees TYPE i.
private section.
DATA: g_employee TYPE t_employee.
ENDCLASS.
-----------------------------------------------------------------------------------------------
Best Regards
Hakan
‎2014 Dec 19 2:42 PM
The difference is that example 1 is local class and example 2 is global class.
I guess you are getting error because you are writing example 1 in either SE24 (code view) or in ADT, right?
F1 on CLASS .. DEFINITION PUBLIC.. :
The PUBLIC addition specifies that the class class is a global class in the Class Library. You can only apply the PUBLIC addition to one class in a class pool. This addition is generated by the Class Builder when a global class is created. Any class that does not have the PUBLIC addition applied to it is a local class in its program.
‎2014 Dec 19 2:42 PM
The difference is that example 1 is local class and example 2 is global class.
I guess you are getting error because you are writing example 1 in either SE24 (code view) or in ADT, right?
F1 on CLASS .. DEFINITION PUBLIC.. :
The PUBLIC addition specifies that the class class is a global class in the Class Library. You can only apply the PUBLIC addition to one class in a class pool. This addition is generated by the Class Builder when a global class is created. Any class that does not have the PUBLIC addition applied to it is a local class in its program.
‎2014 Dec 19 3:59 PM