/**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_CPS_DETAILENTRY' AND KSQL_COL_NAME ='FFULLSETSTATUS') 
 ALTER TABLE T_MRP_CPS_DETAILENTRY ADD (FFULLSETSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL );
 --- drop column --------- 不允许删除表T_MRP_CPS_DETAILENTRY的字段FULLSETSTATUS，请恢复pdm中的字段 ------------------- 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_SHORT_DETAIL') 
 CREATE TABLE T_MRP_CPS_SHORT_DETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FMATERIALATTR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSRCDEMANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREQUIREORGID BIGINT DEFAULT 0 NOT NULL,
FDEMANDBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDBILLF7 NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDDATE DATETIME,
FBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FEXCEPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FEXCEPTION_TAG NCLOB,
FEXCEPTIONNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLF7 NVARCHAR(36) DEFAULT ' ' NOT NULL,
FSUPPLYBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYDATE DATETIME,
FSUPPLYBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FADJUSTSUGGEST NVARCHAR(50) DEFAULT ' ' NOT NULL,
FADJUSTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJUSTDATE DATETIME,
FISMERGE CHAR(1) DEFAULT '0' NOT NULL,
FMERGEBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMERGEBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMERGEBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMERGEBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FISHANDLE CHAR(1) DEFAULT '0' NOT NULL,
FBOMVERSION BIGINT DEFAULT 0 NOT NULL,
FREQPRIORITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPRIORITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPMATERIAL BIGINT DEFAULT 0 NOT NULL,
FREQSOURCEBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPPLYDETAIL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSEXPMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSEXPNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FINVPRIORITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FLLC NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREQUIREOPERATOR BIGINT DEFAULT 0 NOT NULL,
FSUPPLYOPERATOR BIGINT DEFAULT 0 NOT NULL,
FPARENTBOMID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBOMID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEDITDATE DATETIME,
FEDITREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FYIELDRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDYNAMICSCRAPRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFIXSCRAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDYNAMICSCRAPFORMULA NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANTAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLANTAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEVENTID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESOLVERIP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIGINDEMANDDATE DATETIME,
FDEMANDSOURCETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBER BIGINT DEFAULT 0 NOT NULL,
FSUPTRACKNUMBER BIGINT DEFAULT 0 NOT NULL,
FDEMANDSTORAGE BIGINT DEFAULT 0 NOT NULL,
FSUPPLYSTORAGE BIGINT DEFAULT 0 NOT NULL,
FDEMANDAUXPTY BIGINT DEFAULT 0 NOT NULL,
FSUPPLYAUXPTY BIGINT DEFAULT 0 NOT NULL,
FORIGINSUPPLYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYPROJECT BIGINT DEFAULT 0 NOT NULL,
FDEMANDPROJECT BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_SHORTAGE') 
 CREATE TABLE T_MRP_CPS_SHORTAGE (
FID BIGINT DEFAULT 0 NOT NULL,
FCACULATENUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANVALUE BIGINT DEFAULT 0 NOT NULL,
FMRPPLAN BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FRUNTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL
);



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