/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MSPLAN_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_ADJUSTENTRY') 
 CREATE TABLE T_MRP_CPS_ADJUSTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENTITYTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FADJUSTSTRATEGY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESULTTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL
);


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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_DETAILENTRY') 
 CREATE TABLE T_MRP_CPS_DETAILENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FTOPMATERIAL BIGINT DEFAULT 0 NOT NULL,
FFULLSETSTATUS NVARCHAR(50) DEFAULT ' ' 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_ORGENTRY') 
 CREATE TABLE T_MRP_CPS_ORGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDEMANDORG BIGINT DEFAULT 0 NOT NULL,
FINVSTRATEGY BIGINT DEFAULT 0 NOT NULL,
FSUPPLYNET BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_PLANPENTRY') 
 CREATE TABLE T_MRP_CPS_PLANPENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FTYPENAME BIGINT DEFAULT 0 NOT NULL,
FELEMENTNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FELEMENTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDEMANDENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDLOGO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDEMANDNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FFRUNCONDITION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFRUNCONDITION_TAG NCLOB,
FPENTRYFRUNCONDITIONDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENTRYCREATOR BIGINT DEFAULT 0 NOT NULL,
FENTRYCREATETIME DATETIME,
FENTRYMODIFIER BIGINT DEFAULT 0 NOT NULL,
FENTRYMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_PLANPRO') 
 CREATE TABLE T_MRP_CPS_PLANPRO (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX BIGINT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX BIGINT DEFAULT 0 NOT NULL,
FINVSUPPLYSTRATEGY BIGINT DEFAULT 0 NOT NULL,
FSUPPLYNET BIGINT DEFAULT 0 NOT NULL,
FISYIELD CHAR(1) DEFAULT '0' NOT NULL,
FISLOSSRATE CHAR(1) DEFAULT '0' NOT NULL,
FSAFESTOCKEFFECTSET NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISADJUST CHAR(1) DEFAULT '1' NOT NULL,
FISREPLACE CHAR(1) DEFAULT '0' NOT NULL,
FISRESERVE CHAR(1) DEFAULT '0' NOT NULL,
FDEMANDMODEL BIGINT DEFAULT 0 NOT NULL,
FAPPMODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMPUTEMODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTOFDATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDAY INT,
FSUPPLYMODEL BIGINT DEFAULT 0 NOT NULL,
FSCOUTOFDATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSCDAY INT,
FADJUSTEFFECTSET NVARCHAR(50) DEFAULT ' ' NOT NULL,
FALLOWLEADTIME INT,
FEARLYTOLER INT,
FALLOWDELAYTIME INT,
FDELAYTOLER INT,
FCONSIDERBATCHSTR CHAR(1) DEFAULT '0' NOT NULL,
FRELATIVETRANSFER BIGINT DEFAULT 0 NOT NULL,
FISSAFESTOCK CHAR(1) DEFAULT '0' NOT NULL,
FPLANTAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTOCKRESERVE CHAR(1) DEFAULT '0' NOT NULL,
FISCOMMON CHAR(1) DEFAULT '0' NOT NULL,
FISCUSTOMIZE CHAR(1) DEFAULT '0' NOT NULL,
FISSELECTION CHAR(1) DEFAULT '0' NOT NULL,
FISNOTSETUP CHAR(1) DEFAULT '0' NOT NULL,
FISCENTERWAREHOUSE CHAR(1) DEFAULT '0' NOT NULL,
FPLANOUTLOOK INT DEFAULT 0 NOT NULL,
FMRPSETUP BIGINT DEFAULT 0 NOT NULL,
FINVLEVEL BIGINT DEFAULT 0 NOT NULL,
FISMPS CHAR(1) DEFAULT '0' NOT NULL,
FISMRP CHAR(1) DEFAULT '0' NOT NULL,
FISREORDERPOINT CHAR(1) DEFAULT '0' NOT NULL,
FOUTOFRANGE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FHILOINV CHAR(1) DEFAULT '0' NOT NULL,
FTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISNEW CHAR(1) DEFAULT '0' NOT NULL,
FMULID BIGINT DEFAULT 0 NOT NULL,
FORGRANGID NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORGRANGID_TAG NCLOB,
FSELORGRANGID NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSELORGRANGID_TAG NCLOB,
FSTEPNUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISSIMULATION CHAR(1) DEFAULT '0' NOT NULL,
FCUSSAVE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCUSSAVE_TAG NCLOB,
FRELEASEMODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOCPWEAKRESERVE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FWIPBILLFIELDSID BIGINT DEFAULT 0 NOT NULL
);

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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_PLANPRODMENTRY') 
 CREATE TABLE T_MRP_CPS_PLANPRODMENTRY (
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FELEMENTNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FELEMENTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDEMANDENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDLOGO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDEMANDNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FTYPENAME BIGINT DEFAULT 0 NOT NULL,
FFRUNCONDITION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFRUNCONDITION_TAG NCLOB,
FFRUNCONDITIONDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_RENTRY') 
 CREATE TABLE T_MRP_CPS_RENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FISMRPOPERAT CHAR(1) DEFAULT '0' NOT NULL,
FDEMANDSRC NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESOURCEREGISTER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPS_SENTRY') 
 CREATE TABLE T_MRP_CPS_SENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FISSCMRPOPERAT CHAR(1) DEFAULT '0' NOT NULL,
FSUPPLYRES NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESOURCEREGISTERS BIGINT DEFAULT 0 NOT NULL,
FSUPPLYPRIORITY BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CPSPLAN_TAG') 
 CREATE TABLE T_MRP_CPSPLAN_TAG (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

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