/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MRP_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY_E' AND KSQL_COL_NAME ='FEVENTID') 
 ALTER TABLE T_MRP_CALDETAILENTRY_E ADD (FEVENTID NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY_E' AND KSQL_COL_NAME ='FRESOLVERIP') 
 ALTER TABLE T_MRP_CALDETAILENTRY_E ADD (FRESOLVERIP NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_STOCK_FCTENTRY') 
 CREATE TABLE T_MRP_STOCK_FCTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPUBLISHSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPUBLISHER BIGINT DEFAULT 0 NOT NULL,
FPUBLISHTIME DATETIME,
FPUBLISHDATE DATETIME,
FFIRSTPUBLISHER BIGINT DEFAULT 0 NOT NULL,
FFIRSTPUBTIME DATETIME,
FSUPPLYMODEID BIGINT DEFAULT 0 NOT NULL,
FPLANNERID BIGINT DEFAULT 0 NOT NULL,
FPRODRENTID BIGINT DEFAULT 0 NOT NULL,
FPRODLINEID BIGINT DEFAULT 0 NOT NULL,
FPRODDOMAINID BIGINT DEFAULT 0 NOT NULL,
FOFFERINGID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FSHIPPEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARKS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLASTMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FLASTDATETIME DATETIME,
FABILITYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTHREEPRODQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSLUGGISHQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDATEQTY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDATEQTY_TAG NCLOB,
FONLYSERVICE NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_STOCK_FORECAST') 
 CREATE TABLE T_MRP_STOCK_FORECAST (
FID BIGINT DEFAULT 0 NOT NULL,
FPLANNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FALLDATE NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FWARESET NVARCHAR(30) DEFAULT ' ' NOT NULL,
FWARESET_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PEGINFODATA') 
 CREATE TABLE T_MRP_PEGINFODATA (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' 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
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PEGINFODATAENTRY') 
 CREATE TABLE T_MRP_PEGINFODATAENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FREQUIREORGID BIGINT DEFAULT 0 NOT NULL,
FREQUIREBILLTPYE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODUCTFAMILYID BIGINT DEFAULT 0 NOT NULL,
FPRODUCTMODELID BIGINT DEFAULT 0 NOT NULL,
FREQUIREMATERIALID BIGINT DEFAULT 0 NOT NULL,
FREQUIREOPERATORID BIGINT DEFAULT 0 NOT NULL,
FREQUIREBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREQBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREQUIREBILLSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREQUIREUNITID BIGINT DEFAULT 0 NOT NULL,
FREQUIREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREQUIREDATE DATETIME,
FREQUIREPRIORITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLTPYE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYMATERIALID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYOPERATORID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYUNIT BIGINT DEFAULT 0 NOT NULL,
FSUPPLYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYDATE DATETIME,
FACTUALDATE DATETIME,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYDETAIL NVARCHAR(50) DEFAULT ' ' NOT NULL
);



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