/**Begin D:\PDM_UPGRADE\PDM1\MRP_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_XPLANORDER') 
 CREATE TABLE T_MRP_XPLANORDER (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(60) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FAUDITDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FPROORPURORG BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FORDERTYPE NVARCHAR(60) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDROPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FYIELD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FENDPROQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBOM BIGINT DEFAULT 0 NOT NULL,
FUNFOLDBOMDATE DATETIME,
FECNVERSION BIGINT DEFAULT 0 NOT NULL,
FPLANPERSONID BIGINT DEFAULT 0 NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FAVAILABLEDATE DATETIME,
FDATASOURCE VARCHAR(60) DEFAULT ' ' NOT NULL,
FPLANPROGRAM BIGINT DEFAULT 0 NOT NULL,
FPLANOPERATENUM VARCHAR(100) DEFAULT ' ' NOT NULL,
FMATERIALATTR VARCHAR(60) DEFAULT ' ' NOT NULL,
FMATERIALPLANID BIGINT DEFAULT 0 NOT NULL,
FMATERIALLOCK CHAR(1) DEFAULT '0' NOT NULL,
FMATERIALSPREAD CHAR(1) DEFAULT '0' NOT NULL,
FREMARK NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDROPSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FORDERDATE DATETIME,
FPLANTAG NVARCHAR(60) DEFAULT ' ' NOT NULL,
FSURPLUSDROPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTHREESTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERMOQ DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDROPTIME DATETIME,
FADVISEDROPTIME DATETIME,
FCOMMENTREASON NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPLANOPERATENUM2 BIGINT DEFAULT 0 NOT NULL,
FSCHEDULE NVARCHAR(500) DEFAULT ' ' NOT NULL,
FAUXPROPERTY BIGINT DEFAULT 0 NOT NULL,
FSOURCENO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSOURCEID BIGINT DEFAULT 0 NOT NULL,
FCHANGETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCHANGEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHANGEDATE DATETIME,
FREASON NVARCHAR(512) DEFAULT ' ' NOT NULL,
FISSYSGEN CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_XPLANORDERENTRY') 
 CREATE TABLE T_MRP_XPLANORDERENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMODE VARCHAR(60) DEFAULT ' ' NOT NULL,
FTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FVERSIONID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTYTYPE VARCHAR(60) DEFAULT ' ' NOT NULL,
FQTYNUMERATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYDENOMINATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREQUIREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREQUIREDATE DATETIME,
FFIXSCRAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOSSQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYTYPE VARCHAR(60) DEFAULT ' ' NOT NULL,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FBOMID BIGINT DEFAULT 0 NOT NULL,
FBOMENTRYID BIGINT DEFAULT 0 NOT NULL,
FENTRYISREPLACE CHAR(1) DEFAULT '0' NOT NULL,
FENTRYREPLACESTRA NVARCHAR(30) DEFAULT ' ' NOT NULL,
FENTRYREPLACEMETHOD NVARCHAR(30) DEFAULT ' ' NOT NULL,
FENTRYREPLACEMATERIAL CHAR(1) DEFAULT '0' NOT NULL,
FENTRYREPLACEPRIORITY INT DEFAULT 0 NOT NULL,
FENTRYMATERIALPLANID BIGINT DEFAULT 0 NOT NULL,
FENTRYCREATER BIGINT DEFAULT 0 NOT NULL,
FENTRYCREATEDATE DATETIME,
FENTRYMODIFIER BIGINT DEFAULT 0 NOT NULL,
FENTRYMODIFYDATE DATETIME,
FENTRYREPMATERIALS NVARCHAR(512) DEFAULT ' ' NOT NULL,
FENTRYREPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYAUXPROPERTY BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_XPLANORDERCOPENTRY') 
 CREATE TABLE T_MRP_XPLANORDERCOPENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCOPENTRYMATERIAL BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYVERSION BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYUNIT BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOPENTRYALLQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOPENTRYOPERATION BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYVALIDDATE DATETIME,
FCOPENTRYINVALIDDATE DATETIME,
FCOPENTRYREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_XPLANORDERCOPENTRY_L') 
 CREATE TABLE T_MRP_XPLANORDERCOPENTRY_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCOPENTRYREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_XPLANORDERLOG') 
 CREATE TABLE T_MRP_XPLANORDERLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FAUDITDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FPROORPURORG BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FXBILLNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FXBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FCHANGESTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCHANGETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FXREASON NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_XPLANORDERLOGENTRY') 
 CREATE TABLE T_MRP_XPLANORDERLOGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQFIELD BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNOENTRY NVARCHAR(200) DEFAULT ' ' NOT NULL,
FCHANGEQTY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCHANGEDATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL
);



/**End D:\PDM_UPGRADE\PDM1\MRP_table.sql **/
