/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MRP_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_DATAVERSION') 
 CREATE TABLE T_MSPLAN_DATAVERSION (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDESC_TAG NCLOB,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_DV_DETAIL') 
 CREATE TABLE T_MSPLAN_DV_DETAIL (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FHISSTARTTIME DATETIME,
FHISFINISHTIME DATETIME,
FHISSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FHISSETTINGS BIGINT DEFAULT 0 NOT NULL,
FHISENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FHISFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FHISFILTER_TAG NCLOB,
FHISCOLS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FHISCOLS_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_DV_HISENTRY') 
 CREATE TABLE T_MSPLAN_DV_HISENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTARTDATETIME DATETIME,
FFINISHDATETIME DATETIME,
FSYNCSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXECUTOR BIGINT DEFAULT 0 NOT NULL,
FACTIVESTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUSERFIELD BIGINT DEFAULT 0 NOT NULL,
FDATETIMEFIELD DATETIME,
FSYNCLOG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSYNCLOG_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_DV_SYNCINFO') 
 CREATE TABLE T_MSPLAN_DV_SYNCINFO (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FLOGDETAIL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLOGDETAIL_TAG NCLOB,
FTEXTFIELD NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDATACOUNT INT DEFAULT 0 NOT NULL,
FSYNCENTITYTAG NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_SSENTRY') 
 CREATE TABLE T_MSPLAN_SSENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FFIELDNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISREF CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_SYNCSETTINGS') 
 CREATE TABLE T_MSPLAN_SYNCSETTINGS (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDESC_TAG NCLOB,
FFILTERVAL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFILTERVAL_TAG NCLOB,
FSRCTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDATASRC BIGINT DEFAULT 0 NOT NULL,
FENTITYMAPPING BIGINT DEFAULT 0 NOT NULL,
FMATERIALFIELD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL
);


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

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