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: 

Create with employee details

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Before Insert, do a check in the ZEMPLOYEES table for the empid, if sy-subrc = 0, then give an error message.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Before Insert, do a check in the ZEMPLOYEES table for the empid, if sy-subrc = 0, then give an error message.

0 Kudos

Something like this?

IF SY-SUBRC = 0.

EMPID = ZLEMPLOYEE-EMPID

ENDIF.

*THEN this?

INSERT INTO ZLEMPLOYEE VALUES ZLEMPLOYEE.

Thanks for writing back,

Regards,

Lucky

0 Kudos

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.

0 Kudos

Thanks a heap.

Regards,

Lucky

Edited by: Rob Burbank on Aug 5, 2009 1:16 PM