/**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_FORECASTCAL') 
 CREATE TABLE T_MDS_FORECASTCAL (
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,
FFCALPLANID BIGINT DEFAULT 0 NOT NULL,
FPREDVERSION BIGINT DEFAULT 0 NOT NULL,
FCALCULATEPRO DECIMAL(23,8) DEFAULT 0 NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FSUMMIN DECIMAL(23,8) DEFAULT 0 NOT NULL,
FCALSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDAYSOFWEEK NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDAYSOFMON NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRUNNINGTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREPEATTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FLOSEDATE DATETIME,
FPREDTIME BIGINT DEFAULT 0 NOT NULL,
FREPEAT CHAR(1) DEFAULT '0' NOT NULL,
FJOBID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANID VARCHAR(50) DEFAULT ' ' NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FORECASTCALPLAN') 
 CREATE TABLE T_MDS_FORECASTCALPLAN (
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,
FPREDVERSION BIGINT DEFAULT 0 NOT NULL,
FSTYPE VARCHAR(5) DEFAULT ' ' NOT NULL,
FDTYPE BIGINT DEFAULT 0 NOT NULL,
FCHANGEWAY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTLOOKPERIOD BIGINT DEFAULT 0 NOT NULL,
FCALSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FFORECAST BIGINT DEFAULT 0 NOT NULL,
FSOURCETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMOD BIGINT DEFAULT 0 NOT NULL,
FRUNNINGLOG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRUNNINGLOG_TAG NVARCHAR(2000) DEFAULT ' ' NOT NULL
);


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



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