`
touchinsert
  • 浏览: 1370056 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

ABAP-使用cl_oo_class获取类信息

OO 
阅读更多

REPORT zfsl_show_desktop.

TABLES : seoclass.
DATA : zcl_oo_class TYPE REF TO cl_oo_class.


DATA : lt_attributes TYPE seo_attributes,
ls_attributes TYPE vseoattrib,
lt_methods TYPE seo_methods,
ls_methods TYPE vseomethod,
ls_signature TYPE seocmpsign,
lt_params TYPE seo_parameters,
ls_params TYPE vseoparam,
lt_exceps TYPE seo_exceptions,
ls_exceps TYPE vseoexcep.

DATA : ls_seotype TYPE seotype,
lt_subclass TYPE seo_relkeys,
ls_subclass TYPE seorelkey.

DATA : lv_cpdname TYPE seocpdname,
lv_type TYPE char30,
lv_exposure TYPE seoexpose,
lv_text TYPE char30,
lv_superclass TYPE seoclsname.
DATA : lt_domval TYPE re_t_rsdomaval,
ls_domval TYPE dd07v.
PARAMETER : p_class TYPE seoclass-clsname.
TRY.
CREATE OBJECT zcl_oo_class
EXPORTING
clsname = p_class
with_inherited_components = seox_true
with_interface_components = seox_true.
WRITE :/ 'Class Name : ', zcl_oo_class->class-clsname.
WRITE :/ 'Class Description : ', zcl_oo_class->class-descript.
WRITE :/ 'Class Author : ', zcl_oo_class->class-author.
CATCH cx_class_not_existent .
ENDTRY.
IF zcl_oo_class IS NOT INITIAL.
** Get attributes of the Class **
REFRESH : lt_attributes.
zcl_oo_class->get_attributes(
EXPORTING
public_attributes_only = seox_false
instance_attributes_only = seox_false
reference_attributes_only = seox_false
RECEIVING
result = lt_attributes ).
WRITE :/ 'Attributes List'.
WRITE :/ '---------------'.
LOOP AT lt_attributes INTO ls_attributes.
WRITE :/ ls_attributes-clsname, ls_attributes-cmpname.
ENDLOOP.
WRITE :/.
* Get components list **
REFRESH : lt_methods.
zcl_oo_class->get_methods(
EXPORTING
public_methods_only = seox_false
instance_methods_only = seox_false
RECEIVING
result = lt_methods ).
WRITE :/ 'Components List '.
WRITE :/ '----------------'.
LOOP AT lt_methods INTO ls_methods.
WRITE :/ ls_methods-clsname, ls_methods-cmpname.
ENDLOOP.
WRITE :/.
** Get Component Signature **
IF lt_methods[] IS NOT INITIAL.
REFRESH : lt_params, lt_exceps.
WRITE :/ 'Component Signatures '.
WRITE :/ '---------------------'.
LOOP AT lt_methods INTO ls_methods.
MOVE ls_methods-cmpname TO lv_cpdname.
CLEAR : ls_signature.
TRY.
zcl_oo_class->get_component_signature(
EXPORTING
cpdname = lv_cpdname
RECEIVING
result = ls_signature ).
CATCH cx_component_not_existing .
ENDTRY.
IF ls_signature IS NOT INITIAL.
APPEND LINES OF ls_signature-params TO lt_params.
APPEND LINES OF ls_signature-exceps TO lt_exceps.
ENDIF.
ENDLOOP.
WRITE :/ ':: Parameters ::'.
LOOP AT lt_params INTO ls_params.
MOVE ls_params-type TO lv_type.
WRITE :/ ls_params-cmpname,ls_params-sconame, lv_type.
ENDLOOP.
IF lt_exceps[] IS NOT INITIAL.
WRITE :/ ':: Exceptions ::'.
LOOP AT lt_exceps INTO ls_exceps.
WRITE :/ ls_exceps-cmpname, ls_exceps-sconame, ls_exceps-descript.
ENDLOOP.
ENDIF.
ENDIF.
WRITE :/.

** Get Component Exposure **
REFRESH : lt_domval.
cl_reca_ddic_doma=>get_values(
EXPORTING
id_name = 'SEOEXPOSE'
id_langu = sy-langu
IMPORTING
et_values = lt_domval
EXCEPTIONS
not_found = 1
OTHERS = 2 ).
WRITE :/ 'Components Visibility '.
WRITE :/ '----------------------'.
LOOP AT lt_methods INTO ls_methods.
CLEAR : lv_exposure.
MOVE ls_methods-cmpname TO lv_cpdname.
TRY.
zcl_oo_class->get_component_exposure(
EXPORTING
cpdname = lv_cpdname
RECEIVING
result = lv_exposure ).
CLEAR : ls_domval.
READ TABLE lt_domval INTO ls_domval WITH KEY domvalue_l = lv_exposure.
IF sy-subrc EQ 0.
WRITE :/ lv_cpdname, ls_domval-ddtext.
ENDIF.
CATCH cx_component_not_existing .
ENDTRY.
ENDLOOP.
WRITE :/.
** Get attribute Type **
REFRESH : lt_domval.
cl_reca_ddic_doma=>get_values(
EXPORTING
id_name ='SEOTYPTYPE'
id_langu = sy-langu
IMPORTING
et_values = lt_domval
EXCEPTIONS
not_found = 1
OTHERS = 2 ).
WRITE :/ 'Class Attributes details'.
WRITE :/ '------------------------'.
LOOP AT lt_attributes INTO ls_attributes.
TRY.
MOVE ls_attributes-cmpname TO lv_cpdname.
zcl_oo_class->get_attribute_type(
EXPORTING
cpdname = lv_cpdname
RECEIVING
result = ls_seotype ).
CLEAR :ls_domval.
READ TABLE lt_domval INTO ls_domval WITH KEY domvalue_l = ls_seotype-typtype.
IF sy-subrc EQ 0.
MOVE ls_seotype-type TO lv_type.
MOVE ls_domval-ddtext TO lv_text.
WRITE :/ lv_cpdname, lv_text, lv_type.
ENDIF.
CATCH cx_component_not_existing .
CATCH cx_wrong_component_type .
ENDTRY.
ENDLOOP.
WRITE :/.

** Get list of sub classes **
REFRESH : lt_subclass.
lt_subclass = zcl_oo_class->get_subclasses( ).
IF lt_subclass[] IS NOT INITIAL.
WRITE :/ 'Subclass Details'.
WRITE :/ '----------------'.
LOOP AT lt_subclass INTO ls_subclass.
WRITE :/ ls_subclass-refclsname, ls_subclass-clsname.
ENDLOOP.
ENDIF.
WRITE :/.

** Get list of super classes **
CLEAR : lv_superclass.
lv_superclass = zcl_oo_class->get_superclass( ).
WRITE :/ 'Super Class -> ' ,lv_superclass.
ENDIF.

source link:

http://wiki.sdn.sap.com/wiki/display/stage/Information+of+Class+Objects+using+CL_OO_CLASS

分享到:
评论

相关推荐

    SAP-ABAP-OO-实现-CL-SALV-TABLE

    ### SAP-ABAP-OO 实现 CL-SALV-TABLE 的关键知识点 #### 1. ABAP 面向对象的 ALV 显示方法 在 SAP 的 ABAP 环境中,ALV (Application List Viewer) 是一种非常常用的技术,用于在屏幕上以表格的形式展示数据。传统...

    在ALV里编写回车事件

    在这里,我们获取了`BCJE`字段的新值,并可以根据需要对数据进行进一步的验证或处理。 #### 四、总结 通过上述步骤,我们可以在ALV中实现回车事件的处理。这不仅可以提高用户界面的友好性,还能增强系统的功能性。...

    sap abap oo实现ALV

    面向对象的ALV实现主要通过使用类`CL_SALV_TABLE`来完成。这种实现方式相比传统的函数模块更加灵活和强大,能够提供更多的定制选项,并且更易于扩展和维护。 #### 三、实现步骤详解 以下是一些关键步骤和代码示例,...

    ABAP alv OO 面向对象 开发 二

    传统的ALV实现通常涉及复杂的Function Module调用或多个Class的组合使用,而随着面向对象(OO)技术的发展,特别是`CL_SALV_TABLE`类的引入,ALV的实现变得更为简洁高效。 #### ALV显示形式 ABAP ALV支持三种主要的...

    sap abap oo实现alv框可编辑

    "SAP ABAP OO实现ALV框可编辑" 在SAP ABAP中,实现ALV框的可编辑功能是非常重要的。本文将详细介绍如何使用面向对象编程(Object-Oriented Programming,OOP)在SAP ABAP中实现ALV框的可编辑功能。 首先,我们需要...

    ABAP ALV面向对象方法

    - 需要定义的数据源可以是从数据库表中获取的数据,也可以是从ABAP内部表中获取的数据。 2. **Building Field Catalog** - **Structure of a Field Catalog**: - 字段目录是ALV的核心组成部分,它定义了列表中每...

    TAW10 ABAP Certification Test Part 2.pdf

    根据提供的文件信息,我们可以推断出这是一份与ABAP(Advanced Business Application Programming)认证测试相关的文档,专注于面向对象编程(Object-Oriented Programming, OOP)的概念和技术。以下是对文档中提到...

Global site tag (gtag.js) - Google Analytics