/**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_MRP_BOMEXPAND') 
 CREATE TABLE T_MRP_BOMEXPAND (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_BOMEXPAND_L') 
 CREATE TABLE T_MRP_BOMEXPAND_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_MRP_BOMEXPANDENTRY') 
 CREATE TABLE T_MRP_BOMEXPANDENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPRODUCTIONORGUNITID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYORGUNITID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALATTR NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPLANSTRATEGY BIGINT DEFAULT 0 NOT NULL,
FISOLATEDRULE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBOMID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBOMENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBOMENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FBOMDATE DATETIME,
FBOMTYPE BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBALANCEPERIOD BIGINT DEFAULT 0 NOT NULL,
FBOMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPROJECTNUMBER BIGINT DEFAULT 0 NOT NULL,
FENDTRACKNUMBER BIGINT DEFAULT 0 NOT NULL,
FBEGINTRACKNUMBER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_DEMANDBILL_L') 
 CREATE TABLE T_MRP_DEMANDBILL_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_MRP_DEMANDBILLENTRY') 
 CREATE TABLE T_MRP_DEMANDBILLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPRODUCTIONORGUNITID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYORGUNITID BIGINT DEFAULT 0 NOT NULL,
FPURCHASEORGUNITID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALATTR NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPLANSTRATEGY BIGINT DEFAULT 0 NOT NULL,
FISOLATEDRULE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FBIZTYPE BIGINT DEFAULT 0 NOT NULL,
FDEMANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMPUTINGPERIOD BIGINT DEFAULT 0 NOT NULL,
FBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPRODUNIT BIGINT DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FPROJECTNUMBER BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBER BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_INH') 
 CREATE TABLE T_MRP_INH (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_INH_L') 
 CREATE TABLE T_MRP_INH_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_MRP_INHENTRY') 
 CREATE TABLE T_MRP_INHENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPRODUCTIONORGUNITID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYORGUNITID BIGINT DEFAULT 0 NOT NULL,
FPURCHASEORGUNITID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALATTR NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPLANSTRATEGY BIGINT DEFAULT 0 NOT NULL,
FISOLATEDRULE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLDATE DATETIME,
FBILLID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLENTRYID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FBIZTYPE BIGINT DEFAULT 0 NOT NULL,
FUSABLESTOQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMPUTINGPERIOD BIGINT DEFAULT 0 NOT NULL,
FBILLNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPRODUNIT BIGINT DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FPROJECTNUMBER BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBER BIGINT DEFAULT 0 NOT NULL
);

 --- drop column --------- 不允许删除表T_MRP_PLANPRODMENTRY的字段FID，请恢复pdm中的字段 ------------------- 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_DEMANDBILL') 
 CREATE TABLE T_MRP_DEMANDBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);



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