/**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_DEMANDPLAN') 
 CREATE TABLE T_MRP_DEMANDPLAN (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(60) 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(60) DEFAULT ' ' NOT NULL,
FDEMANDBILLTYPEID NVARCHAR(60) DEFAULT ' ' NOT NULL,
FDEMANDORG NVARCHAR(60) DEFAULT ' ' NOT NULL,
FDEMANDQTY NVARCHAR(60) DEFAULT ' ' NOT NULL,
FISSYSTEM NVARCHAR(60) DEFAULT ' ' NOT NULL,
FFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFILTER_TAG NCLOB,
FDEMANDORGNAME NVARCHAR(60) DEFAULT ' ' NOT NULL,
FDEMANDQTYNAME NVARCHAR(60) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_DEMANDPLAN_L') 
 CREATE TABLE T_MRP_DEMANDPLAN_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_DEMANDRECORD') 
 CREATE TABLE T_MRP_DEMANDRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(50) 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,
FDEMANDBILLTYPEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONSUMEORGID BIGINT DEFAULT 0 NOT NULL,
FCONSUMEBILLTYPEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONSUMEBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONSUMEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONSUMEENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROJECTNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRACKNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISDEMANDCLOSED NVARCHAR(60) DEFAULT ' ' NOT NULL,
FISHANDCLOSED NVARCHAR(60) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_DEMANDRECORD_L') 
 CREATE TABLE T_MRP_DEMANDRECORD_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_SUPPLYBILL_L') 
 CREATE TABLE T_MRP_SUPPLYBILL_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_SUPPLYORGTYPE_L') 
 CREATE TABLE T_MRP_SUPPLYORGTYPE_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_DEMANDPLANENTRY') 
 CREATE TABLE T_MRP_DEMANDPLANENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SUPPLYBILL') 
 CREATE TABLE T_MRP_SUPPLYBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYORG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYORGNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYQTY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYQTYNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDBILLTYPEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFILTER_TAG NCLOB,
FORGFIELD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SUPPLYBILLENTRY') 
 CREATE TABLE T_MRP_SUPPLYBILLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FINBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESERVEMATCHFLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SUPPLYORGTYPE') 
 CREATE TABLE T_MRP_SUPPLYORGTYPE (
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,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL
);



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