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

Any function module for validation

Former Member
0 Likes
2,723

Hi,

I am new to ABAP.

Can any body tell me whether there is any built in function module for

field validation.

Thanks in advance

Archana

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,628

> Hi,

>

> I am new to ABAP.

> Can any body tell me whether there is any built in

> function module for

> field validation.

>

> Thanks in advance

>

> Archana

Thank you everybody.

My exact query is as follows:

I am doing module programming.

I want to validate a particular field while getting input.

For example:

I have a field like location. In that field input should be only india.

If user enters some other value, it should display a message like invalid input.

Thanks in advance

Archana

8 REPLIES 8
Read only

Former Member
0 Likes
1,628

Hi!

Welcome on the board!

Your question seems very common, what exactly do you want?

A few examples:

- datum fields have automatic validation for correct format, but if you wnat an exat date range, you have to program it yourself

- at the select-option command, you can use the OBLIGATORY extension, to prevent the field staying empty

- in SE11, you can define to your data element a foreign key, which checks in the background, are there entries for the given field

Regards

Tamá

Read only

Manohar2u
Active Contributor
0 Likes
1,628

Welcome Archana.

What kind of validation you are looking for? because depends on the field you need to respective validations...like data...like ...customer number...like vendor number....etc...etc...

Hence if you are looking in for your program then you need to make use of AT-SELECTION SCREEN events and write respective validation code.

Hope I could able to give you some details..

Cheers

Manohar

Read only

Former Member
0 Likes
1,628

Hi,

u can validate the field values using at selectiion-screen

• AT SELECTION-SCREEN

When user enters the values in the fields of selection screen and clicks on execute button, this event gets triggered. This event is basically for checking the values entered by the user for the fields of the selection screen i.e., data validity checking. This event is for entire selection screen. For example:

You are accepting carrid, connid, fldate from user and you don’t want to proceed if user enters no value for carrid and fldate. Using AT SELECTION-SCREEN can do this.

Select-options: carrid1 for sflight-carrid,

Connid1 for sflight-connid,

F1date1 for sflight-f1date.

AT SELECTION-SCREEN.

If carrid1-low ne ‘ ’ and fldate1-low = ‘ ’.

Error message.

Endif.

In this case, if both the fields are entered blank, then the user gets error message.

Basically, this event is for many fields on selection screen. Usually, it is for the fields which are logically related.

• AT SELECTION-SCREEN ON <field>

When you want to check for specific value of a field. For example, carrid should be in the range of ‘LH’ and ‘SQ’. This can be done in this event. Basically, this event is for checking individual fields. You can have many AT selection-screen events in your program (i.e., for each field specified in the Select-Options).

Select-Options carrid1 for sflight-carrid.

AT SELECTION-SCREEN.

If carrid1-low ne ‘LH’ and carrid1-high ne ‘SQ’.

Error message.

Endif.

Here the system will not proceed on entering wrong values.

Regards,

Sruthi

Read only

Former Member
0 Likes
1,628

Obligatory is making the input mandatory.

You can use the below event at selection-screen on field and write you respective validation code in the perform.

AT SELECTION-SCREEN ON field p_fname.

PERFORM get_filename USING p_fname.

Read only

Former Member
0 Likes
1,629

> Hi,

>

> I am new to ABAP.

> Can any body tell me whether there is any built in

> function module for

> field validation.

>

> Thanks in advance

>

> Archana

Thank you everybody.

My exact query is as follows:

I am doing module programming.

I want to validate a particular field while getting input.

For example:

I have a field like location. In that field input should be only india.

If user enters some other value, it should display a message like invalid input.

Thanks in advance

Archana

Read only

0 Likes
1,628

Refer this code

Code to demonstrate screen validation for dialog programs. The following code should be inserted into

the PAI module.

  • Validate single field via module call

 FIELD sc_field-ebeln
   MODULE validate_screen_field     "validation code performed in module
  ON INPUT.


* Validate multiple fields via module call
  CHAIN.
    FIELD: sc_field-ebeln, sc_field-ebelp.
    MODULE validate_screen_field.   "validation code performed in module
  ENDCHAIN.


* Validate field via table selection
  FIELD sc_field-ebeln
    SELECT *
      FROM ekko
     WHERE ebeln = sc_field-ebeln
      INTO ekko
       WHENEVER NOT FOUND SEND ERRORMESSAGE 001
                         WITH ' Document Number ’
 ON INPUT.

http://www.sapdevelopment.co.uk/dialog/dialoghome.htm

Hope this will oslve ur query, reward if this helsp.

Read only

0 Likes
1,628

hi archana,

in the Flow logic of the screen..

under the PROCESS AFTER INPUT event..

write module...

module MOD1.

MODULE MOD1 INPUT.

IF V_FLD NE 'INDIA'.

MESSAGE E001(ZERR).

ENDIF.

ENDMODULE.

Read only

0 Likes
1,628

use this it will help you,AT SELECTION-SCREEN ON FIELD S_KUNNR-LOW.

SELECT SINGLE * FROM KNA1 WHERE KUNNR = S_KUNNR-LOW.

IF SY-SUBRC NE 0.

MESSAGE E000(0) WITH 'ENTER VALID VALUE'.

CHEERS