*---------------------------------------------------------------------*
*    view related FORM routines
*   generation date: 23.09.2018 at 19:52:37
*   view maintenance generator version: #001407#
*---------------------------------------------------------------------*
*...processing: ZVCONST_H.......................................*
FORM GET_DATA_ZVCONST_H.
  PERFORM VIM_FILL_WHERETAB.
*.read data from database.............................................*
  REFRESH TOTAL.
  CLEAR   TOTAL.
  SELECT * FROM ZTCONST_H WHERE
(VIM_WHERETAB) .
    CLEAR ZVCONST_H .
ZVCONST_H-MANDT =
ZTCONST_H-MANDT .
ZVCONST_H-SECTION_ID =
ZTCONST_H-SECTION_ID .
ZVCONST_H-CONST_ID =
ZTCONST_H-CONST_ID .
ZVCONST_H-LOGSYS =
ZTCONST_H-LOGSYS .
    SELECT SINGLE * FROM ZTCONST_HT WHERE
SECTION_ID = ZTCONST_H-SECTION_ID AND
CONST_ID = ZTCONST_H-CONST_ID AND
LOGSYS = ZTCONST_H-LOGSYS AND
LANGU = SY-LANGU .
    IF SY-SUBRC EQ 0.
ZVCONST_H-TEXT =
ZTCONST_HT-TEXT .
    ENDIF.
<VIM_TOTAL_STRUC> = ZVCONST_H.
    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_ZVCONST_H .
*.process data base updates/inserts/deletes.........................*
LOOP AT TOTAL.
  CHECK <ACTION> NE ORIGINAL.
MOVE <VIM_TOTAL_STRUC> TO ZVCONST_H.
  IF <ACTION> = UPDATE_GELOESCHT.
    <ACTION> = GELOESCHT.
  ENDIF.
  CASE <ACTION>.
   WHEN NEUER_GELOESCHT.
IF STATUS_ZVCONST_H-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 ZTCONST_H WHERE
  SECTION_ID = ZVCONST_H-SECTION_ID AND
  CONST_ID = ZVCONST_H-CONST_ID AND
  LOGSYS = ZVCONST_H-LOGSYS .
    IF SY-SUBRC = 0.
    DELETE ZTCONST_H .
    ENDIF.
    DELETE FROM ZTCONST_HT WHERE
    SECTION_ID = ZTCONST_H-SECTION_ID AND
    CONST_ID = ZTCONST_H-CONST_ID AND
    LOGSYS = ZTCONST_H-LOGSYS .
    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 ZTCONST_H WHERE
  SECTION_ID = ZVCONST_H-SECTION_ID AND
  CONST_ID = ZVCONST_H-CONST_ID AND
  LOGSYS = ZVCONST_H-LOGSYS .
    IF SY-SUBRC <> 0.   "insert preprocessing: init WA
      CLEAR ZTCONST_H.
    ENDIF.
ZTCONST_H-MANDT =
ZVCONST_H-MANDT .
ZTCONST_H-SECTION_ID =
ZVCONST_H-SECTION_ID .
ZTCONST_H-CONST_ID =
ZVCONST_H-CONST_ID .
ZTCONST_H-LOGSYS =
ZVCONST_H-LOGSYS .
    IF SY-SUBRC = 0.
    UPDATE ZTCONST_H ##WARN_OK.
    ELSE.
    INSERT ZTCONST_H .
    ENDIF.
    SELECT SINGLE FOR UPDATE * FROM ZTCONST_HT WHERE
    SECTION_ID = ZTCONST_H-SECTION_ID AND
    CONST_ID = ZTCONST_H-CONST_ID AND
    LOGSYS = ZTCONST_H-LOGSYS AND
    LANGU = SY-LANGU .
      IF SY-SUBRC <> 0.   "insert preprocessing: init WA
        CLEAR ZTCONST_HT.
ZTCONST_HT-SECTION_ID =
ZTCONST_H-SECTION_ID .
ZTCONST_HT-CONST_ID =
ZTCONST_H-CONST_ID .
ZTCONST_HT-LOGSYS =
ZTCONST_H-LOGSYS .
ZTCONST_HT-LANGU =
SY-LANGU .
      ENDIF.
