Application Development 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: 

How to provide validation for a particular field of screen

Former Member
0 Kudos

Hi Experts,

For my project, I have created a screen. In the screen, we have one field. For this field we have provided F4 help. When the user clicks on the F4 list of values is displayed.

I have to provide following condition for this field.

User should only select values from this F4 list only. If the user tries to enter any data which is not contained in the list, system should throw message that 'Invalid data. Select valid values".

Can you please let me know how I can do so?

The relevant portion of code is

CASE save_ok_code.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'BACK'.

PERFORM exit.

WHEN 'CANCEL'.

LEAVE PROGRAM.

WHEN 'SAVE'.

CALL FUNCTION 'MESSAGES_INITIALIZE'.

PERFORM check_batch CHANGING fl_error.

IF fl_error IS INITIAL.

PERFORM save.

IF sy-subrc EQ 0.

CLEAR gv_deleted.

PERFORM update_alv_grid_display.

***for message display

CALL FUNCTION 'MESSAGES_SHOW'.

ENDIF.

ELSE.

CALL FUNCTION 'MESSAGE_STORE'

EXPORTING

arbgb = 'ZEX_MYPROJECT'

msgty = 'S'

txtnr = '053'

msgv1 = text-008

EXCEPTIONS

OTHERS = 3.

CHECK sy-subrc = 0.

CALL FUNCTION 'MESSAGES_SHOW'.

ENDIF.

WHEN OTHERS.

CALL METHOD cl_gui_cfw=>dispatch.

I am totally new for ABAP. So, please help me out.

Thanks

Smith

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

then in that case you have to use Field <screenfield> module <module_name>.

in the module you check the value using the checktable/value table and accordinly give the message.

3 REPLIES 3

former_member188685
Active Contributor
0 Kudos

then in that case you have to use Field <screenfield> module <module_name>.

in the module you check the value using the checktable/value table and accordinly give the message.

Former Member
0 Kudos

Hello Smith,

If you are showing F4 values from the foreign table. You can activate foreigh key check box on the field attributes. If you are showing F4 values dynamically (through POV), you have to validate the field with FIELD statement in PAI event. Let me know if you need more information.

with best regards

K. Mohan Reddy

Former Member
0 Kudos

Hi,

Try this.

Create an internal table and populated it with the values present in the F4 help of the field. Then in AT SELECTION-SCREEN event check the value of the field with the values in the internal table and display the appropriate message.

Sharin.