‎2010 Aug 18 3:00 PM
Hi Experts
I have the following function module code, that passes the syntax, however in the class interface ABC, I have an attribute IJK that is Instance Attribute (Public). When I modify the code like ABC->IJK but it does not like it, the error is :-
Field "ABC" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "DATA" statement.
Question : How do I declare the Class Interface ABC in my Function Module that will allow me to access the Instance Attribute ?
Thanks in advance.
FUNCTION XYZ.
if not ABC=>EFG is initial.
output = ABC=>EFG.
shift output left deleting LEADING space.
endif.
ENDFUNCTION.
‎2010 Aug 19 4:22 AM
Do like this :
data : reference typ ref to abc.
create object reference.
output = reference->ijk
Edited by: pr@t on Aug 19, 2010 8:53 AM
‎2010 Aug 19 4:22 AM
Do like this :
data : reference typ ref to abc.
create object reference.
output = reference->ijk
Edited by: pr@t on Aug 19, 2010 8:53 AM
‎2010 Aug 22 8:21 PM
Hello
You question only makes sense if
(1) the class / interface is part of the FM's interface (i.e. an IMPORTING - or perhaps CHANGING - parameter)
(2) the class / interface is defined as global variable in the TOP include of the function group
If either of these two options is applicable then the coding may look like this:
" (1) IMPORTING parameter: e.g. IO_INSTANCE TYPE REF TO class / interface name
IF ( io_instance IS BOUND ).
io_instance->abc = 'New value'.
ENDIF.
" (2) Global variable of function group, e.g. GO_INSTANCE TYPE REF TO class / interface name:
IF ( go_instance IS BOUND ).
go_instance->abc = 'New value'.
ENDIF.
Obviously, the public attribute ABC must be changeable (i.e. not READ-ONLY).
Regards
Uwe
‎2010 Aug 24 8:30 AM
Thanks for your responses and helpful hints.
I awarded the points. Before your response I managed to resolve it with following syntax, similar to the one proposed.
DATA dref TYPE REF TO ABC.
DATA: f2 LIKE dref->EFG.
if not ABC->EFG is initial.
output = ABC->EFG.
shift output left deleting LEADING space.
endif.