cancel
Showing results for 
Search instead for 
Did you mean: 

Overwriting framework error messages of simple types

Former Member
0 Kudos

Hi

Is it possible to overwrite the framework error messages of simple types? For example: Instead of "Enter the value in the format -2,733.34" we prefer something like "Enter the percent value in the format 0.00 to 100." or "Enter a correct percent value.".

Use case: We use for the most input fields for any numbers (telefon, amount, age, ...) the simple type "decimal", this offers following advantages:

- optional use (and framework validation) of fraction digits

- the input field has no default value (integer/long/short writes as default "0" to the input field, that is in most cases - for example post/zip code - not useful)

Otherwise decimal simple types has the disadvantage, that if the user write any letters in the (decimal) input field, the error message is as described above and so not very helpful too.

Thanks in advance

Stefan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If I remember correctly, I talked about the same question with a SAP trainer a year ago. His answer was no.

I never tried since, but still believe its not possible.

I would try custom validation and mark the Action as non validating for the fields in question.

Jan

Answers (1)

Answers (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Stefan

Unfortunately seems no way to customize the error messages.

1. If the standard numeric simple type does not suit your needs, theoretically you can try to override the Java class of the standard type and add your custom messages/logic. For example, for Integer this is DdTypeInteger & DdTypeInt. Methods you need to override is format(...) and parse(...). After this in controller's code you should create a new attribute and provide your own custom type as input parameter.

I never tried this way

2. You can make the attribute as Calculated. Then in getter/setter you should put your custom formatting/parsing logic.

BR, Siarhei

Former Member
0 Kudos

Thanks Siarhei

to 1.

Looks to be a good idea, unfortunately it's not possible using simple types based on a Java classes, every simple type must be a Built-In-Type or a extension of another Base Type (which is also based on a Built-In-Type).

to 2.

Maybe that could work, but with such a solution the advantage of framework validation gets lost (that means the automatic roundtrip validation for all input-fields of the active view/register, when - for example - the user switches to another register/tab).

Regards

Stefan

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Stefan

to 1.

Here I agree with you expecting the problems with Built-In-Types.

to 2.

The deal is not exactly as you wrote here. Your custom setter will be under the automatic validation too. I mean that you have to write your own validation in the setter. But the setter will be invoked by the framework as usual. So your use case "automatic roundtrip validation for all input-fields of the active view/register, when - for example - the user switches to another register/tab" will work.

BR, Siarhei

Edited by: Siarhei Pisarenka on Nov 24, 2009 9:35 AM

former_member183915
Active Contributor
0 Kudos

Hi Siarhei ,

I am facing similar issue. In my case for a context attribute of type integer if the user enters a decimal value , then the framework provided message Value must be of type integer (between -2147483648 and 2147483647) is displayed but as per my requirement instead of this message a custom message needs to be displayed.

Could you please elaborate on the 2nd approach i.e. to make the attribute as Calculated and then custom formatting/parsing logic in getter/setter.

It would be good if you give an example on how to make a context attribute calculated and avoid the framework provided message