Skip to Content
0
Oct 23, 2013 at 11:29 AM

How to declare a local exception class-it doesnt work

2381 Views

Hello guys:)

I have been working in Eclipse and trying to create a class with a local exception object.

But the code doesnt see the local exception object and gives an error

Here it is

Define the class in Local Types section:

class lcx_operation_not_allowed DEFINITION

INHERITING FROM cx_static_check.

ENDCLASS.

And the Main class as below

CLASS ZCL_SERIALIZER DEFINITION

PUBLIC

FINAL

CREATE PRIVATE .

PUBLIC SECTION.

CLASS-METHODS: GET_INSTANCE RETURNING VALUE(RO_SERIALIZER) TYPE REF TO ZCL_SERIALIZER.

CLASS-METHODS: CLASS_CONSTRUCTOR.

METHODS: CONSTRUCTOR RAISING lcx_operation_not_allowed.

PROTECTED SECTION.

PRIVATE SECTION.

CLASS-DATA: LO_SELF TYPE REF TO ZCL_SERIALIZER.

ENDCLASS.

CLASS ZCL_SERIALIZER IMPLEMENTATION.

METHOD CLASS_CONSTRUCTOR.

CREATE OBJECT LO_SELF.

ENDMETHOD.

METHOD CONSTRUCTOR.

RAISE EXCEPTION TYPE lcx_operation_not_allowed.

ENDMETHOD.

METHOD GET_INSTANCE.

RO_SERIALIZER = LO_SELF.

ENDMETHOD.

ENDCLASS.

Error I am getting is lcx_operation_not_allowed is unknown type.