/**Begin D:\PDM_UPGRADE\PDM1\MSPLAN_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_PLANSCOPE_WHS') 
 CREATE TABLE T_MSPLAN_PLANSCOPE_WHS (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(20) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(20) 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(30) DEFAULT ' ' NOT NULL,
FEFFECTUATE_TYPE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(155) DEFAULT ' ' NOT NULL,
FWAREHOUSE BIGINT DEFAULT 0 NOT NULL,
FPLANSCOPE BIGINT DEFAULT 0 NOT NULL,
FINVORG BIGINT DEFAULT 0 NOT NULL,
FINV_SUPPLY_STRATEGY BIGINT DEFAULT 0 NOT NULL,
FIS_ININV_WHS CHAR(1) DEFAULT '0' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_PLANSCOPE') 
 CREATE TABLE T_MSPLAN_PLANSCOPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(20) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(20) 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(30) DEFAULT ' ' NOT NULL,
FTYPE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(155) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_MATPLASCO') 
 CREATE TABLE T_MSPLAN_MATPLASCO (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(20) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(20) 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(30) DEFAULT ' ' NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(155) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_MATPLASCO_ENTRY') 
 CREATE TABLE T_MSPLAN_MATPLASCO_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPLANSCOPE BIGINT DEFAULT 0 NOT NULL,
FINTER_ASSIST_MODE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FSUPPLIER_ORG BIGINT DEFAULT 0 NOT NULL,
FINTER_ASSIST_ORG BIGINT DEFAULT 0 NOT NULL,
FSUPPLIER_WAREHOUSE BIGINT DEFAULT 0 NOT NULL,
FSUPPLIER_SHIPPING BIGINT DEFAULT 0 NOT NULL,
FIN_STORAGE_SHIPPING BIGINT DEFAULT 0 NOT NULL,
FIN_STORAGE_ORG BIGINT DEFAULT 0 NOT NULL,
FIN_STORAGE_WAREHOUSE BIGINT DEFAULT 0 NOT NULL,
FPLANTYPE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FOPERATOR BIGINT DEFAULT 0 NOT NULL,
FREORDER DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FECOBATCH DECIMAL(23,10) DEFAULT 0 NOT NULL
);



/**End D:\PDM_UPGRADE\PDM1\MSPLAN_table.sql **/
