cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create SimpleType at RunTime and Set MaximumLength

0 Kudos

Hi,

My requirement is to create an input field at run time and its maximum length should be the same as ABAP field (Example:CHAR 10).

Here the node creation is also being done at runtime.

And as I understood, the maximum length is determined by the binding type.

So when dynamically creating a node and adding an attribute(per field), I need to pass the simple data type.

Here the need is how to create a simple data type and set its Maximum length at runtime.

I can do this at design time, but did not find any api methods to do this at run time.

Any pointers on how this can be achieved.

Regards,

Sagar

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi,

Thanks for your reply, but now the setMaxLength expects me to set an integer but if I do that, I get the following exception:

java.lang.IllegalArgumentException

com.sap.dictionary.runtime.DdSimpleType.setMaxLength(DdSimpleType.java:716)

How to resolve this?

Regards,

Sagar

Former Member
0 Kudos

you can restrict the input field by writing this code in init method.

use try catch block

ISimpleTypeModifiable aaaaa= wdContext.wdGetAPI().getModifiableTypeOf ("bbbbb");

aaaaa.setMaxExternalLength(6);

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sagar,

If you need just limit the string length you don't need to create SimpleType. You can create an attribute of type string and use the method setMaxLength() to set the max length:


...
IWDNodeInfo info = wdContext.nodeTest().getNodeInfo();
info.getAttribute(IPublicTestComp.ITestElement.TEST_STRING).getModifiableSimpleType().setMaxLength(TEXT_LENGTH_10);
...

This will also affects the InputField element. If you bind value property to testString context attribute, the user will be able to enter max 10 chars.

Good luck

Ivan

Former Member
0 Kudos

I dont think it is possible to cretae a simple type at Run time but we can certainly modify it using getModifiableSimpleType()