/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BASE_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_PROCESSSEQENTRY') 
 CREATE TABLE T_BD_PROCESSSEQENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPROCESSSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROCESSSEQNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROCESSSEQTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROCESSSEQREMARK NVARCHAR(510) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_PROSEQRELATION') 
 CREATE TABLE T_BD_PROSEQRELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSEQRELATIONSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSEQRELATIONNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSEQRELATIONPARSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSEQRELATIONPARNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRANSFERPROCESSNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRANSFERPROCESSNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTURNOUTPROCESSNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTURNOUTPROCESSNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARALLELRATION NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_ROUTER') 
 CREATE TABLE T_BD_ROUTER (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) 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,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FVERSIONID BIGINT DEFAULT 0 NOT NULL,
FROUTEREPLACE BIGINT DEFAULT 0 NOT NULL,
FISMAINPROCESS CHAR(1) DEFAULT '1' NOT NULL,
FPROCESSTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMATERIALGROUPID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FAUXPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FBOMVERSIONID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(510) DEFAULT ' ' NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITTIME DATETIME,
FCANCELERID BIGINT DEFAULT 0 NOT NULL,
FCANCELTIME DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_ROUTERACTENTRY') 
 CREATE TABLE T_BD_ROUTERACTENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPROCESSNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPERATIONNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPROCESSSTAGE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FACTIVITYID BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDARDFORMULAID BIGINT DEFAULT 0 NOT NULL,
FMINFORMULAID BIGINT DEFAULT 0 NOT NULL,
FSTANDARDFORMULA1ID BIGINT DEFAULT 0 NOT NULL,
FMINFORMULA1ID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_ROUTERPROCESSENTRY') 
 CREATE TABLE T_BD_ROUTERPROCESSENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPARENTID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPERATIONNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMACHININGTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODUCTIONORGID BIGINT DEFAULT 0 NOT NULL,
FWORKCENTERID BIGINT DEFAULT 0 NOT NULL,
FPURCHASEORGID BIGINT DEFAULT 0 NOT NULL,
FPRODUCTIONWORKSHOPID BIGINT DEFAULT 0 NOT NULL,
FOPERATIONID BIGINT DEFAULT 0 NOT NULL,
FOPRCTRLSTRATEGY BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(510) DEFAULT ' ' NOT NULL,
FUPPERRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFLOORRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEBATCHQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FHEADQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FHEADUNITID BIGINT DEFAULT 0 NOT NULL,
FOPERATIONQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOPERATIONUNITID BIGINT DEFAULT 0 NOT NULL,
FISSPLIT CHAR(1) DEFAULT ' ' NOT NULL,
FISPROCESSOVERLAP CHAR(1) DEFAULT ' ' NOT NULL,
FSPLITQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMINWORKTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTIMEUNIT NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMINOVERLAPTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOVERLAPTIMEUNIT NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOVERLAPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOVERLAPUNITID BIGINT DEFAULT 0 NOT NULL,
FPURCHASEGROUPID BIGINT DEFAULT 0 NOT NULL,
FPURCHASEPERSONID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYFIELD BIGINT DEFAULT 0 NOT NULL,
FTAXRATE BIGINT DEFAULT 0 NOT NULL,
FTAXPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSETTLEMENTUNITID BIGINT DEFAULT 0 NOT NULL,
FSETTLEMENTCOEFFICIENT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYMATERIALID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_ROUTERSUBENTRY') 
 CREATE TABLE T_BD_ROUTERSUBENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FRESOURCEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_BOMENTRY') 
 CREATE TABLE T_BD_BOMENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FVERSIONID BIGINT DEFAULT 0 NOT NULL,
FQTYTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FQTYNUMERATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYDENOMINATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFIXSCRAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVALIDDATE DATETIME,
FINVALIDDATE DATETIME,
FAUXPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FOWNERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_COSTBOM') 
 CREATE TABLE T_BD_COSTBOM (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FTYPEID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCTRLSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FVERSIONID BIGINT DEFAULT 0 NOT NULL,
FREPLACENOID BIGINT DEFAULT 0 NOT NULL,
FYIELDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAUXPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FISCOPRODUCT CHAR(1) DEFAULT '0' NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FDISABLEUSERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FENABLEUSERID BIGINT DEFAULT 0 NOT NULL,
FENABLEDATE DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_VICEBOMENTRY') 
 CREATE TABLE T_BD_VICEBOMENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FVERSIONID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOPERATIONID BIGINT DEFAULT 0 NOT NULL,
FVALIDDATE DATETIME,
FINVALIDDATE DATETIME,
FAUXPROPERTYID BIGINT DEFAULT 0 NOT NULL
);



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