cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically reduce max-length of input field

daniel_humberg
Contributor
0 Kudos

I have an input field that is mapped to a context attribute with a DDIC type (CHAR40 in this case).

Therefore, it is not possible for the user to enter more than 40 characters.

In some cases, I want to reduce the maximum number of characters to 24 without changing the type of the context attribute or the data type in DDIC.

Is there any way?

Unfortunately, an input field does not have a MaxLenth property. Can I change the context attribute's metadata programmatically?

Accepted Solutions (0)

Answers (3)

Answers (3)

marcin_cholewczuk
Active Contributor
0 Kudos

Hi all,

@PRAVEEN This method gives possibility to change only these values: REQUIRED, READ_ONLY, VISIBLE, ENABLED - no max length

@kissnas width is possible to be set with normal attributes of this control, so no need to use dynamic programming here. Beside that attribute width is width of control not max length. I've looked through this class (cl_wd_input_field) and end up with nothing 😕 method SET__DDIC_BINDING looked good at first, but it's for something else.

@Daniel If I were you I would define second context attribute with 24 characters and rebind value of input field or, if it doesn't work, delete and create input field once again with new context binding.

Best regards

Marcin Cholewczuk

daniel_humberg
Contributor
0 Kudos

summary: the length will always from the the context element, and therefore indirectly from the DDIC.

Former Member
0 Kudos

Hi,

here is the sample code which you need to write in wddomodify

data: LR_CONTAINER type ref to CL_WD_UIELEMENT_CONTAINER,

lr_inptfld type ref to cl_wd_input_field.

lr_inptfld ?= view->GET_ELEMENT( 'DEALER' ).

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_width LIKE ls_context-width. // width type i.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

lv_width = '24'.

lr_inptfld->SET_WIDTH( VALUE = LV_WIDTH ).

Hope it helps...

Cheers,

Kris.

Former Member
0 Kudos

Hi,

Yes we can change the properties of a UI elements in the coding part ,and try to code this part in wddomodify by using the method SET_ATTRIBUTE_PROPERTY which is included in IF_WD_CONTEXT_NODE.Give the respected values you want to give to the field you want to edit.And try doing this way,hope it works for sure.

Thanks.