*---------------------------------------------------------------------* * FORM CHECK_NEW_MAINKEY * *---------------------------------------------------------------------* * check if current mainkey is a new one * *---------------------------------------------------------------------* * <-- SY-SUBRC : 0 -> mainkey is new, others -> mainkey already exists* *---------------------------------------------------------------------* FORM check_new_mainkey. LOCAL: total, . DATA: hf TYPE i, rec TYPE i. MOVE: TO . READ TABLE total WITH KEY BINARY SEARCH TRANSPORTING NO FIELDS. IF sy-subrc EQ 0."new entry already inserted into TOTAL hf = sy-tabix - 1. READ TABLE total INDEX hf. "read previous entry IF EQ AND ( vim_mkey_after_exists EQ space OR EQ ). "same mainkey * IF EQ AND * ( vim_mkey_after_exists EQ space OR * EQ ). "same mainkey rec = 8. "-> mainkey already exists ELSE. "not the same mainkey -> check also next entry hf = hf + 2. READ TABLE total INDEX hf. "read next entry IF EQ AND ( vim_mkey_after_exists EQ space OR EQ ). "same mainkey * IF EQ AND * ( vim_mkey_after_exists EQ space OR * EQ ). "same mainkey rec = 8. "-> mainkey already exists ENDIF. ENDIF. ENDIF. sy-subrc = rec. ENDFORM. "check_new_mainkey