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

Method return parameter of typ ref

Former Member
0 Likes
526

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
        .

3 REPLIES 3
Read only

manuel_bassani
Contributor
0 Likes
501

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

Read only

Former Member
0 Likes
501

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

Read only

0 Likes
501

@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?