ZTCONST_HT-TEXT =
ZVCONST_H-TEXT .
    IF SY-SUBRC = 0.
    UPDATE ZTCONST_HT ##WARN_OK.
    ELSE.
    INSERT ZTCONST_HT .
    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_ZVCONST_H-UPD_FLAG,
STATUS_ZVCONST_H-UPD_CHECKD.
MESSAGE S018(SV).
ENDFORM.
*---------------------------------------------------------------------*
FORM READ_SINGLE_ENTRY_ZVCONST_H.
  SELECT SINGLE * FROM ZTCONST_H WHERE
SECTION_ID = ZVCONST_H-SECTION_ID AND
CONST_ID = ZVCONST_H-CONST_ID AND
LOGSYS = ZVCONST_H-LOGSYS .
ZVCONST_H-MANDT =
ZTCONST_H-MANDT .
ZVCONST_H-SECTION_ID =
ZTCONST_H-SECTION_ID .
ZVCONST_H-CONST_ID =
ZTCONST_H-CONST_ID .
ZVCONST_H-LOGSYS =
ZTCONST_H-LOGSYS .
    SELECT SINGLE * FROM ZTCONST_HT WHERE
SECTION_ID = ZTCONST_H-SECTION_ID AND
CONST_ID = ZTCONST_H-CONST_ID AND
LOGSYS = ZTCONST_H-LOGSYS AND
LANGU = SY-LANGU .
    IF SY-SUBRC EQ 0.
ZVCONST_H-TEXT =
ZTCONST_HT-TEXT .
    ELSE.
      CLEAR SY-SUBRC.
      CLEAR ZVCONST_H-TEXT .
    ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
FORM CORR_MAINT_ZVCONST_H 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 ZVCONST_H-SECTION_ID TO
ZTCONST_H-SECTION_ID .
MOVE ZVCONST_H-CONST_ID TO
ZTCONST_H-CONST_ID .
MOVE ZVCONST_H-LOGSYS TO
ZTCONST_H-LOGSYS .
MOVE ZVCONST_H-MANDT TO
ZTCONST_H-MANDT .
  CORR_KEYTAB             =  E071K.
  CORR_KEYTAB-OBJNAME     = 'ZTCONST_H'.
  IF NOT <vim_corr_keyx> IS ASSIGNED.
    ASSIGN CORR_KEYTAB-TABKEY TO <vim_corr_keyx> CASTING.
  ENDIF.
  ASSIGN ZTCONST_H TO <TAB_KEY_X> CASTING.
  PERFORM VIM_GET_TRSPKEYLEN
    USING 'ZTCONST_H'
    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.

MOVE ZTCONST_H-SECTION_ID TO
ZTCONST_HT-SECTION_ID .
MOVE ZTCONST_H-CONST_ID TO
ZTCONST_HT-CONST_ID .
MOVE ZTCONST_H-LOGSYS TO
ZTCONST_HT-LOGSYS .
MOVE SY-LANGU TO
ZTCONST_HT-LANGU .
MOVE ZVCONST_H-MANDT TO
ZTCONST_HT-MANDT .
  CORR_KEYTAB             =  E071K.
  CORR_KEYTAB-OBJNAME     = 'ZTCONST_HT'.
  IF NOT <vim_corr_keyx> IS ASSIGNED.
    ASSIGN CORR_KEYTAB-TABKEY TO <vim_corr_keyx> CASTING.
  ENDIF.
  ASSIGN ZTCONST_HT TO <TAB_KEY_X> CASTING.
  PERFORM VIM_GET_TRSPKEYLEN
    USING 'ZTCONST_HT'
    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.
*---------------------------------------------------------------------*
*...processing: ZVCONST_I.......................................*
FORM GET_DATA_ZVCONST_I.
  PERFORM VIM_FILL_WHERETAB.
*.read data from database.............................................*
  REFRESH TOTAL.
  CLEAR   TOTAL.
  SELECT * FROM ZTCONST_I WHERE
