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. endcase. endcase. pnode = pnode->get_first_child( ). * then I am using while loop WHILE NOT pnode IS INITIAL. PERFORM parse_xml USING pnode. pnode = pnode->get_next( ). ENDWHILE. endform.
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.
endcase pnode = pnode->get_first_child( ). WHILE NOT pnode IS INITIAL. CALL METHOD zcl_xblr_dca=>parse_xml EXPORTING pnode = pnode lv_output = lv_output . pnode = pnode->get_next( ). ENDWHILE.
But it passes some xml tags.
Do you know any other ways to use a subroutine inside a class ?