*---------------------------------------------------------------------*
*       FORM FILL_EXTRACT                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM fill_extract.
 DATA: rec LIKE sy-subrc VALUE 9, total_safe(4096) TYPE c, indei TYPE i,
                   hf TYPE i VALUE 1.
  FIELD-SYMBOLS: <begdate_mask>.
  REFRESH: extract. CLEAR extract.
  CLEAR vim_mainkey.
  TRANSLATE vim_no_mainkey_exists USING vim_no_mkey_not_procsd_patt.
  IF x_header-delmdtflag NE space.
    ASSIGN <vim_new_begdate> TO <begdate_mask> TYPE 'C'.
  ENDIF.
  LOOP AT total.
    PERFORM normal_select.
    CHECK sy-subrc EQ 0.
    IF x_header-delmdtflag NE space AND
       vim_ignore_collapsed_mainkeys EQ space.
      PERFORM check_and_modify_mainkey_tab USING rec.
      IF rec NE 0.
        vim_coll_mainkeys_beg_ix = vim_last_coll_mainkeys_ix.
      ENDIF.
      CHECK rec LT 8.
      IF rec EQ 4. rec = 9. ENDIF.
    ENDIF.
    extract = total.
    APPEND extract.
  ENDLOOP.
  vim_coll_mainkeys_beg_ix = 1.
  IF rec NE 9 AND rec NE 0.
    PERFORM mod_extract_and_mainkey_tab USING 'A' 0.
  ENDIF.
  DESCRIBE TABLE extract LINES maxlines.
  mark_extract = mark_total.
  status-data = gesamtdaten.
  title-data  = gesamtdaten.
  CLEAR <status>-selected.
* <STATUS>-DISPL_MODE = EXPANDED. "default display mode
  IF maxlines EQ 0.
    PERFORM vim_send_sv005_or_sv766 USING '766'
                                          'RESET'.
    IF function NE 'DELE' AND function NE 'SAVE'.           "HWR
      IF x_header-selection EQ space AND fill_extr_first_proc EQ space.
        IF NOT vim_oc_inst IS INITIAL
* data access restricted?
          AND ( ( <status>-st_action = aendern
                AND NOT vim_oc_inst->oc_selcrit_maint_tab IS INITIAL )
          OR ( 'ST' CS <status>-st_action
                AND NOT vim_oc_inst->oc_selcrit_read_tab IS INITIAL ) ).
          MESSAGE s766(sv).
*   Eingeschränkte Anzeige von Datensätzen.
        ELSE.
          MESSAGE s065(sv).            "keine Einträge vorhanden
        ENDIF.
        MOVE 'X' TO fill_extr_first_proc.
      ELSE.
        MESSAGE s004(sv). "keine Einträge gemäß Selektion gefunden
      ENDIF.
    ENDIF.                                                  "HWR
    EXIT.
  ELSEIF maxlines EQ 1.
    PERFORM vim_maintain_single_set.    "UFint2329966/2000
  ELSEIF NOT vim_oc_inst IS INITIAL AND
   function NE 'DELE' AND function NE 'SAVE'.
* data access restricted?
    IF ( <status>-st_action = aendern
         AND NOT vim_oc_inst->oc_selcrit_maint_tab IS INITIAL )
     OR ( 'ST' CS <status>-st_action
          AND NOT vim_oc_inst->oc_selcrit_read_tab IS INITIAL ).
      PERFORM vim_send_sv005_or_sv766 USING '766'
                                          'SENDIT'.
*   Eingeschränkte Anzeige von Datensätzen.
    ENDIF.
  ELSE.
    PERFORM vim_send_sv005_or_sv766 USING '766'
                                          'RESET'.
  ENDIF.
ENDFORM.                    "fill_extract