(VIM_WHERETAB) .
    CLEAR ZVCONST_I .
ZVCONST_I-MANDT =
ZTCONST_I-MANDT .
ZVCONST_I-SECTION_ID =
ZTCONST_I-SECTION_ID .
ZVCONST_I-CONST_ID =
ZTCONST_I-CONST_ID .
ZVCONST_I-LOGSYS =
ZTCONST_I-LOGSYS .
ZVCONST_I-VALUE =
ZTCONST_I-VALUE .
    SELECT SINGLE * FROM ZTCONST_IT WHERE
SECTION_ID = ZTCONST_I-SECTION_ID AND
CONST_ID = ZTCONST_I-CONST_ID AND
LOGSYS = ZTCONST_I-LOGSYS AND
VALUE = ZTCONST_I-VALUE AND
LANGU = SY-LANGU .
    IF SY-SUBRC EQ 0.
ZVCONST_I-TEXT =
ZTCONST_IT-TEXT .
    ENDIF.
<VIM_TOTAL_STRUC> = ZVCONST_I.
    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_ZVCONST_I .
*.process data base updates/inserts/deletes.........................*
LOOP AT TOTAL.
  CHECK <ACTION> NE ORIGINAL.
MOVE <VIM_TOTAL_STRUC> TO ZVCONST_I.
  IF <ACTION> = UPDATE_GELOESCHT.
    <ACTION> = GELOESCHT.
  ENDIF.
  CASE <ACTION>.
   WHEN NEUER_GELOESCHT.
IF STATUS_ZVCONST_I-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 ZTCONST_I WHERE
  SECTION_ID = ZVCONST_I-SECTION_ID AND
  CONST_ID = ZVCONST_I-CONST_ID AND
  LOGSYS = ZVCONST_I-LOGSYS AND
  VALUE = ZVCONST_I-VALUE .
    IF SY-SUBRC = 0.
    DELETE ZTCONST_I .
    ENDIF.
    DELETE FROM ZTCONST_IT WHERE
    SECTION_ID = ZTCONST_I-SECTION_ID AND
    CONST_ID = ZTCONST_I-CONST_ID AND
    LOGSYS = ZTCONST_I-LOGSYS AND
    VALUE = ZTCONST_I-VALUE .
    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 ZTCONST_I WHERE
  SECTION_ID = ZVCONST_I-SECTION_ID AND
  CONST_ID = ZVCONST_I-CONST_ID AND
  LOGSYS = ZVCONST_I-LOGSYS AND
  VALUE = ZVCONST_I-VALUE .
    IF SY-SUBRC <> 0.   "insert preprocessing: init WA
      CLEAR ZTCONST_I.
    ENDIF.
ZTCONST_I-MANDT =
ZVCONST_I-MANDT .
ZTCONST_I-SECTION_ID =
ZVCONST_I-SECTION_ID .
ZTCONST_I-CONST_ID =
ZVCONST_I-CONST_ID .
ZTCONST_I-LOGSYS =
ZVCONST_I-LOGSYS .
ZTCONST_I-VALUE =
ZVCONST_I-VALUE .
    IF SY-SUBRC = 0.
    UPDATE ZTCONST_I ##WARN_OK.
    ELSE.
    INSERT ZTCONST_I .
    ENDIF.
    SELECT SINGLE FOR UPDATE * FROM ZTCONST_IT WHERE
    SECTION_ID = ZTCONST_I-SECTION_ID AND
    CONST_ID = ZTCONST_I-CONST_ID AND
    LOGSYS = ZTCONST_I-LOGSYS AND
    VALUE = ZTCONST_I-VALUE AND
    LANGU = SY-LANGU .
      IF SY-SUBRC <> 0.   "insert preprocessing: init WA
        CLEAR ZTCONST_IT.
ZTCONST_IT-SECTION_ID =
ZTCONST_I-SECTION_ID .
ZTCONST_IT-CONST_ID =
ZTCONST_I-CONST_ID .
ZTCONST_IT-LOGSYS =
ZTCONST_I-LOGSYS .
ZTCONST_IT-VALUE =
ZTCONST_I-VALUE .
ZTCONST_IT-LANGU =
SY-LANGU .
      ENDIF.
