Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with Abap Object

Former Member
0 Likes
667

Hi expert,

I have problem with "CLASS":

In my program i'm calling a method wich give me :

.

I want just the first : How can i do not to take the second?

How can right in abap :


if ... eq CLASS=CL_RETM_PERIOD_MNGR
exit.
endif.

Thanks a lot,

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
630

Hello

Perhaps for this requirement SAP provides a corresponding method:


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_IS_INSTANCE_OF
*&
*&---------------------------------------------------------------------*
*& Thread: Problem with Abap Object 
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1309987"></a> 
*&---------------------------------------------------------------------*

REPORT  zus_sdn_is_instance_of.


DATA:
  go_term_mngr      TYPE REF TO cl_reaj_term_mngr,
  to_period_mngr    TYPE REF TO cl_retm_period_mngr.


START-OF-SELECTION.

" NOTE: Direct instantiation not possible => fake coding
  CREATE OBJECT go_term_mngr.
  CREATE OBJECT go_period_mngr.

  IF ( cf_reca_object=>get_classname( go_term_mngr ) = 'CL_REAJ_TERM_MNGR' ).

  ELSE.

  ENDIF.


END-OF-SELECTION.

Perhaps it is necessary to use the underlying interfaces instead of the classes:

IF_REAJ_TERM_MNGR
IF_RETM_PERIOD_MNGR

Regards

Uwe

Regards

Uwe

6 REPLIES 6
Read only

former_member156446
Active Contributor
0 Likes
630
DATA: lv_vbap TYPE REF TO <class_name>.
CREATE OBJECT lv_vbap.


if  lv_vbap eq CL_RETM_PERIOD_MNGR.

do ...this

else.

donot .. do this
endif.
Read only

0 Likes
630

Thank u for your response but it doesn't work.

the problem is here:


if lv_vbap eq CL_RETM_PERIOD_MNGR.

It takes CL_RETM_PERIOD_MNGR as a field and not as class, and gives: CL_RETM_PERIOD_MNGR is unknown

Read only

0 Likes
630

I meant to check the instance of the class....

Read only

0 Likes
630

You mean: ?


        IF lo_specific_term_mngr  EQ {O:153*\CLASS=CL_REAJ_TERM_MNGR}.

          DO.
            go_adjmterm_mngr ?= lo_specific_term_mngr.
          ENDDO.
        ENDIF.

If it's that , it doesn't work: the error message: {0 is unknown.

Read only

uwe_schieferstein
Active Contributor
0 Likes
631

Hello

Perhaps for this requirement SAP provides a corresponding method:


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_IS_INSTANCE_OF
*&
*&---------------------------------------------------------------------*
*& Thread: Problem with Abap Object 
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1309987"></a> 
*&---------------------------------------------------------------------*

REPORT  zus_sdn_is_instance_of.


DATA:
  go_term_mngr      TYPE REF TO cl_reaj_term_mngr,
  to_period_mngr    TYPE REF TO cl_retm_period_mngr.


START-OF-SELECTION.

" NOTE: Direct instantiation not possible => fake coding
  CREATE OBJECT go_term_mngr.
  CREATE OBJECT go_period_mngr.

  IF ( cf_reca_object=>get_classname( go_term_mngr ) = 'CL_REAJ_TERM_MNGR' ).

  ELSE.

  ENDIF.


END-OF-SELECTION.

Perhaps it is necessary to use the underlying interfaces instead of the classes:

IF_REAJ_TERM_MNGR
IF_RETM_PERIOD_MNGR

Regards

Uwe

Regards

Uwe

Read only

0 Likes
630

Thanks Uwe, it solves my pb

Regards,

Mehdi