2010 Jun 05 9:31 AM
Hi ABAPers,
I have created a Z table and a table maintenance generator to maintain the data.
I have to carry out certain validations when user enters data on Key and Non- key fields.
In the event 21 validate the data entered and give a information message if the validation fail and in the event 01 (on save) I recheck the data if validation fail the user is not allowed to save the data ( VIM_ABORT_SAVING = 'X') and give a message to change the data and save.
This is working fine, but the issue is with the key fields.
The Z table is created with SITE, MATNR and EBDAT as key. We have requirement were the future date record entry is not allowed.
When the user enters a future date the following code is invoked in event 21:
IF TOTAL_S-EBDAT > sy-datum.
VIM_ABORT_SAVING = 'X'.
MESSAGE i008(ZSCP_MSG) WITH total_s-WERKS total_s-MATNR total_s-EBDAT ." Future date not allowed
sy-subrc = 4.
ENDIF.After this when the table maintenance screen is displayed the date field is grayed out (non-editable) as it is the key field of the table.
Now the user cannot change the data unlike the non-key fields were the user can modify the non-valid data and save again.
In the current scenario the user has to delete the record and create a new record.
How can make the date field (Key Field) editable after entry in case the validation fail, so that the user can make the changes.
Please suggest the approach to handle the above scenario in events.
Thanks,
Tausif
Hi ABAPers,
I have created a Z table and a table maintenance generator to maintain the data.
I have to carry out certain validations when user enters data on Key and Non- key fields.
In the event 21 validate the data entered and give a information message if the validation fail and in the event 01 (on save) I recheck the data if validation fail the user is not allowed to save the data ( VIM_ABORT_SAVING = 'X') and give a message to change the data and save.
This is working fine, but the issue is with the key fields.
The Z table is created with SITE, MATNR and EBDAT as key. We have requirement were the future date record entry is not allowed.
When the user enters a future date the following code is invoked in event 21:
IF TOTAL_S-EBDAT > sy-datum.
VIM_ABORT_SAVING = 'X'.
MESSAGE i008(ZSCP_MSG) WITH total_s-WERKS total_s-MATNR total_s-EBDAT ." Future date not allowed
sy-subrc = 4.
ENDIF.After this when the table maintenance screen is displayed the date field is grayed out (non-editable) as it is the key field of the table.
Now the user cannot change the data unlike the non-key fields were the user can modify the non-valid data and save again.
In the current scenario the user has to delete the record and create a new record.
How can make the date field (Key Field) editable after entry in case the validation fail, so that the user can make the changes.
Please suggest the approach to handle the above scenario in events.
Thanks,
Tausif
2010 Jun 05 4:26 PM
Hi Tausif,
Try this approach -
Goto the table maintenance generator double click on the overview screen now here u can see that the validation is handled between chain endchain, so create a module and throw error message on the validate condition, this will definitely work for non unique keys not sure about the primary key as table maintenance is used to add entries and modify the existing entries but not primary key. Anyway just try it might work.
Hope this helps.
2010 Jun 07 10:10 AM
Thanks Seema for the reply.
I have done the validations for the non-key fields using events. The issue is how to handel the validations for key fields. As after validations when the table maintenance screen is re-displayed the key fields are non-editable mode.
Regards,
Tausif
2010 Jun 07 10:49 AM
Hi Tausif,
In regards to your query.. I would say that you can keep this validation in '21' event.
If you will apply the validation in 21 event, entry can be recreated by clicking on cancel button. There won't be any need to delete the whole record.
I hope this would help.
2010 Jun 07 11:21 AM
Hi Nimisha ,
Thanks for the reply.
As mentioned I giving a message if the future date is entered in event 21, but when the user clicks OK on the message the date field goes into display mode.
Below is the code in Event 21:
IF ZSCP_DAILY-EBDAT > sy-datum.
* CLEAR ZSCP_DAILY-EBDAT.
MESSAGE i007(ZSCP_MSG). "Future date not allowed
* MESSAGE s007(ZSCP_MSG).
* Loop at screen.
* IF screen-name = 'ZSCP_DAILY-EBDAT'.
* screen-input = 1.
* modify screen.
* endif.
* endloop.
EXIT.
ENDIF.Regards,
Tausif