/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ASSIGNED') 
 CREATE TABLE T_MDS_ASSIGNED (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) 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(50) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ASSIGNENTRY') 
 CREATE TABLE T_MDS_ASSIGNENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPERIOD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINTPERIOD BIGINT DEFAULT 0 NOT NULL,
FMOD DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FNREPORT') 
 CREATE TABLE T_MDS_FNREPORT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) 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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FOKDATE DATETIME,
FFINISHDATE DATETIME,
FFORDATE DATETIME,
FSETOFFDATE DATETIME,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSETOFFQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSETOFFVERID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FROWNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFORECASTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEPDDATE DATETIME,
FSALEORG BIGINT DEFAULT 0 NOT NULL,
FRPDDATE DATETIME,
FOUTSTOCKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERREMAINQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FSENDGOODSDATE DATETIME,
FTOOLID BIGINT DEFAULT 0 NOT NULL,
FSETID BIGINT DEFAULT 0 NOT NULL,
FORDERSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FPLANID BIGINT DEFAULT 0 NOT NULL,
FPLANENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROVIDERRECORD') 
 CREATE TABLE T_MDS_PROVIDERRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) 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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLROWNO BIGINT DEFAULT 0 NOT NULL,
FBSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATERIEL BIGINT DEFAULT 0 NOT NULL,
FBILLUNIT BIGINT DEFAULT 0 NOT NULL,
FTRANSFERID BIGINT DEFAULT 0 NOT NULL,
FBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FRECORDDATE DATETIME,
FSETID BIGINT DEFAULT 0 NOT NULL,
FTOOLID BIGINT DEFAULT 0 NOT NULL,
FSETOFFQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLTAG VARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLTYPENAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FBILLORG BIGINT DEFAULT 0 NOT NULL,
FFCVRNNUM BIGINT DEFAULT 0 NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_REQUESTRECORD') 
 CREATE TABLE T_MDS_REQUESTRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) 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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLROWNO BIGINT DEFAULT 0 NOT NULL,
FBSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATERIEL BIGINT DEFAULT 0 NOT NULL,
FBILLUNIT BIGINT DEFAULT 0 NOT NULL,
FTRANSFERID BIGINT DEFAULT 0 NOT NULL,
FRECORDDATE DATETIME,
FBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FBILLTAG VARCHAR(50) DEFAULT ' ' NOT NULL,
FBNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSETID BIGINT DEFAULT 0 NOT NULL,
FTOOLID BIGINT DEFAULT 0 NOT NULL,
FSETOFFQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FBILLORG BIGINT DEFAULT 0 NOT NULL,
FRPD DATETIME,
FEPD DATETIME,
FDELEVERYDATE DATETIME,
FACCOUTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSALEORDEROUTID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPENAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFLOG') 
 CREATE TABLE T_MDS_SETOFFLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) 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(50) DEFAULT ' ' NOT NULL,
FCALCULATEPRO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FSUMMIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPLANID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FJOBID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FEXECSTAT VARCHAR(5) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFLOGENTRY') 
 CREATE TABLE T_MDS_SETOFFLOGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSTEPSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTEPNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPROCESSDATA BIGINT DEFAULT 0 NOT NULL,
FOPERATMIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRESULT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDETAILMSG NVARCHAR(1000) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFLOGTOOL') 
 CREATE TABLE T_MDS_SETOFFLOGTOOL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSETOFFID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFSETENT') 
 CREATE TABLE T_MDS_SETOFFSETENT (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FXFDATAID BIGINT DEFAULT 0 NOT NULL,
FGFDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFSETENTG') 
 CREATE TABLE T_MDS_SETOFFSETENTG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPROVIDERSETID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFSETENTS') 
 CREATE TABLE T_MDS_SETOFFSETENTS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSALESETID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFSETTING') 
 CREATE TABLE T_MDS_SETOFFSETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) 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,
FPLANID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FJOBID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCTRLSTRATEGY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSETOFFORDERID BIGINT DEFAULT 0 NOT NULL,
FMOD BIGINT DEFAULT 0 NOT NULL,
FSFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSFILTER_TAG NCLOB,
FPFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPFILTER_TAG NCLOB
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFTOOL') 
 CREATE TABLE T_MDS_SETOFFTOOL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) 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(50) DEFAULT ' ' NOT NULL,
FPLUGIN NVARCHAR(255) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFTOOLENTRY') 
 CREATE TABLE T_MDS_SETOFFTOOLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSETID BIGINT DEFAULT 0 NOT NULL,
