*---------------------------------------------------------------------*
*    view related FORM routines
*   generation date: 15.05.2019 at 19:12:53
*   view maintenance generator version: #001407#
*---------------------------------------------------------------------*
*...processing: ZAGUNITTESTV....................................*
FORM GET_DATA_ZAGUNITTESTV.
  PERFORM VIM_FILL_WHERETAB.
*.read data from database.............................................*
  REFRESH TOTAL.
  CLEAR   TOTAL.
  SELECT * FROM ZAGUNITTEST WHERE
(VIM_WHERETAB) .
    CLEAR ZAGUNITTESTV .
ZAGUNITTESTV-MANDT =
ZAGUNITTEST-MANDT .
ZAGUNITTESTV-PARAM_KEY =
ZAGUNITTEST-PARAM_KEY .
ZAGUNITTESTV-PARAM_VALUE =
ZAGUNITTEST-PARAM_VALUE .
<VIM_TOTAL_STRUC> = ZAGUNITTESTV.
    APPEND TOTAL.
  ENDSELECT.
  SORT TOTAL BY <VIM_XTOTAL_KEY>.
  <STATUS>-ALR_SORTED = 'R'.
*.check dynamic selectoptions (not in DDIC)...........................*
  IF X_HEADER-SELECTION NE SPACE.
    PERFORM CHECK_DYNAMIC_SELECT_OPTIONS.
  ELSEIF X_HEADER-DELMDTFLAG NE SPACE.
    PERFORM BUILD_MAINKEY_TAB.
  ENDIF.
  REFRESH EXTRACT.
ENDFORM.
*---------------------------------------------------------------------*
FORM DB_UPD_ZAGUNITTESTV .
*.process data base updates/inserts/deletes.........................*
LOOP AT TOTAL.
  CHECK <ACTION> NE ORIGINAL.
MOVE <VIM_TOTAL_STRUC> TO ZAGUNITTESTV.
  IF <ACTION> = UPDATE_GELOESCHT.
    <ACTION> = GELOESCHT.
  ENDIF.
  CASE <ACTION>.
   WHEN NEUER_GELOESCHT.
IF STATUS_ZAGUNITTESTV-ST_DELETE EQ GELOESCHT.
     READ TABLE EXTRACT WITH KEY <VIM_XTOTAL_KEY>.
     IF SY-SUBRC EQ 0.
       DELETE EXTRACT INDEX SY-TABIX.
     ENDIF.
    ENDIF.
    DELETE TOTAL.
    IF X_HEADER-DELMDTFLAG NE SPACE.
      PERFORM DELETE_FROM_MAINKEY_TAB.
    ENDIF.
   WHEN GELOESCHT.
  SELECT SINGLE FOR UPDATE * FROM ZAGUNITTEST WHERE
  PARAM_KEY = ZAGUNITTESTV-PARAM_KEY .
    IF SY-SUBRC = 0.
    DELETE ZAGUNITTEST .
    ENDIF.
    IF STATUS-DELETE EQ GELOESCHT.
      READ TABLE EXTRACT WITH KEY <VIM_XTOTAL_KEY> BINARY SEARCH.
      DELETE EXTRACT INDEX SY-TABIX.
    ENDIF.
    DELETE TOTAL.
    IF X_HEADER-DELMDTFLAG NE SPACE.
      PERFORM DELETE_FROM_MAINKEY_TAB.
    ENDIF.
   WHEN OTHERS.
  SELECT SINGLE FOR UPDATE * FROM ZAGUNITTEST WHERE
  PARAM_KEY = ZAGUNITTESTV-PARAM_KEY .
    IF SY-SUBRC <> 0.   "insert preprocessing: init WA
      CLEAR ZAGUNITTEST.
    ENDIF.
ZAGUNITTEST-MANDT =
ZAGUNITTESTV-MANDT .
ZAGUNITTEST-PARAM_KEY =
ZAGUNITTESTV-PARAM_KEY .
ZAGUNITTEST-PARAM_VALUE =
ZAGUNITTESTV-PARAM_VALUE .
    IF SY-SUBRC = 0.
    UPDATE ZAGUNITTEST ##WARN_OK.
    ELSE.
    INSERT ZAGUNITTEST .
    ENDIF.
    READ TABLE EXTRACT WITH KEY <VIM_XTOTAL_KEY>.
    IF SY-SUBRC EQ 0.
      <XACT> = ORIGINAL.
      MODIFY EXTRACT INDEX SY-TABIX.
    ENDIF.
    <ACTION> = ORIGINAL.
    MODIFY TOTAL.
  ENDCASE.
ENDLOOP.
CLEAR: STATUS_ZAGUNITTESTV-UPD_FLAG,
STATUS_ZAGUNITTESTV-UPD_CHECKD.
MESSAGE S018(SV).
ENDFORM.
*---------------------------------------------------------------------*
FORM READ_SINGLE_ZAGUNITTESTV.
  SELECT SINGLE * FROM ZAGUNITTEST WHERE
PARAM_KEY = ZAGUNITTESTV-PARAM_KEY .
ZAGUNITTESTV-MANDT =
ZAGUNITTEST-MANDT .
ZAGUNITTESTV-PARAM_KEY =
ZAGUNITTEST-PARAM_KEY .
ZAGUNITTESTV-PARAM_VALUE =
ZAGUNITTEST-PARAM_VALUE .
ENDFORM.
*---------------------------------------------------------------------*
FORM CORR_MAINT_ZAGUNITTESTV USING VALUE(CM_ACTION) RC.
  DATA: RETCODE LIKE SY-SUBRC, COUNT TYPE I, TRSP_KEYLEN TYPE SYFLENG.
  FIELD-SYMBOLS: <TAB_KEY_X> TYPE X.
  CLEAR RC.
MOVE ZAGUNITTESTV-PARAM_KEY TO
ZAGUNITTEST-PARAM_KEY .
MOVE ZAGUNITTESTV-MANDT TO
ZAGUNITTEST-MANDT .
  CORR_KEYTAB             =  E071K.
  CORR_KEYTAB-OBJNAME     = 'ZAGUNITTEST'.
  IF NOT <vim_corr_keyx> IS ASSIGNED.
    ASSIGN CORR_KEYTAB-TABKEY TO <vim_corr_keyx> CASTING.
  ENDIF.
  ASSIGN ZAGUNITTEST TO <TAB_KEY_X> CASTING.
  PERFORM VIM_GET_TRSPKEYLEN
    USING 'ZAGUNITTEST'
    CHANGING TRSP_KEYLEN.
  <VIM_CORR_KEYX>(TRSP_KEYLEN) = <TAB_KEY_X>(TRSP_KEYLEN).
  PERFORM UPDATE_CORR_KEYTAB USING CM_ACTION RETCODE.
  ADD: RETCODE TO RC, 1 TO COUNT.
  IF RC LT COUNT AND CM_ACTION NE PRUEFEN.
    CLEAR RC.
  ENDIF.

ENDFORM.
*---------------------------------------------------------------------*
