CREATE VIEW tmsystem.DUAL AS SELECT CURRENT DATE AS AKTDAT, CONCAT(CONCAT(TRIM(CHAR(YEAR(BAKDTM))), SUBSTR(CONCAT('00', TRIM(CHAR(MONTH(BAKDTM))) 
 ), LENGTH(CONCAT('00', TRIM(CHAR(MONTH(BAKDTM))))) - 1, 2)), SUBSTR 
(CONCAT('00', TRIM(CHAR(DAY(BAKDTM)))), LENGTH(CONCAT('00', TRIM(CHAR (DAY(BAKDTM))))) - 1, 2)) AS YYYYMMDD, CONCAT(TRIM(CHAR(YEAR(BAKDTM))), SUBSTR(CONCAT('00', TRIM(CHAR(MONTH(BAKDTM)))),
 LENGTH(CONCAT('0                                                                     0', TRIM(CHAR(MONTH(BAKDTM))))) - 1, 2)) AS YYYYMM, CURRENT TIME AS AKTTIM, CONCAT(CONCAT(SUBSTR(CONCAT('00', TRIM(CHAR(HOUR(CURRENT TIME)))), LENGTH(CONCAT('00', TRIM(CHAR(HOUR(CURRENT TIME))))) - 1,  
2),':'), SUBSTR(CONCAT('00', TRIM(CHAR(MINUTE(CURRENT TIME)))), LENGTH( CONCAT('00', TRIM(CHAR(MINUTE(CURRENT TIME))))) - 1, 2)) AS HHMM FROM TMSYSTEM.TMS133BAK WHERE BAKDTM = CURRENT DATE                 
;
CREATE VIEW %SCHEMA%.DUAL AS SELECT CURRENT DATE AS AKTDAT, CONCAT(CONCAT(TRIM(CHAR(YEAR(BAKDTM))), SUBSTR(CONCAT('00', TRIM(CHAR(MONTH(BAKDTM))) 
 ), LENGTH(CONCAT('00', TRIM(CHAR(MONTH(BAKDTM))))) - 1, 2)), SUBSTR 
(CONCAT('00', TRIM(CHAR(DAY(BAKDTM)))), LENGTH(CONCAT('00', TRIM(CHAR (DAY(BAKDTM))))) - 1, 2)) AS YYYYMMDD, CONCAT(TRIM(CHAR(YEAR(BAKDTM))), SUBSTR(CONCAT('00', TRIM(CHAR(MONTH(BAKDTM)))),
 LENGTH(CONCAT('0                                                                     0', TRIM(CHAR(MONTH(BAKDTM))))) - 1, 2)) AS YYYYMM, CURRENT TIME AS AKTTIM, CONCAT(CONCAT(SUBSTR(CONCAT('00', TRIM(CHAR(HOUR(CURRENT TIME)))), LENGTH(CONCAT('00', TRIM(CHAR(HOUR(CURRENT TIME))))) - 1,  
2),':'), SUBSTR(CONCAT('00', TRIM(CHAR(MINUTE(CURRENT TIME)))), LENGTH( CONCAT('00', TRIM(CHAR(MINUTE(CURRENT TIME))))) - 1, 2)) AS HHMM FROM TMSYSTEM.TMS133BAK WHERE BAKDTM = CURRENT DATE                 
;
-- drop view TMSYSTEM.TMS800SBEDWH;
-- CREATE VIEW TMSYSTEM.TMS800SBEDWH ( 
-- SBEDWHNAM,SBEDWHLIZ,SBEDWHMND,SBEDWHFIR,SBEDWHTXT,SBEDWHKAT,
-- SBEDWHSTT,SBEDWHDAT,SBEDWHERF,SBEDWHSTA,SBEDWHSBE) 
-- AS SELECT DISTINCT DWHNAM, DWHLIZ, DWHMND, DWHFIR, DWHTXT,
--           DWHKAT, DWHSTT, DWHDAT, DWHERF, 1, DWHSBE
-- FROM TMSYSTEM.TMS800DWH A 
-- WHERE A.DWHSTT = 'A' 
-- AND DWHDAT = (
--     SELECT MAX(B.DWHDAT) 
--     FROM TMSYSTEM.TMS800DWH B 
--     WHERE A.DWHLIZ = B.DWHLIZ 
--     AND A.DWHMND = B.DWHMND 
--     AND A.DWHNAM = B.DWHNAM 
--     AND A.DWHKAT = B.DWHKAT
--     AND A.DWHSBE = B.DWHSBE
--     AND A.DWHSTT = B.DWHSTT);
-- 
-- CREATE VIEW TMSYSTEM.G2006LOGODNL (LDLLIZ, LDLMND, LDLNAM, LDLTYP, LDLDNM, LDLDTV, LDLDTB, LDLUZV, LDLUZB, LDLSTA, LDLDAT, LDLERF, LDLZAG, LDLTRM, LDLDLA) AS
--     SELECT DDLLIZ, DDLMND, DDLNAM, DDLTYP, DDLDNM||' '||TRDVER, DDLDTV, DDLDTB,
--            DDLUZV, DDLUZB, DDLSTA, DDLDAT, DDLERF,
--            DDLZAG, DDLTRM, DDLDLA
--     FROM   TMSYSTEM.G2006DATDNLLST, TMSYSTEM.O2006TRMDATEI
--     WHERE  DDLTYP = 2
--     AND    DDLDNM = TRDNAM
--     AND    DDLLIZ = TRDLIZ
--     AND    DDLMND = TRDMND;
-- 
-- 
-- CREATE VIEW TMSYSTEM.G2006NWSDNL (NDLLIZ, NDLMND, NDLNAM, NDLTYP, NDLDNM, NDLDTV, NDLDTB, NDLUZV, NDLUZB, NDLSTA, NDLDAT, NDLERF, NDLZAG, NDLTRM, NDLDLA) AS
--     SELECT DDLLIZ, DDLMND, DDLNAM, DDLTYP, DDLDNM||' '||TRDVER, DDLDTV, DDLDTB,
--            DDLUZV, DDLUZB, DDLSTA, DDLDAT, DDLERF,
--            DDLZAG, DDLTRM, DDLDLA
--     FROM   TMSYSTEM.G2006DATDNLLST, TMSYSTEM.O2006TRMDATEI
--     WHERE  DDLTYP = 6
--     AND    DDLDNM = TRDNAM
--     AND    DDLLIZ = TRDLIZ
--     AND    DDLMND = TRDMND;
-- 
-- 
-- CREATE VIEW TMSYSTEM.G2006PREDNL (PDLLIZ, PDLMND, PDLNAM, PDLTYP, PDLDNM, PDLDTV, PDLDTB, PDLUZV, PDLUZB, PDLSTA, PDLDAT, PDLERF, PDLZAG, PDLTRM, PDLDLA) AS
--     SELECT DDLLIZ, DDLMND, DDLNAM, DDLTYP, DDLDNM||' '||TRDVER, DDLDTV, DDLDTB,
--            DDLUZV, DDLUZB, DDLSTA, DDLDAT, DDLERF,
--            DDLZAG, DDLTRM, DDLDLA
--     FROM   TMSYSTEM.G2006DATDNLLST, TMSYSTEM.O2006TRMDATEI
--     WHERE  DDLTYP = 4
--     AND    DDLDNM = TRDNAM
--     AND    DDLLIZ = TRDLIZ
--     AND    DDLMND = TRDMND;
-- 
-- 
-- CREATE VIEW TMSYSTEM.G2006SCRDNL (SDLLIZ, SDLMND, SDLNAM, SDLTYP, SDLDNM, SDLDTV, SDLDTB, SDLUZV, SDLUZB, SDLSTA, SDLDAT, SDLERF, SDLZAG, SDLTRM, SDLDLA) AS
--     SELECT DDLLIZ, DDLMND, DDLNAM, DDLTYP, DDLDNM||' '||TRDVER, DDLDTV, DDLDTB,
--            DDLUZV, DDLUZB, DDLSTA, DDLDAT, DDLERF,
--            DDLZAG, DDLTRM, DDLDLA
--     FROM   TMSYSTEM.G2006DATDNLLST, TMSYSTEM.O2006TRMDATEI
--     WHERE  DDLTYP = 3
--     AND    DDLDNM = TRDNAM
--     AND    DDLLIZ = TRDLIZ
--     AND    DDLMND = TRDMND;
-- 
-- 
-- CREATE VIEW TMSYSTEM.G2006TKRDNL (TDLLIZ, TDLMND, TDLNAM, TDLTYP, TDLDNM, TDLDTV, TDLDTB, TDLUZV, TDLUZB, TDLSTA, TDLDAT, TDLERF, TDLZAG, TDLTRM, TDLDLA) AS
--     SELECT DDLLIZ, DDLMND, DDLNAM, DDLTYP, DDLDNM||' '||TRDVER, DDLDTV, DDLDTB,
--            DDLUZV, DDLUZB, DDLSTA, DDLDAT, DDLERF,
--            DDLZAG, DDLTRM, DDLDLA
--     FROM   TMSYSTEM.G2006DATDNLLST, TMSYSTEM.O2006TRMDATEI
--     WHERE  DDLTYP = 7
--     AND    DDLDNM = TRDNAM
--     AND    DDLLIZ = TRDLIZ
--     AND    DDLMND = TRDMND;
-- 
-- CREATE VIEW TMSYSTEM.G2006WLCDNL (WDLLIZ, WDLMND, WDLNAM, WDLTYP, WDLDNM, WDLDTV, WDLDTB, WDLUZV, WDLUZB, WDLSTA, WDLDAT, WDLERF, WDLZAG, WDLTRM, WDLDLA) AS
--     SELECT DDLLIZ, DDLMND, DDLNAM, DDLTYP, DDLDNM||' '||TRDVER, DDLDTV, DDLDTB,
--            DDLUZV, DDLUZB, DDLSTA, DDLDAT, DDLERF,
--            DDLZAG, DDLTRM, DDLDLA
--     FROM   TMSYSTEM.G2006DATDNLLST, TMSYSTEM.O2006TRMDATEI
--     WHERE  DDLTYP = 5
--     AND    DDLDNM = TRDNAM
--     AND    DDLLIZ = TRDLIZ
--     AND    DDLMND = TRDMND;