FISUSE CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PRODUCTFAMILY' AND KSQL_COL_NAME ='FOFFERINGSHOW') 
 ALTER TABLE T_MDS_PRODUCTFAMILY ADD (FOFFERINGSHOW NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PRODUCTFAMILY' AND KSQL_COL_NAME ='FPBOMNAMESHOW') 
 ALTER TABLE T_MDS_PRODUCTFAMILY ADD (FPBOMNAMESHOW NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PRODUCTFAMILY' AND KSQL_COL_NAME ='FITEMNAMESHOW') 
 ALTER TABLE T_MDS_PRODUCTFAMILY ADD (FITEMNAMESHOW NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PRODUCTFAMILY' AND KSQL_COL_NAME ='FCREATEORGID') 
 ALTER TABLE T_MDS_PRODUCTFAMILY ADD (FCREATEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PRODUCTFAMILY' AND KSQL_COL_NAME ='FORGID') 
 ALTER TABLE T_MDS_PRODUCTFAMILY ADD (FORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PRODUCTFAMILY' AND KSQL_COL_NAME ='FCTRLSTRATEGY') 
 ALTER TABLE T_MDS_PRODUCTFAMILY ADD (FCTRLSTRATEGY NVARCHAR(50) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_MDS_PLANEXEC', 'FDAYSOFMON', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SETOFFORDER') 
 CREATE TABLE T_MDS_SETOFFORDER (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) 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(50) DEFAULT ' ' NOT NULL,
FAHEADS BIGINT DEFAULT 0 NOT NULL,
FTAILS BIGINT DEFAULT 0 NOT NULL,
FORDERTYPE VARCHAR(5) DEFAULT ' ' NOT NULL,
FQTYPE VARCHAR(5) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DATEENTRY') 
 CREATE TABLE T_MDS_DATEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FFIELDKEY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDELIVERYCOLUMN CHAR(1) DEFAULT ' ' NOT NULL,
FTARGETDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSTABLEDATA') 
 CREATE TABLE T_MDS_DPSTABLEDATA (
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,
FLASTUPDATETIME DATETIME,
FUSER BIGINT DEFAULT 0 NOT NULL,
FPSPARTTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FISNO CHAR(1) DEFAULT ' ' NOT NULL,
FSUMMARYLINE VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYFIELD VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYFAMILY VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYSERIES VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYMODEL VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMMARYCOLOR VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPORTMODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FPSPARTNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FPPARTM VARCHAR(50) DEFAULT ' ' NOT NULL,
FMANUMODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIELMF BIGINT DEFAULT 0 NOT NULL,
FMATERIELDPS BIGINT DEFAULT 0 NOT NULL,
FORGDPSSITE BIGINT DEFAULT 0 NOT NULL,
FDPSSITENO VARCHAR(50) DEFAULT ' ' NOT NULL,
FDPSSITENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FPSPART BIGINT DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSTABLEDATA_R') 
 CREATE TABLE T_MDS_DPSTABLEDATA_R (
FID BIGINT DEFAULT 0 NOT NULL,
FPRESTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVASTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROFAULTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROCESS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBAREMARGIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKDELIVERED DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDSEND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISPLACEMENT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAITDISPLACE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPREDISPLACE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMONEGAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMTWODEMAND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMTWOPREDISPLACE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMTWOGAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKDELIVERY DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSVRDSSET') 
 CREATE TABLE T_MDS_DPSVRDSSET (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(80) 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(80) DEFAULT ' ' NOT NULL,
FVRDS BIGINT DEFAULT 0 NOT NULL,
FTRANSFER BIGINT DEFAULT 0 NOT NULL,
FSOPVRDS BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATATS') 
 CREATE TABLE T_MDS_FCDATATS (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLESTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FFCVRNNUM BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATATSENTRY') 
 CREATE TABLE T_MDS_FCDATATSENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FPRODORG BIGINT DEFAULT 0 NOT NULL,
FPLANGP BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FQTY1 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY2 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY3 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY4 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY5 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY6 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY7 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY8 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY9 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY10 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY11 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY12 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY13 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY14 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY15 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY16 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY17 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY18 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY19 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY20 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY21 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY22 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY23 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY24 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY25 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY26 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY27 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY28 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY29 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY30 DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATATSENTRY_A') 
 CREATE TABLE T_MDS_FCDATATSENTRY_A (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FQTY31 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY32 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY33 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY34 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY35 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY36 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY37 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY38 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY39 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY40 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY41 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY42 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY43 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY44 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY45 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY46 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY47 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY48 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY49 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY50 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY51 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY52 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY53 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY54 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY55 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY56 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY57 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY58 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY59 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY60 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY61 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY62 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY63 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY64 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY65 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY66 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY67 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY68 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY69 DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATATSENTRY_B') 
 CREATE TABLE T_MDS_FCDATATSENTRY_B (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FQTY70 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY71 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY72 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY73 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY74 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY75 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY76 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY77 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY78 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY79 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY80 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY81 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY82 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY83 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY84 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY85 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY86 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY87 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY88 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY89 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY90 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY91 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY92 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY93 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY94 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY95 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY96 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY97 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY98 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY99 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY100 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY101 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY102 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY103 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY104 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY105 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY106 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY107 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY108 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY109 DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATATSENTRY_C') 
 CREATE TABLE T_MDS_FCDATATSENTRY_C (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FQTY110 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY111 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY112 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY113 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY114 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY115 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY116 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY117 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY118 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY119 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY120 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY121 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY122 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY123 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY124 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY125 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY126 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY127 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY128 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY129 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY130 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY131 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY132 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY133 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY134 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY135 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY136 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY137 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY138 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY139 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY140 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY141 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY142 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY143 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY144 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY145 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY146 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY147 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY148 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY149 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY150 DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATATSENTRY_D') 
 CREATE TABLE T_MDS_FCDATATSENTRY_D (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FRECEIVE1 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE2 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE3 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE4 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE5 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE6 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE7 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE8 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE9 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVE10 DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_WEEKDPS') 
 CREATE TABLE T_MDS_WEEKDPS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIELWEEK BIGINT DEFAULT 0 NOT NULL,
FSUPORG BIGINT DEFAULT 0 NOT NULL,
FWEEKDATE DATETIME,
FWEEKPLAN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKDEMAND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWEEKRESULT DECIMAL(23,10) DEFAULT 0 NOT NULL
);



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