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: 

Validation of entry in custom table

former_member672218
Participant
0 Kudos

Hi ppl,

I have one requirement where users can maintain value into a custom table. While entering a new value, if the similar primary key entries already exist in the table then there is a requirement of giving a pop-up box to the user informing that a similar kind of entry already exist and if he wants to overwrite. If the user clicks yes, then the new record should be saved and also one of the field in old record should be modified.

I have written an event in the table maintenace by which i am able to get the pop-up and the old entry gets modifed but when the PBO module gets triggered inside a standard include i get the error mssage " Record already exist". The error is obvious as the same primary keys are used in the second entry too but i am just curious to know if there is any way by which this standard error could be overcome so that the user should get only my pop-up box and not the standard error message.

Regards,

Venkat

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hey,

You are getting the standard text because you are going to insert into the table.You cannot suppress the standard message but you can do some other thing.You take the values in the table to the internal table and before insertion into the table you should check the value which the user had entered and then check the value and the key.Thus you can catch that before the insertion into the table.

You can use the READ statement with key for reading the database.if the sy-subrc is 0 you can understand a value is there in the table.

Hope this will be helpful.

Regards,

Midhun Abraham

Edited by: Midhun Abraham on Oct 5, 2008 5:23 AM

7 REPLIES 7

Former Member
0 Kudos

hey,

You are getting the standard text because you are going to insert into the table.You cannot suppress the standard message but you can do some other thing.You take the values in the table to the internal table and before insertion into the table you should check the value which the user had entered and then check the value and the key.Thus you can catch that before the insertion into the table.

You can use the READ statement with key for reading the database.if the sy-subrc is 0 you can understand a value is there in the table.

Hope this will be helpful.

Regards,

Midhun Abraham

Edited by: Midhun Abraham on Oct 5, 2008 5:23 AM

vinod_vemuru2
Active Contributor
0 Kudos

Hi Venkat,

One more thought here...

Instead of INSERT use MODIFy statement which modifies the old record. So ur new data will be updated and u won't get the standard error message. If this doesn't work then probably u have to delete the current entry, COMMIT WORK then INSERT ur new entry. Hope one of the above will solve ur problem.

Thanks,

Vinod.

former_member672218
Participant
0 Kudos

Hi,

Thanks for your inputs but Midhun even on following your suggestion when we try to update the table with the similar primary entries wont the standard error be displayed?

Vinod, the requirement is to have the old entry too along with the new entry. Only change that is needed in the old entry is that the "Valid to" field must be modifed. I am able to modify the old entry but am not sure if there is a way to suppress the standard error .

Regards,

Venkat

0 Kudos

Hi Venkat,

I don't think there is a way to suppress this message. Also can u tell whether u r using INSERT/MODIFY statement? Also is this Valid To is a key field. if it is a key then u can't modify the record. Also it is not possible to have more than one record with same primary key.

Hope u got my views.

Thanks,

Vinod.

former_member672218
Participant
0 Kudos

Hi Vinod,

I am using the modify command and the valid to field is not a primary key.

Edited by: venkat varadan on Oct 5, 2008 2:01 PM

0 Kudos

Hi Venkat,

If u use to modify statement with the primary key which is already exists then it won't insert a new record. Infact it modifies the existing record. Check ur table entries once. U won't have 2 records with same key combination. It is not possible in SAP/In any database as per my knowledge.

If u still wnat to achieve this functionality then probably u can have a dummy key (Say some counter). So when ever u got a new record with same primary key(Old) then increment this counter by 1 and insert a new record. I hope this is the only way to solve ur problem.

Thanks,

Vinod.

0 Kudos

Closing.