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: 

Validating field in a table while creating new entries.

Former Member
0 Kudos

HI all,

I have to validate the 'Todate' field in ztable. Validation is Todate should be greater than 'Fromdate'.

For this i have written some code in maintainance event (05-New entries).It is working fine.See the code below.

----


***INCLUDE LZKM0007F01 .

----


FORM AT_NEWENTRY.

IF ZKM0007-ZTO_DATE LT ZKM0007-ZFROM_DATE.

MESSAGE E001(ZKM) WITH 'ENTER TODATE GREATER THAN FROMDATE'.

ENDIF.

ENDFORM.

If i enter the 'Todate' less than 'fromdate' it is showing an error massege. After showing the error message these two fields are greyed out(disabled). But it should not happened. I want error message and i want to change (or correct) the 'Todate' here itself instead of cancelling and re entering the record line totally.

Rewards to all.

Thanks,

Anu.

3 REPLIES 3

Former Member
0 Kudos

Hi anupama,

Please do the following,

FORM AT_NEWENTRY.

IF ZKM0007-ZTO_DATE LT ZKM0007-ZFROM_DATE.

MESSAGE<b> I001</b>(ZKM) WITH 'ENTER TODATE GREATER THAN FROMDATE'.

<b>EXIT.</b>

ENDIF.

ENDFORM.

change error to information message and write..exit after that..which will bring you back to the same screen

Pls check and revert

Regards

Byju

0 Kudos

Hi,

I have already tried this. It shows only information.If we forgot to change the date, then it saves in database. It allow to save. so i want to display error message.

Is it possible with error message?

Thanks

Anu.

0 Kudos

Issuing an "E" type message is the correct way to proceed, I reckon... look at one of the SAP events that does a similar validation e.g. view V_WOSCR_GRP_003 has an event '05' called "validate_account" in (include LWOST_CR_IMG01FNG)... it issues "E" messages (with some amusing comments too).

An "E" message in a table control would normally lock all the rows other than the current one... but if fields on the current (exception) row are getting locked, have a look at the screen flow - in the PAI there should be a " LOOP AT EXTRACT." followed by a "CHAIN." and then all the fields to keep open on the row in case of error and "module set_update_flag"... check the ones you want are there, as I think that's where your event will be called.

Jonathan