/**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_PLANORDER' AND KSQL_COL_NAME ='FPLANOPERATENUM2') 
 ALTER TABLE T_MRP_PLANORDER ADD (FPLANOPERATENUM2 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_GDM_DEFINE_ENTRY') 
 CREATE TABLE T_MRP_GDM_DEFINE_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSETOFFSETTINGID BIGINT DEFAULT 0 NOT NULL,
FSETOFFTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSETOFFNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_GROSSDEMAND_DEFINE') 
 CREATE TABLE T_MRP_GROSSDEMAND_DEFINE (
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,
FCODETYPE BIGINT DEFAULT 0 NOT NULL,
FUSEORG BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_GROSSDEMAND_DEFINE_L') 
 CREATE TABLE T_MRP_GROSSDEMAND_DEFINE_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,
FMRPDEMANDTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_GROSSDEMAND_SOURCE') 
 CREATE TABLE T_MRP_GROSSDEMAND_SOURCE (
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,
FCACULATELOG BIGINT DEFAULT 0 NOT NULL,
FMATERIALCODE BIGINT DEFAULT 0 NOT NULL,
FMATERIALPARENTCODE BIGINT DEFAULT 0 NOT NULL,
FREQUIREMENTTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRODUCTMODEL BIGINT DEFAULT 0 NOT NULL,
FPBOM BIGINT DEFAULT 0 NOT NULL,
FMATERIALGROUP BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_GROSSDEMAND_SOURCE_L') 
 CREATE TABLE T_MRP_GROSSDEMAND_SOURCE_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PROSCHEDULE_ORDER') 
 CREATE TABLE T_MRP_PROSCHEDULE_ORDER (
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,
FMATERIELID BIGINT DEFAULT 0 NOT NULL,
FATTRIBUTE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(200) DEFAULT ' ' NOT NULL,
FORDERNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FPRODUCTYIELDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRODUCTYIELDNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBOM BIGINT DEFAULT 0 NOT NULL,
FBOMDATETIME DATETIME,
FECNVERSION BIGINT DEFAULT 0 NOT NULL,
FPLANNER BIGINT DEFAULT 0 NOT NULL,
FPLANPREPAREDATE DATETIME,
FPLANSTARTDATE DATETIME,
FPLANFINISHDATE DATETIME,
FAVAILABLEDATE DATETIME,
FSOURCEENTITY NVARCHAR(36) DEFAULT ' ' NOT NULL,
FPLANORDERBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPRODUCTIONORGID BIGINT DEFAULT 0 NOT NULL
);



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