08-05-2009 5:50 PM
Hello everyone,
I have a small question. Quiet confusing though i have created a button "create" to insert data into my employee table.
this is how it goes and it works completely fine:
WHEN 'CREATE'.
INSERT INTO ZLEMPLOYEE VALUES ZLEMPLOYEE.
*where zlemployee is my employee table.
Question: How can i make sure that the entered data already exists in my table and how can i tell the user that he cannot create the same employee record with different details?
Say a user has entered the data into the fields and suppose i already have that employee record created in the table. how can i tell the user that the following employee has already been created? say my empid is the primary key.
Thanks for writing back,
Regards,
Lucky
08-05-2009 5:55 PM
Hi,
Before Insert, do a check in the ZEMPLOYEES table for the empid, if sy-subrc = 0, then give an error message.
08-05-2009 5:55 PM
Hi,
Before Insert, do a check in the ZEMPLOYEES table for the empid, if sy-subrc = 0, then give an error message.
08-05-2009 5:59 PM
Something like this?
IF SY-SUBRC = 0.
EMPID = ZLEMPLOYEE-EMPID
ENDIF.
*THEN this?
INSERT INTO ZLEMPLOYEE VALUES ZLEMPLOYEE.
Thanks for writing back,
Regards,
Lucky
08-05-2009 6:05 PM
like..
SELECT SINGLE * FROM ZEMPLOYEES INTO WA_ZEMPLOYEES
WHERE EMPID = ZEMPLOYEES-EMPID.
IF SY-SUBRC =0.
MESSAGE " Employee already exists".
ELSE.
your INSERT statement.
ENDIF.
08-05-2009 6:10 PM
Thanks a heap.
Regards,
Lucky
Edited by: Rob Burbank on Aug 5, 2009 1:16 PM