/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_WEEKROLL_L') 
 CREATE TABLE T_MDS_WEEKROLL_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_WEEKROLLENTA') 
 CREATE TABLE T_MDS_WEEKROLLENTA (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSETID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_WEEKROLLENTB') 
 CREATE TABLE T_MDS_WEEKROLLENTB (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FVERID BIGINT DEFAULT 0 NOT NULL
);

IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATADTLENTBK') 
drop table T_MDS_FCDATADTLENTBK;

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATADTLENTBK') 
 CREATE TABLE T_MDS_FCDATADTLENTBK (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FCYCLETYPED NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDATENODE DATETIME,
FFCQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOWQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYSRC NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANGP BIGINT DEFAULT 0 NOT NULL,
FWRITEOFFNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRODORG BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(500) DEFAULT ' ' NOT NULL,
FVERID BIGINT DEFAULT 0 NOT NULL,
FWEEKROLLID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_WEEKROLLLOG') 
 CREATE TABLE T_MDS_WEEKROLLLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSTEPSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTEPNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROCESSDATA BIGINT DEFAULT 0 NOT NULL,
FOPERATMIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRESULT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDETAILMSG NVARCHAR(1000) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_WEEKROLL') 
 CREATE TABLE T_MDS_WEEKROLL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(100) 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,
FACCSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXECSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FSTIME DATETIME,
FETIME DATETIME,
FSETVAL NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCALCULATEPRO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUMMIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FJOBID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANID VARCHAR(50) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_EXECTASKX') 
 CREATE TABLE T_MDS_EXECTASKX (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FTEXTRES VARCHAR(2000) DEFAULT ' ' NOT NULL,
FDBROUTE VARCHAR(50) DEFAULT ' ' NOT NULL
);

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDS_table.sql **/
