/**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_BILLFIELDTRANSFER') 
 CREATE TABLE T_MRP_BILLFIELDTRANSFER (
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,
FCTRLSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSRCBILL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSRCBILLENTITY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDESTBILL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDESTENTITY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTRATEGYCLASS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISSYSTEMINSERT CHAR(1) DEFAULT '0' NOT NULL,
FLARGETEXTFIELD NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLARGETEXTFIELD_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_BILLFIELDTRANSFER_L') 
 CREATE TABLE T_MRP_BILLFIELDTRANSFER_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_BILLTRANFERENTRY') 
 CREATE TABLE T_MRP_BILLTRANFERENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSOURCEENTITYFLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEFIELDFLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESTENTITYFLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESTFIELDFLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESTFIELDNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_INDEXCONFIG') 
 CREATE TABLE T_MRP_INDEXCONFIG (
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,
FISUNIQUE CHAR(1) DEFAULT '0' NOT NULL,
FINDEXFIELD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESOURCENUM BIGINT DEFAULT 0 NOT NULL,
FINDEX NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_INDEXCONFIG_L') 
 CREATE TABLE T_MRP_INDEXCONFIG_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_MATERIALSETUP') 
 CREATE TABLE T_MRP_MATERIALSETUP (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPARENTENTRYID BIGINT DEFAULT 0 NOT NULL,
FMATERIELID BIGINT DEFAULT 0 NOT NULL,
FMATERIALORGID BIGINT DEFAULT 0 NOT NULL,
FSTOCKID BIGINT DEFAULT 0 NOT NULL,
FSTOCKINDEXID BIGINT DEFAULT 0 NOT NULL,
FPRIORITY BIGINT DEFAULT 0 NOT NULL,
FSTOCKRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPARENTBASEDATAFIELD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_RESOUCEREGISSTER_L') 
 CREATE TABLE T_MRP_RESOUCEREGISSTER_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_RESOURCEREGISTER') 
 CREATE TABLE T_MRP_RESOURCEREGISTER (
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,
FBUSINESSENTITY NVARCHAR(36) DEFAULT ' ' NOT NULL,
FTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDATABASENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_RSDATACONFIG') 
 CREATE TABLE T_MRP_RSDATACONFIG (
FID BIGINT DEFAULT 0 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,
FTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISSYSTEMDESIGN CHAR(1) DEFAULT '0' NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCGNUMBER BIGINT DEFAULT 0 NOT NULL,
FBILLFIELDTRANSFERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_RSDATACONFIG_L') 
 CREATE TABLE T_MRP_RSDATACONFIG_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_RSREGISTERENTRY') 
 CREATE TABLE T_MRP_RSREGISTERENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBIZDATATYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSIGNID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSIGNNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDATATYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEFAULTVALUE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCTYPE NVARCHAR(36) DEFAULT ' ' NOT NULL,
FFORMULADESC NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_STOCKSETUP') 
 CREATE TABLE T_MRP_STOCKSETUP (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSTOCKNUMBERID BIGINT DEFAULT 0 NOT NULL,
FSTOCKINDEXID BIGINT DEFAULT 0 NOT NULL,
FSTORAGEADDRESS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRIORITY BIGINT DEFAULT 0 NOT NULL,
FSTOCKORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_STOCKSORGENTRY') 
 CREATE TABLE T_MRP_STOCKSORGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSTORAGEORGID BIGINT DEFAULT 0 NOT NULL,
FINTEGERFIELD BIGINT DEFAULT 0 NOT NULL,
FDECIMALFIELD DECIMAL(23,10) DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_STOCKSUPPLY_L') 
 CREATE TABLE T_MRP_STOCKSUPPLY_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_STOCKTYPEENTRY') 
 CREATE TABLE T_MRP_STOCKTYPEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSTOCKTYPEID BIGINT DEFAULT 0 NOT NULL,
FISMRP CHAR(1) DEFAULT '0' NOT NULL
);





IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_DEFINITIONSUPPLY') 
 CREATE TABLE T_MRP_DEFINITIONSUPPLY (
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
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_DEFINITIONSUPPLY_L') 
 CREATE TABLE T_MRP_DEFINITIONSUPPLY_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_STOCKSTATUS') 
 CREATE TABLE T_MRP_STOCKSTATUS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FISMRP CHAR(1) DEFAULT '0' NOT NULL,
FSTOCKTYPEID BIGINT DEFAULT 0 NOT NULL
);



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