Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Display error message when value entered does not have same data type

0 Likes
951

Hi Experts,

            How do I Display an error message when the value entered for a FIELD in the SCREEN is not of the same Data type as assigned to the field????

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
897

Hi,

Those are handled by default. You need not worry

for example, execute this

parameters:pa  type i. "Try entering a alphabet here

parameters:pa2 type p. "Try entering a symbol   here

parameters:pa3 type sy-datum. "Try entering a symbol or alphabet here

6 REPLIES 6
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
897

Provide more details.

Your question is wrong as of now because the value is provided as input by the user in the screen and how does the value have a data type ?

Read only

0 Likes
897

Hi Kesavadas,

                   I have designed a screen and I have dragged and dropped fields from the Dictionary, To be specific the fields from the tables which I have CUSTOM CREATED..The Fields by default have the dictionary data type mapping from the tables.

            For me, from the End- User Point of View, if the user enters a value that is not supposed to be entered in that field, LIKE SAY FOR EXAMPLE For a  NAME ,I enter a NUMBER by MISTAKE.

For this kind of a scenario i need to throw an error message.

How Can I go Forward with it?

Read only

0 Likes
897

Well, numbers are a subset of characters, so I'm not sure what you want.

For example, if the screen field is an address, you would want to allow users to enter something like "123 Main St."

Rob

Read only

0 Likes
897

Hi Bharath,

You can use,

FIELD <fieldname> MODULE <modulename>. "for single field check

CHAIN .... ENDCHAIN construct "for multiple fields  in PAI

and write logic in <modulename> to check whether the input is correct format or not like

if fieldname co '0123456789'  "syntax for checking if a field value contains only numbers

Hope this helps,

Regards,

Ravi

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
898

Hi,

Those are handled by default. You need not worry

for example, execute this

parameters:pa  type i. "Try entering a alphabet here

parameters:pa2 type p. "Try entering a symbol   here

parameters:pa3 type sy-datum. "Try entering a symbol or alphabet here

Read only

Former Member
0 Likes
897

Hi,

For data types I, P and D and some others you will get a standard message,

to handle the Char type data validation use

log_exp - Comparison operators for character-type operands

Ex: CA contains any, NA contains not any...

if the screen field is v_matnr and supposed enter only character and type of Char....

If v-matnr CA 'numbers'.

i hope you may try the logic with existing classes  like CL_ABAP_CHAR_UTILITIES.

Hope the info would help you..