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

Table Maintenance Generator With Events validations.

Former Member
0 Likes
2,458

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

4 REPLIES 4
Read only

Former Member
0 Likes
1,204

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.

Read only

0 Likes
1,204

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

Read only

Former Member
0 Likes
1,204

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.

Read only

0 Likes
1,204

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