‎2005 Nov 09 10:55 AM
Hi,
im trying to return the value of a ref variable (pointer) in a method. But the compiler says "the result of the method is not convertable into a number." ???? Is there a prob with returning ref values? My code is the following:
Method call:
DATA structure_elem TYPE REF TO if_ixml_element.
DATA document_elem TYPE REF TO if_ixml_element.
structure_elem = setTag(
tagName = 'STRUCTURE'
tagValue = ''
parentDomElement = document_elem
)
Method IMPLEMENTATION:
METHOD setTag.
* iXML
ixml TYPE REF TO if_ixml,
document TYPE REF TO if_ixml_document,
attributeElement TYPE REF TO if_ixml_element,
attributeValue TYPE REF TO if_ixml_text.
CLASS cl_ixml DEFINITION LOAD.
ixml = cl_ixml=>create( ).
document = ixml->create_document( ).
newDomElement = document->create_element(
name = tagName
).
ENDMETHOD.
Method DEFINTION:
setTag
IMPORTING
TagName TYPE STRING
TagValue TYPE STRING
parentDomElement TYPE REF TO if_ixml_element
RETURNING
VALUE(newDomElement) TYPE REF TO if_ixml_element
.
‎2005 Nov 09 11:30 AM
Hi,
i think that in in code
structure_elem = setTag(
tagName = 'STRUCTURE'
tagValue = ''
parentDomElement = document_elem
)
the specification of the object is missing. Try something like:
structure_elem = AN_OBJECT->setTag(
tagName = 'STRUCTURE'
tagValue = ''
parentDomElement = document_elem
)
Instead you can also declare the method setTag as STATIC
structure_elem = A_CLASS=>setTag(
tagName = 'STRUCTURE'
tagValue = ''
parentDomElement = document_elem
)
the code structure_elem = setTag( ... ) seems to be te call of arithmetic function like abs(...) or ceil(...)
Regards, Manuel
‎2005 Nov 09 11:36 AM
Hi,
In the code
newDomElement = document->create_element(
name = tagName
).
Check the returning parameter's type of <b>document->create_element()</b> method? The compilers error may be regarding this line.
Regards,
Ravi
‎2005 Nov 09 12:12 PM
@manuel: the method call is made inside the object
@ravi: they have the same typ in the definition. why should they have different typs for the compiler? or did u mean something different?