Skip to Content
Former Member
Nov 11, 2018 at 05:16 PM

I need to create a perform inside a class.

505 Views Last edit Nov 11, 2018 at 05:17 PM 2 rev


I wrote a report which I had to use the perform statement but I need now to move the code of that report into my class, unfortunately I just saw that you cannot implement a subroutine inside a method so what i did was to create a method to handle that.

The problem is that now the code is not working like it should work.

The report had to upload the file and parse the xml in it string by string.

I'll show you my program so maybe you can help me.

Here is the report:

perform upload_file. "It's for uploading the data from the xml to a string variable
perform parse_xml.
Form parse_xml.
CASE pnode->get_type( ).
     WHEN if_ixml_node=>co_node_element.
       string = pnode->get_name( ).
       attribs = pnode->get_attributes( ).
       CLEAR attrib_value.
       CASE string.
*This is done for every string to get data from the xml.
         WHEN 'identifier'.
           CLEAR ss.
           ss = pnode->get_value( ).
           ls_context-identifier = ss.
           APPEND ls_context TO lt_context.
pnode = pnode->get_first_child( ).
* then I am using while loop 
    PERFORM parse_xml USING pnode.
     pnode = pnode->get_next( ).

This way it's working fine and not having any issues.

Now I have to move it to my class and that's where it becomes difficult since i cannot have a perform.

I used the same code calling the same method inside the method.

pnode = pnode->get_first_child( ).
       WHILE NOT pnode IS INITIAL.
     CALL METHOD zcl_xblr_dca=>parse_xml
         pnode     = pnode
         lv_output = lv_output
     pnode = pnode->get_next( ).

But it passes some xml tags.

Do you know any other ways to use a subroutine inside a class ?