Question : ABAP syntax error:statement is not accessible

In the attached code I get the "statement is not accessible" syntax error @ the
line CREATE OBJECT. Can someone help?

thanks in advance.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
*&---------------------------------------------------------------------*
*& Report  ZCHTYPOBJ                                                   *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  zchtypobj.

DATA customer_count TYPE i.
DATA tyre_price TYPE f.
DATA var1 TYPE i VALUE 786.
var1 = 890.
MOVE 900 TO var1.
WRITE 'ABAP/4 is easy.'.
WRITE / var1.

*& try text field literal vs string literal

DATA: str1(10) TYPE c VALUE 'abc',
      str2(10) TYPE c VALUE 'abc   '.

IF str1 = str2.
  WRITE / 'str1 and str2 are same'.
ELSE.
  WRITE / 'str1 and str2 are not same'.
ENDIF.

DATA: str3 TYPE string VALUE `abc`,
      str4 TYPE string VALUE `abc   `.

IF str3 = str4.
  WRITE / 'str3 and str4 are same'.
ELSE.
  WRITE / 'str3 and str4 are not same'.
ENDIF.

*CONSTANTS

CONSTANTS: c_nump TYPE p DECIMALS 3 VALUE '123.657',
c_city TYPE c LENGTH 10 VALUE 'manchester'.
*c_nump = 23. causes syntax error

*text symbols
WRITE / 'testign text symbols'.
WRITE: / text-001, / text-002, / text-0a0.
*****why is this not working??????
*write  'can i store during run time' (002).

DO 5 TIMES.
  PERFORM dataobject_example.
  WRITE: / 'sy-index: ', sy-index.
ENDDO.

*&--------------------------------------------------------------------*
*&      Form  dataobject_example
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM dataobject_example.
  DATA ct1 TYPE i.
  STATICS ct2 TYPE i.
  ct1 = ct1 + 1.
  ct2 = ct2 + 1.
  WRITE: / 'ct1: ', ct1, 'ct2: ', ct2.
ENDFORM.                    "dataobject_example
*---------------------------------------------------------------------*
*       CLASS C1 DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS c1 DEFINITION.
  PUBLIC SECTION.
    CLASS-DATA create_count TYPE i.
    METHODS constructor.
ENDCLASS.                    "C1 DEFINITION

DATA: o1 TYPE REF TO c1,
      o2 LIKE o1,
      o3 LIKE o1.

CREATE OBJECT: o1,
               o2,
               o3.

WRITE: 'Number of created objects:', c1=>create_count.

*---------------------------------------------------------------------*
*       CLASS C1 IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS c1 IMPLEMENTATION.
  METHOD constructor.
    create_count = create_count + 1.
  ENDMETHOD.                    "CONSTRUCTOR
ENDCLASS.                    "C1 IMPLEMENTATION

Answer : ABAP syntax error:statement is not accessible

'Form ... EndForm' are always written after all immediate execution and can be called using 'perform'.
Random Solutions  
 
programming4us programming4us