/**Begin D:\k3Cloud\PDM_UPGRADE\PDM1\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSPLANMATERIAL') 
 CREATE TABLE T_MDS_DPSPLANMATERIAL (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSPLANMATERIALORG') 
 CREATE TABLE T_MDS_DPSPLANMATERIALORG (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSRUNLOG') 
 CREATE TABLE T_MDS_DPSRUNLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FDPSARRANGESETID BIGINT DEFAULT 0 NOT NULL,
FCALSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FSTARTTIME DATETIME,
FENDTIME DATETIME,
FERRORMESSAGE NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FSUMTIME DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSRUNLOG_L') 
 CREATE TABLE T_MDS_DPSRUNLOG_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSTABLE') 
 CREATE TABLE T_MDS_DPSTABLE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) DEFAULT '0' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FLASTUPDATETIME DATETIME,
FUSER BIGINT DEFAULT 0 NOT NULL,
FPSPARTTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISNO CHAR(1) DEFAULT '0' NOT NULL,
FSUMMARYLINE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYFIELD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYFAMILY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYSERIES NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYMODEL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYCOLOR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPORTMODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPSPARTNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPPARTM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMANUMODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIELMF BIGINT DEFAULT 0 NOT NULL,
FMATERIELDPS BIGINT DEFAULT 0 NOT NULL,
FORGDPSSITE BIGINT DEFAULT 0 NOT NULL,
FDPSSITENO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDPSSITENAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPSPART BIGINT DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FMITEM BIGINT DEFAULT 0 NOT NULL,
FOPENPRODUCTFAMILY CHAR(1) DEFAULT '0' NOT NULL,
FPBOM BIGINT DEFAULT 0 NOT NULL,
FDPSARRANGESET BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSTABLE_A') 
 CREATE TABLE T_MDS_DPSTABLE_A (
FID BIGINT DEFAULT 0 NOT NULL,
FWEEKDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRESTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVASTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROFAULTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROCESS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBAREMARGIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKDELIVERED DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDSEND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISPLACEMENT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAITDISPLACE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPREDISPLACE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMONEGAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMTWODEMAND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMTWOPREDISPLACE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMTWOUSE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMTWOGAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSAFESTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKPLANGAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKRESULTGAP DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSTABLE_L') 
 CREATE TABLE T_MDS_DPSTABLE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSTABLEMBOM') 
 CREATE TABLE T_MDS_DPSTABLEMBOM (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSWEEK') 
 CREATE TABLE T_MDS_DPSWEEK (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIELWEEK BIGINT DEFAULT 0 NOT NULL,
FSUPORG BIGINT DEFAULT 0 NOT NULL,
FWEEKDATE DATETIME,
FWEEKPLAN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKDEMAND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKRESULT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMBOMMATERIAL BIGINT DEFAULT 0 NOT NULL
);



/**End D:\k3Cloud\PDM_UPGRADE\PDM1\MDS_table.sql **/
