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: 

Modify Key Field Values of a table through Table Maintenance Generator

Former Member
0 Kudos

Hi All,

I have created a z table with below structure. In this fields upto Valid To are all key fields. This is to ensure that consistant valid record get stored in the table.

MANDT MANDT CLNT 3 0 Client

VKORG VKORG CHAR 4 0 Sales Organization

VTWEG VTWEG CHAR 2 0 Distribution Channel

SPART SPART CHAR 2 0 Division

SKU MATNR CHAR 18 0 Material Number

LZONE LZONE CHAR 10 0 Transportation zone to or from which the goods are delivered

VALID_FROM ZVALID_FROM DATS 8 0 Valid From

VALID_TO ZVALID_TO DATS 8 0 Valid To

PLANT WERKS_D CHAR 4 0 Plant

SNP_TZONE ZSNP_TZONE CHAR 20 0 APO Transportation Zone

ERDAT ERDAT DATS 8 0 Date on Which Record Was Created

ERNAM ERNAM CHAR 12 0 Name of Person who Created the Object

AEDAT AEDAT DATS 8 0 Changed On

AENAME AENAME CHAR 12 0 Last changed by

I have created a Table Maintance program through the Table Maintenance Generator. And for that I have assigned a t code.

I can able to create new entires but i can not able to modify Valid_from and Valid_to entries of existing records.

Initially those two fields were in display mode but i went to its module pool program and made then as input enabled. But what the vales I was entering, its not getting saved in database. When we change the values of those fields and save it, the system is saying No Data Change.

Any inputs how to solve this issue. I can not make VALID_FROM and VALID_TO fields as non key.

Regards,

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You wont be able to modify VALID_FROM and VALID_TO if they are defined as primary keys. Primary keys are meant to be unique, thus the system wont allow the primary key fields to be modified for existing records. The only option available is to delete the existing record and again enter the same values with different VALID_FROM and VALID_TO and insert the record.

Else remove the primary key definition for VALID_FROM and VALID_TO alone. Then you will be able to modify it. Also the table consistency and integrity will still be maintained since you have around 6 primary key fields.

Regards,

Vikranth

4 REPLIES 4

Former Member
0 Kudos

Hi,

You wont be able to modify VALID_FROM and VALID_TO if they are defined as primary keys. Primary keys are meant to be unique, thus the system wont allow the primary key fields to be modified for existing records. The only option available is to delete the existing record and again enter the same values with different VALID_FROM and VALID_TO and insert the record.

Else remove the primary key definition for VALID_FROM and VALID_TO alone. Then you will be able to modify it. Also the table consistency and integrity will still be maintained since you have around 6 primary key fields.

Regards,

Vikranth

0 Kudos

Hi,

Thanks for your reply. Now the Functional consultant has told to create a new entry with updated values when ever user tries to change the VALID_FROM or VALID_TO fields but keep the old values also. For this to achive which event is to be used in Table Maintenace Generator and if possible can u send me sample code for how to achive that.

Regards,

0 Kudos

Hi,

I would also like to know how we can assign authorization objects to table maintenance view created through Table Maintenance Generator.

I need to add Authorization objects M_MATE_WRK for Plant V_KNA1_VKO for Sales Area and ZSNP_TZONE for SNP Transportation Zone.

How can I achive this.

Regards,

0 Kudos

Hi,

As you have already said that the value for valid to is a part of the key so you should not have any issues when this value is changed and the value is saved using the table maintainence generator, but in case you want to save values where the value for valid from has changed but the key is same we would not be able to save as there is already a value for the key, so if you want to save these values there are two ways 1 would either to delete the existing value value and create the new value or to have one more field as the key field like a counter so when the value is saved with a key the value is saved with counter as 1 and then ever next time for the new values increase the value of the counter.

In order to save these values use event 5 and put you code there.

You can also carry out checks for new aithorization in that event also.

Regards,

Himanshu