cancel
Showing results for 
Search instead for 
Did you mean: 

Can we do input field readonly and it will takes data only from F4

former_member459142
Participant
0 Kudos

Hi experts,

I want user only fill data in inputfield by F4, not manualy , can we do somwthing for that.

Thanks & Regards

Prashant Gupta

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Prashanth,

We can handle your requirement. I will give one example and it is working.

Address - Node

Firtst_Name- Node attribute and this attribute will have DDIC search help.

Create Input field 'FIRSTNAME' for this attribute in screen with transparent container 'TC' and bind the above context to the UI element. Now this UI element is Context is 'ADDRESS.FIRSTNAME'.

Now add the below code in MODIFYVIEW hook method.The below code will add search help with read only input field but for display mode again you have to disable the search help for this field. i have not written code for that.

DATA: lo_first_name TYPE REF TO cl_wd_input_field,

lo_first_name_new TYPE REF TO cl_wd_input_field, " New input field

lo_transp_cont TYPE REF TO cl_wd_transparent_container. " TC container

lo_new_container TYPE REF TO cl_wd_transparent_container.

DATA: lv_bound_value TYPE string,

lv_read_only TYPE wdy_boolean.

IF iv_first_time EQ abap_true.

lo_first_name_input ?= io_view->get_element( id = 'FIRST_NAME' ).

lo_first_name_input->set_width( '0' ).

lv_bound_value = lo_first_name_input->bound_value( ). "ADDRESS.FIRST_NAME"

  • Create new dynamic Input Field

CALL METHOD cl_wd_input_field=>new_input_field

EXPORTING

bind_value = lv_bound_value

id = 'FIRST_NAME_NEW'

read_only = abap_true

view = io_view

RECEIVING

control = lo_first_name_new.

  • Create new dynamic Transparent Container

CALL METHOD cl_wd_transparent_container=>new_transparent_container

EXPORTING

id = 'TC_NEW' " New container

view = io_view

RECEIVING

control = lo_new_container.

" I used flow layout thats why i am using the flow layout

cl_wd_flow_layout=>new_flow_layout( container = lo_new_container ).

cl_wd_matrix_data=>new_matrix_data( element = lo_new_container ).

" Get old field container

lo_transp_cont ?= io_view->get_element( id = 'TC' ).

IF NOT lo_transp_cont IS INITIAL.

"Using a new Transparent Container both Fields for FIRST_NAME are shown as only one Field

cl_wd_flow_data=>new_flow_data( element = lo_first_name_new ).

lo_new_container->add_child( the_child = lo_first_name_new ).

" remove the child means old FIRT_NAME

lo_first_name ?= lo_transp_cont->remove_child( id = 'FIRST_NAME' ).

cl_wd_flow_data=>new_flow_data( element = lo_first_name ).

lo_new_container->add_child( the_child = lo_first_name ).

lo_transp_cont->add_child( index = 2

the_child = lo_new_container ).

ENDIF.

endif.

Regards,

Devi

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

HI prashant

it is not possible by any options in input field.

you can do some workaround to get the desired functionlityone option is create one more input field besides to the first one and make the size of it 0px.

and then make the first input field as disabled.

then the value help icon will come with first input field and choosing the value form value help will chenge its value.

but there also field will be disbled and you wont be able to use F4

option from the keyboard.

so i will suggest use dropdown instead of this.

thanks

sarbjeet singh