cancel
Showing results for 
Search instead for 
Did you mean: 

Setting max length of the field when using Context Model Node

Former Member
0 Kudos

I have created a model using Import Adaptive Web Service model option (a web service was a wrapper around SAP BAPI function module).

There were no dictionary types created in the Local dictionary as a result of import.

I have mapped the context of the controller to the model node.

One of the fields in the model is name CUSTOMER_NUMBER type string;

Corresponding element in the wsdl of the web service is

<xsd:element name="CUSTOMER_NUMBER" type="tns:char10" />

I have created a view with the input filed mapped to the CUSTOMER_NUMBER field of the model node.

When I type more than 10 chars into the field and hit the search button, I get a com.sap.dictionary.runtime.Ddcheck exception that the length of the field should be less than 10 chars.

How can I set the max length of the field in design time to prevent runtime exception?

Thanks,

Julia

Accepted Solutions (1)

Accepted Solutions (1)

sridhar_k2
Active Contributor
0 Kudos

Julia,

As this is a simple thing(10 Chars to Web Service), i would not recommend to create Value Node and copy the structure.

Why dont you try with substring(int beginIndex, int endIndex)

it returns first 10 chars of your search string.

Regards,

Sridhar

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you for your reply.

Java trim function will trim the white spaces only, not the characters.

I can code check length functionality before calling execute function (the function that call the web service).

I can also create a dictionary structure based on the model structure; create a context value node based on the dictionary structure and use WDCopyService API to move the data between value node and model node.

I was looking for the best practice...

When importing model based on Adaptive RFC, the dictionary structures are imported together with the model. This does not happen for Adaptive web service - hence there is a need to add coding for simple checks.

Julia

Former Member
0 Kudos

Why dont u make use of a simple type and set the max length(say 10) for the simple type and bind it to the value attribute.And make use of the trim() method to eliminate the spaces if any entered.

Former Member
0 Kudos

There are more fields than just this one - 2 of them are dates, 1 numeric and 5 strings.

If I code the length / data type check for each one, I will have to create multiple error messages for each one and translate them (we support 3 languages).

Julia

Former Member
0 Kudos

For date you are not going to write any code because the frame work is going to take care of the date validations.And for the strings you make use of the same simple type for all the attributes if their max length is same.And for the numeric make use of another simple type then you dont need to do any coding for error messages as the webdypro framework is going to take care of the error message generation.(if its a simple type)

sridhar_k2
Active Contributor
0 Kudos

Julia,

You are true. For your requirement, it is better to create value node and pass it with copyService to your model node.

Regards,

Sridhar

Former Member
0 Kudos

Thanks.

Julia

PS: It would be very nice if the dictionary structures were created for the web service based models (similar to the RFC models).

Former Member
0 Kudos

Yes you can do it making use of the String related methods.The method trim() of String class is going to limit the values to the number of characters you want to do it.As per you after you enter more than 10 characters then those values will be trimmed.