cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in instantiating the class CL_WDR_CONTEXT_ELEMENT

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi All,

I would like to use the Interface method IF_WD_CONTEXT_ELEMENT~GET_ATTRIBUTE in my z program.

When I execute my program it is going to DUMP and says you cannot use the reference of a NULL object.

So I tried to do DATA : Oref type ref to CL_WDR_CONTEXT_ELEMENT.

and then CREATE Object Oref.

Now syntax says ' you can create instance of this class out side the class'.

I searched similar posts in SDN and found that some one is suggesting to use GET_INSTANCE method inside the class.

But I dont have GET_INSTANCE method inside this class.

Please assist.

Accepted Solutions (1)

Accepted Solutions (1)

alex_campbell
Contributor
0 Kudos

It might help for you to go back to the WebDynpro and ABAP-OO documentation, as there are some important concepts here that you might not grasp completely.

You cannot use CREATE OBJECT on CL_WDR_CONTEXT_ELEMENT, because SAP has defined it as "Create Private" meaning that it is not allowed to create an instance of this class directly. This is very common in ABAP-OO as a way to keep custom developers (like us) from creating instances incorrectly. Usually, if you need to work on an instance of one of these classes, there will be a "Factory" method (which creates a new instance from within the class) or a "Getter" method (which returns an instance of the class which already exists).

In WebDynpro, you would get the context element from a context node. For example, if your context (which is automatically instantiated in field wd_context in a WD controller) has a node "ELEMENTS", you would call getter method GET_CHILD_NODE like such:

elements_node = wd_context->get_child_node( 'ELEMENTS' )

and this would populate wd_elements_node with the instance for the "ELEMENTS" node. If then you wanted to get the first element in node "ELEMENTS" (which is only possible if the node has a cardinality to n), you would call getter method GET_ELEMENT like such:

element_attr = elements_node->get_element( 1 )

and then you would have your instance of IF_WD_CONTEXT_ELEMENT.

I strongly suggest you go back and do some tutorials on WebDynpro (or the SAP Press book Web Dynpro ABAP is excellent), as SAP expects you to do things in a very particular way, and if you don't have a solid understainding of how everything works together, you are going to have a very, very tough time.

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi Alex. Thanks for the comments. I was working on the FPM application and in the Feeder class there is a method called, BEFORE_FLUSH and FLUSH. In these methods there is a Parameter called CT_CHANGE_LOG and IT_CHANGE_LOG and when there is a value in these methods TABLE_ROW is not getting populated. It is always Initial. I was trying to understand that part. Regarding working on Web-Dynpro I was working on this Technology from past 5 years.

alex_campbell
Contributor
0 Kudos

I haven't worked with FPM so I don't think I can provide any guidance on your specific case. It sounds like maybe what you're trying to do is create a new element in a multi-element context node. In this case you'd need to get an instance of your context node (hopefully FPM gives you access, either through the root context node, or the context node directly), and call method if_wd_context_node~create_element. This will return an instance of if_wd_context_element, on which you can call method if_wd_context_element~get_attribute.

Hope this helps!

Alex

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Could you please let me know your requirement. I'm afraid, you cannot use Web Dynpro methods outside. And it is not advisable to use CL_WDR* classes aswell.

Regards,

Kiran