cancel
Showing results for 
Search instead for 
Did you mean: 

Get UI element ID

Former Member
0 Kudos

Hi,

I'm trying to get the element ID.

Ex: I'm having a inputfield with id = 'input1'.

at runtime i want to hide the fields depeding the id.

So i need to get the id.

I used cl_custom_event to get the id.

But getting the type conflict.

Can u help me out.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi suba,

If you have already created an input field element with id 'INPUT1' at design time, first access that particular element using the ID that you specified , then do the manipulations( visibilty :: hide) there however you like..

source code would be as follows..

METHOD wdmodifyview.

DATA : lr_input1 TYPE REF TO cl_wd_input_field.

lr_input1 = view->get_element (

exporting

id = 'INPUT1'

).

now u have reached to that particular element where u can change it's properties.

first get the visibility property of this element.

data: lv_visible Type Ref to wdui_input_field_visible.

lv_visible = lr_input1->get_visibile().

lr_input1->set_visible(

importing

value = IF_WDL_STANDARD=>INPUTFIELDVISIBLE_NONE).

try this one.. and it should work....

best regards .

SRINI....

lr_input

ENDMETHOD.

Former Member
0 Kudos

Hi Srini,

Thanks a lot for ur answer.

I welcome ur code example.

If we know the ID we are accessing the property.

But I want to get the ID dynamically.

Say for example, we are having 5 screen input fields.

once u fill data into the 1st field, u have to move the cursor to the 2nd field and it goes on....

So i would like to get the id dynamically.

Former Member
0 Kudos

Hi Suba

I think it's not a good design to hide some inputfield deponds on their id in WDDOMODIFYVIEW.

Webdynpro programming suggests that binding the UI elements's invisible property to a context attribute, and then change the invisible property in your actions.

You can bind your inputfield's invisible property to few groups,like Input1-20 bind to group1,Input30-40 bind to group2,and in your actions change group1 to abap_false or abap_true,it's the best way to handle UI elements.

Regards.

Fisher.

Answers (3)

Answers (3)

Former Member
0 Kudos

hi,

please can u tell me how to display UI elements dynimically than hiding at runtime.

thank u in advance

Former Member
0 Kudos

Hi,

Follow the following steps:

1. You have to have a reference to the current view - a reference to an object of type IF_WD_VIEW. The is automatically available in the WDDOMODIFYVIEW event handler.

2. Use a code similar to the following.


 data: lr_container       type ref to cl_wd_transparent_container,
         lr_layout            type ref to cl_wd_layout,
         lr_text                type ref to cl_wd_text_view.

  lr_container ?= view->get_element( 'CONTAINER_NAME' ) .
  lr_layout ?= cl_wd_grid_layout=>new_grid_layout( container = lr_container ).
  lr_container->set_layout( lr_layout ).

  if lr_container->has_children( ) = 'X'.
    lr_container->remove_all_children( ).
  endif.

  lr_text ?= cl_wd_text_view=>new_text_view( text = l_msg design = 03 ).
  cl_wd_grid_data=>new_grid_data( element = 'Text' ).
  lr_container->add_child( lr_text ).

The above code has a reference to the current view in 'view' (it is written in WDDOMODIFYVIEW)

The reference to the transparent container UI element is retrieved, and a UI element of type TEXTVIEW is attached to the transparent container which has a grid layout.

Similarly, you can create and add other UI elements dynamically.

Regards,

Wenonah

Former Member
0 Kudos

hi suba ram,

To the best of my knowledge if u want to get the ID of a view element , do the following

From the view element (input-field 1 (ID : INPUT1))

create and instance of ur INPUT-FIELD1, which is

data: LR_INPUT1 TYPE REF TO CL_WD_INPUT_FIELD1

DATA: lv_id TYPE string.

lv_id = LR_INPUT1->IF_WD_VIEW_ELEMENT~GET_ID().

It must work.....

regards

srini..

Former Member
0 Kudos

Hello,

See these: , [http://help.sap.com/saphelp_nw04s/helpdata/en/ab/518f41ff3f2e7be10000000a1550b0/frameset.htm], [https://www.sdn.sap.com/irj/sdn/wiki?path=/display/wdabap/dynamic%2buse%2bof%2bdictionary].

Regards.