IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_INVDETAIL') 
 CREATE TABLE T_MSPLAN_INVDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FCACULATELOG BIGINT DEFAULT 0 NOT NULL,
FMRPPLAN BIGINT DEFAULT 0 NOT NULL,
FCACULATENUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FRUNTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPLANTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANVALUE BIGINT DEFAULT 0 NOT NULL,
feventid NVARCHAR(300) DEFAULT ' ' NOT NULL,
fresolverip NVARCHAR(50) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_INVDETAILENTRY') 
 CREATE TABLE T_MSPLAN_INVDETAILENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FSUPPLYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FADJUSTSUGGEST NVARCHAR(50) DEFAULT ' ' NOT NULL,
FADJUSTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJUSTDATE DATETIME,
FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FSUPPLYBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FDEMANDDATE DATETIME,
FSUPPLYDATE DATETIME,
FMATERIALATTR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRACKNUMBER BIGINT DEFAULT 0 NOT NULL,
FCONFIGUREDCODE 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,
FEXCEPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FEXCEPTION_TAG NCLOB,
fsrcdemandqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
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 BIGINT DEFAULT 0 NOT NULL,
FEXCEPTIONNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FREQUIREORGID BIGINT DEFAULT 0 NOT NULL,
FREQPRIORITY NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPPRIORITY NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPMATERIAL BIGINT DEFAULT 0 NOT NULL,
FREQSOURCEBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPPLYDETAIL NVARCHAR(255) 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(255) DEFAULT ' ' NOT NULL,
FLLC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FREQUIREOPERATOR BIGINT DEFAULT 0 NOT NULL,
FSUPPLYOPERATOR BIGINT DEFAULT 0 NOT NULL,
FPARENTBOMID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBOMID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FEDITDATE DATETIME,
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(30) DEFAULT ' ' NOT NULL,
FEDITREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPLANTAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEVENTID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESOLVERIP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIGINDEMANDDATE DATETIME,
FSUPPLANTAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDSOURCETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL
);

