title: Avoid Adding Duplicate Records
body: <p>I m trying to write if statement to give error message if user try to add existing ID number.When i try to enter existing id i get error .untill here it s ok but when i type another id no and fill the fields(name,adress etc) it doesnt go to database.</p>
  <pre><code>METHOD add_employee.
      DATA: IT_EMP TYPE TABLE OF ZEMPLOYEE_20.
      DATA:WA_EMP TYPE ZEMPLOYEE_20.
      Data: l_count type i value '2'.
  
      SELECT * FROM ZEMPLOYEE_20 INTO TABLE IT_EMP.
  
      LOOP AT IT_EMP INTO WA_EMP.
  
        IF wa_emp-EMPLOYEE_ID eq pa_id.
          l_count = l_count * '0'.
  
        else.
          l_count = l_count * '1'.
        endif.
      endloop.
  
      If l_count eq '2'.
  
        WA_EMP-EMPLOYEE_ID = C_ID.
        WA_EMP-EMPLOYEE_NAME = C_NAME.
        WA_EMP-EMPLOYEE_ADDRESS = C_ADD.
        WA_EMP-EMPLOYEE_SALARY = C_SAL.
        WA_EMP-EMPLOYEE_TYPE = C_TYPE.
        APPEND wa_emp TO it_emp.
        INSERT ZEMPLOYEE_20 FROM TABLE it_emp.
  
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
          EXPORTING
            TITEL     = 'INFO'
            TEXTLINE1 = 'Record Added Successfully.'.
            elseif l_count eq '0'.
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
          EXPORTING
            TITEL     = 'INFO'
            TEXTLINE1 = 'Selected ID already in database.Please type another ID no.'.
  
      ENDIF.
  ENDMETHOD.
  </code></pre>