ZTCONST_IT-TEXT =
ZVCONST_I-TEXT .
    IF SY-SUBRC = 0.
    UPDATE ZTCONST_IT ##WARN_OK.
    ELSE.
    INSERT ZTCONST_IT .
    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_ZVCONST_I-UPD_FLAG,
STATUS_ZVCONST_I-UPD_CHECKD.
MESSAGE S018(SV).
ENDFORM.
*---------------------------------------------------------------------*
FORM READ_SINGLE_ENTRY_ZVCONST_I.
  SELECT SINGLE * FROM ZTCONST_I WHERE
SECTION_ID = ZVCONST_I-SECTION_ID AND
CONST_ID = ZVCONST_I-CONST_ID AND
LOGSYS = ZVCONST_I-LOGSYS AND
VALUE = ZVCONST_I-VALUE .
ZVCONST_I-MANDT =
ZTCONST_I-MANDT .
ZVCONST_I-SECTION_ID =
ZTCONST_I-SECTION_ID .
ZVCONST_I-CONST_ID =
ZTCONST_I-CONST_ID .
ZVCONST_I-LOGSYS =
ZTCONST_I-LOGSYS .
ZVCONST_I-VALUE =
ZTCONST_I-VALUE .
    SELECT SINGLE * FROM ZTCONST_IT WHERE
SECTION_ID = ZTCONST_I-SECTION_ID AND
CONST_ID = ZTCONST_I-CONST_ID AND
LOGSYS = ZTCONST_I-LOGSYS AND
VALUE = ZTCONST_I-VALUE AND
LANGU = SY-LANGU .
    IF SY-SUBRC EQ 0.
ZVCONST_I-TEXT =
ZTCONST_IT-TEXT .
    ELSE.
      CLEAR SY-SUBRC.
      CLEAR ZVCONST_I-TEXT .
    ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
FORM CORR_MAINT_ZVCONST_I 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 ZVCONST_I-SECTION_ID TO
ZTCONST_I-SECTION_ID .
MOVE ZVCONST_I-CONST_ID TO
ZTCONST_I-CONST_ID .
MOVE ZVCONST_I-LOGSYS TO
ZTCONST_I-LOGSYS .
MOVE ZVCONST_I-VALUE TO
ZTCONST_I-VALUE .
MOVE ZVCONST_I-MANDT TO
ZTCONST_I-MANDT .
  CORR_KEYTAB             =  E071K.
  CORR_KEYTAB-OBJNAME     = 'ZTCONST_I'.
  IF NOT <vim_corr_keyx> IS ASSIGNED.
    ASSIGN CORR_KEYTAB-TABKEY TO <vim_corr_keyx> CASTING.
  ENDIF.
  ASSIGN ZTCONST_I TO <TAB_KEY_X> CASTING.
  PERFORM VIM_GET_TRSPKEYLEN
    USING 'ZTCONST_I'
    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.

MOVE ZTCONST_I-SECTION_ID TO
ZTCONST_IT-SECTION_ID .
MOVE ZTCONST_I-CONST_ID TO
ZTCONST_IT-CONST_ID .
MOVE ZTCONST_I-LOGSYS TO
ZTCONST_IT-LOGSYS .
MOVE ZTCONST_I-VALUE TO
ZTCONST_IT-VALUE .
MOVE SY-LANGU TO
ZTCONST_IT-LANGU .
MOVE ZVCONST_I-MANDT TO
ZTCONST_IT-MANDT .
  CORR_KEYTAB             =  E071K.
  CORR_KEYTAB-OBJNAME     = 'ZTCONST_IT'.
  IF NOT <vim_corr_keyx> IS ASSIGNED.
    ASSIGN CORR_KEYTAB-TABKEY TO <vim_corr_keyx> CASTING.
  ENDIF.
  ASSIGN ZTCONST_IT TO <TAB_KEY_X> CASTING.
  PERFORM VIM_GET_TRSPKEYLEN
    USING 'ZTCONST_IT'
    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.
*---------------------------------------------------------------------*
