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

Accessing Class attributes within a BADI class object

Former Member
0 Likes
1,018

we have a BADI object of type ISU_UCES_CO_NEW. now in the codes of a FM this object is assigned with values. one of the value assigned is a class object ZCL_ISU_UCES_CO_NEW in the object.

We need to access the attribute of the sub class ZCL_ISU_UCES_CO_NEW inside the main object ISU_UCES_CO_NEW.

Checking in the debugging we are able to see the value but need to access it through the program.

How to access the class attributes with in a class .

Your ideas are appreciated.

we have a BADI object of type ISU_UCES_CO_NEW. now in the codes of a FM this object is assigned with values. one of the value assigned is a class object ZCL_ISU_UCES_CO_NEW in the object.

We need to access the attribute of the sub class ZCL_ISU_UCES_CO_NEW inside the main object ISU_UCES_CO_NEW.

Checking in the debugging we are able to see the value but need to access it through the program.

How to access the class attributes with in a class .

Your ideas are appreciated.

2 REPLIES 2
Read only

franois_henrotte
Active Contributor
0 Likes
666

you need to cast your object into an instance of the ZCL_ISU_UCES_CO_NEW class in order to access its proper attributes

so if you have a parameter of type ref to ISU_UCES_CO_NEW called P_UCES you do it like this:

DATA: lo_uces TYPE REF TO zcl_isu_uces_co_new.

lo_uces ?= p_uces.

* now you have access to attributes of object lo_uces

Read only

0 Likes
666

The casting of lo_uces ?= p_uces. throws a syntax error for incompatibility.

lo_uces TYPE REF TO zcl_isu_uces_co_new

P_UCES TYPE REF TO isu_uces_co_new