Below codes is a simply and rough example could be used as a reference if you have a long time or never touch ABAP OO but would like to use it right now in you project.
REPORT YT_OO_T01.
*Interface
INTERFACE lif_test.
DATA: v_info TYPE c LENGTH 10.
METHODS: display_info.
ENDINTERFACE.
*Define Class
CLASS lcl_test DEFINITION.
PUBLIC SECTION.
EVENTS:
v_event EXPORTING VALUE(ex_info) TYPE string.
METHODS:
constructor,
set_info IMPORTING p_info TYPE c,
display_info.
CLASS-DATA:
v_static_value TYPE c LENGTH 10.
CLASS-METHODS:
display_static_info.
INTERFACES:
lif_test.
PROTECTED SECTION.
METHODS:
protected_method.
PRIVATE SECTION.
DATA: v_info TYPE c LENGTH 10.
ENDCLASS. "LCL_TEST DEFINITION
*Implementation
CLASS lcl_test IMPLEMENTATION.
METHOD constructor.
v_info = 'initial'.
ENDMETHOD. "constructor
METHOD set_info.
v_info = p_info.
ENDMETHOD. "set_info
METHOD display_info.
WRITE:/ v_info.
RAISE EVENT v_event EXPORTING ex_info = 'call event handler'.
ENDMETHOD. "display_info
METHOD display_static_info.
v_static_value = 'initial'.
WRITE:/ v_static_value.
ENDMETHOD. "display_static_info
METHOD protected_method.
WRITE:/ 'call protected method'.
ENDMETHOD. "protected_method
METHOD lif_test~display_info.
lif_test~v_info = 'Interface'.
WRITE:/ 'v_info = ', v_info,
',lif_test~v_info = ', lif_test~v_info.
ENDMETHOD.
ENDCLASS. "LCL_TEST IMPLEMENTATION
*Inheriting
CLASS lcl_test_sub DEFINITION INHERITING FROM lcl_test.
PUBLIC SECTION.
METHODS: display_sub.
*When we redefine a method, we can't change its visibility (PUBLIC, PROTECTED)
PROTECTED SECTION.
METHODS: protected_method REDEFINITION.
ENDCLASS.
CLASS lcl_test_sub IMPLEMENTATION.
METHOD display_sub.
set_info( 'hello sub' ).
display_info( ).
protected_method( ).
ENDMETHOD.
METHOD protected_method.
super->protected_method( ).
WRITE:/ 'Call protected method in sub class'.
ENDMETHOD.
ENDCLASS.
*Event Handler
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
on_event FOR EVENT v_event OF lcl_test
IMPORTING ex_info sender.
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_event.
write:/ ex_info.
ENDMETHOD.
ENDCLASS.
*Using
START-OF-SELECTION.
lcl_test=>display_static_info( ).
DATA obj_test TYPE REF TO lcl_test.
CREATE OBJECT obj_test.
SET HANDLER lcl_event_handler=>on_event FOR obj_test.
obj_test->set_info( 'hello' ).
obj_test->display_info( ).
obj_test->lif_test~display_info( ).
SKIP 2.
WRITE:/ 'Sub Class'.
DATA obj_test_sub TYPE REF TO lcl_test_sub.
CREATE OBJECT obj_test_sub.
obj_test_sub->display_sub( ).
分享到:
相关推荐
这里是go语言学习笔记4中关于接口的练习,读者可以参考着,自己体会体会。
"JAVA实现DAO层和业务逻辑的impl实现层" 在JAVA中,实现DAO层和业务逻辑是非常重要的部分。impl实现层是指在业务逻辑层和持久层之间的桥梁,负责将业务逻辑转换为数据库操作。下面我们将详细介绍impl实现层的实现...
开发工具 taglibs-standard-impl-1.2.5开发工具 taglibs-standard-impl-1.2.5开发工具 taglibs-standard-impl-1.2.5开发工具 taglibs-standard-impl-1.2.5开发工具 taglibs-standard-impl-1.2.5开发工具 taglibs-...
jaxb-impl-2.1.13.jar
标题“win_impl.rar_event_sunwindow”暗示我们正在讨论与Windows实现相关的特定库,特别是与太阳窗口(SunWindow)事件管理有关的私有数据结构。在Windows操作系统中,事件管理是图形用户界面(GUI)编程的核心部分...
interface A{ int x=0; } class B{ int x=1; } public class C extends B implements A{ public void pX(){ System.out.println(super.x); } public static void main(String[] args){ new C().pX(); }
标题中的"jstl-impl-1.2.jar.rar"是一个压缩文件,它包含了"jstl-impl-1.2.jar"这个JAR包,这通常与Java Web开发相关,特别是与JSP(JavaServer Pages)技术紧密相连。JSTL(JavaServer Pages Standard Tag Library...
jaxb-impl-2.1.jar
jstl-api-1.2、jstl-impl-1.2.jar标签包,两份。
通过查看make过程中的错误知道,问题出在OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp文件中, 参考 https://code.ros.org/trac/opencv/ticket/1020 中 ffmpeg_build.patch 和 ffmpeg_build_2.patch 对 ...
**jaxb-impl.jar包详解** `jaxb-impl.jar`是Java Architecture for XML Binding (JAXB)的一个实现包,它是Java平台标准版(Java SE)和企业版(Java EE)的一部分,主要用于XML到Java对象的绑定以及反之,使得...
赠送jar包:avalon-framework-impl-4.3.1.jar; 赠送原API文档:avalon-framework-impl-4.3.1-javadoc.jar; 赠送源代码:avalon-framework-impl-4.3.1-sources.jar; 赠送Maven依赖信息文件:avalon-framework-impl...
jstl-impl-1.2.2.jar!
jaxb-impl-2.0.3.jar 可用包
impl, impl生成用于实现接口的方法存根 impl 生成用于实现接口的方法存根。go get -u github.com/josharian/impl示例用法:$ impl 'f *File' io.ReadWriteCloserfunc (f *File
赠送jar包:jjwt-impl-0.11.2.jar; 赠送原API文档:jjwt-impl-0.11.2-javadoc.jar; 赠送源代码:jjwt-impl-0.11.2-sources.jar; 赠送Maven依赖信息文件:jjwt-impl-0.11.2.pom; 包含翻译后的API文档:jjwt-impl-...
有关Maven项目中缺少jaxb-api的异常报错解决,jaxb-impl-2.3.0.jar
赠送jar包:log4j-slf4j-impl-2.12.1.jar; 赠送原API文档:log4j-slf4j-impl-2.12.1-javadoc.jar; 赠送源代码:log4j-slf4j-impl-2.12.1-sources.jar; 赠送Maven依赖信息文件:log4j-slf4j-impl-2.12.1.pom; ...
jsf-impl-1.2_12 源码 jar
OpenH264与h264_impl是WebRTC(Web Real-Time Communication)在iOS平台上实现H264编解码的关键组件。OpenH264是一个开源的H264编码库,由思科系统(Cisco Systems)开发并维护,它提供了高效的视频编码功能,广泛...