cancel
Showing results for 
Search instead for 
Did you mean: 

Reference to View

Former Member
0 Kudos

Hi,

How do i get the reference to the view in which i am working????

In Modifyview method i can just use the parameter "view". But i need this reference in another method.

Can anybody help me out in this?

Best Regards,

Kanakaraj V A

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Use IF_WD_VIEW to instantiate the view

Use wd_this to point the present view.

DATA: i_view type ref to IF_WD_VIEW.

DATA: i2_view type ref to IF_WD_VIEW.

i2_view = wd_this->i_view.

Best Regards

Ravi

Former Member
0 Kudos

hi,

Yes, you can use VIEW parameter in WDMODIFYVIEW in the following way


data ui_label     type ref to cl_wd_label. " suppose you have UI as LABEL


  ui_label ?= view->get_element( 'LABEL' )." here give the ID of UI element 

    ui_label->set_enabled( abap_true ).

I hope it helps.

Regards,

Rohit

uday_gubbala2
Active Contributor
0 Kudos

Hi Kanakaraj,

You can as a work around obtain the reference of the view within your WDDOMODIFYVIEW & save it into an view attribute of the same type (i.e, TYPE REF TO IF_WD_VIEW). This attribute would then be available across your view.

ex:

Suppose you had defined an attribute by name gv_view of TYPE REF TO IF_WD_VIEW in your views "Attributes" tab. You can access this attribute from any of your View's method by saying as: wd_this->gv_view

You can obtain & save your views reference into it from within your WDDOMODIFYVIEW method by saying as:

check first_time = abap_true.
wd_this->gv_view =  view.

SAP doesn't recommend this approach at all and you wouldn't be able to ask for any support from SAP for any problems that you may incur while following such an approach. As per SAP any dynamic programming that you intend to perform must be done lone from within your WDDOMODIFYVIEW.

Regards,

Uday

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> SAP doesn't recommend this approach at all and you wouldn't be able to ask for any support from SAP for any problems that you may incur while following such an approach. As per SAP any dynamic programming that you intend to perform must be done lone from within your WDDOMODIFYVIEW.

>

> Regards,

> Uday

I want to add to this warning and strongly recommend against doing this. This absolutely violates the phase model of Web Dynpro and if you change UI elements outside WDDOMODIFYVIEW you will almost certainly have inconsistencies and/or short dumps. This is a very bad idea.

arjun_thakur
Active Contributor
0 Kudos

Hi Kanakaraj,

You can use WD_THIS as reference of the local controller. Go to the attribute tab of the view, there you'll see an attribute of WD_THIS name, you can use it to get reference of the current view you are working it.

Regards

Arjun