Properties SourceCde
txt
1
*---------------------------------------------------------------------*
2
*       FORM CHECK_NEW_MAINKEY                                        *
3
*---------------------------------------------------------------------*
4
* check if current mainkey is a new one                               *
5
*---------------------------------------------------------------------*
6
* <-- SY-SUBRC : 0 -> mainkey is new, others -> mainkey already exists*
7
*---------------------------------------------------------------------*
8
FORM check_new_mainkey.
9
  LOCAL: total, <table1>.
10
  DATA: hf TYPE i, rec TYPE i.
11
 
12
  MOVE: <vim_xtotal_key> TO <f1_x>.
13
  READ TABLE total WITH KEY <f1_x> BINARY SEARCH TRANSPORTING NO FIELDS.
14
  IF sy-subrc EQ 0."new entry already inserted into TOTAL
15
    hf = sy-tabix - 1.
16
    READ TABLE total INDEX hf.         "read previous entry
17
    IF <vim_tot_mkey_beforex> EQ <vim_f1_beforex> AND
18
       ( vim_mkey_after_exists EQ space OR
19
         <vim_tot_mkey_afterx> EQ <vim_f1_afterx> ). "same mainkey
20
*    IF <vim_tot_mkey_before> EQ <vim_f1_before> AND
21
*       ( vim_mkey_after_exists EQ space OR
22
*         <vim_tot_mkey_after> EQ <vim_f1_after> ). "same mainkey
23
      rec = 8.                         "-> mainkey already exists
24
    ELSE. "not the same mainkey -> check also next entry
25
      hf = hf + 2.
26
      READ TABLE total INDEX hf.       "read next entry
27
      IF <vim_tot_mkey_beforex> EQ <vim_f1_beforex> AND
28
         ( vim_mkey_after_exists EQ space OR
29
           <vim_tot_mkey_afterx> EQ <vim_f1_afterx> ). "same mainkey
30
*      IF <vim_tot_mkey_before> EQ <vim_f1_before> AND
31
*         ( vim_mkey_after_exists EQ space OR
32
*           <vim_tot_mkey_after> EQ <vim_f1_after> ). "same mainkey
33
        rec = 8.                       "-> mainkey already exists
34
      ENDIF.
35
    ENDIF.
36
  ENDIF.
37
  sy-subrc = rec.
38
ENDFORM.                               "check_new_mainkey