/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MRP_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMCOLORDER') 
 CREATE TABLE T_MRP_SIMCOLORDER (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) 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,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FMATERIELID BIGINT DEFAULT 0 NOT NULL,
FDEMANDDATE DATETIME,
FDATASOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANPROGRAM BIGINT DEFAULT 0 NOT NULL,
FPLANOPERATENUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBOMVERSION BIGINT DEFAULT 0 NOT NULL,
FDEMANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FMATERIALPLANID BIGINT DEFAULT 0 NOT NULL,
FPLANTAGS BIGINT DEFAULT 0 NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBER BIGINT DEFAULT 0 NOT NULL,
FAUXPROPERTY BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMULATEORDER') 
 CREATE TABLE T_MRP_SIMULATEORDER (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) 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,
FORDERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROORPURORG BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDROPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FYIELD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENDPROQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBOM BIGINT DEFAULT 0 NOT NULL,
FUNFOLDBOMDATE DATETIME,
FPLANPERSONID BIGINT DEFAULT 0 NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FAVAILABLEDATE DATETIME,
FDATASOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANPROGRAM BIGINT DEFAULT 0 NOT NULL,
FPLANOPERATENUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIALATTR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIALLOCK CHAR(1) DEFAULT '0' NOT NULL,
FMATERIALSPREAD CHAR(1) DEFAULT '0' NOT NULL,
FMATERIALPLANID BIGINT DEFAULT 0 NOT NULL,
FDROPSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERDATE DATETIME,
FPLANTAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSURPLUSDROPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMMENTREASON NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTHREESTOCK DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERMOQ DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADVISEDROPTIME DATETIME,
FPLANOPERATENUM2 BIGINT DEFAULT 0 NOT NULL,
FDROPTIME DATETIME,
FSCHEDULE NVARCHAR(500) DEFAULT ' ' NOT NULL,
FPLANTAGS BIGINT DEFAULT 0 NOT NULL,
FDEMANDBILL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDSEQ BIGINT DEFAULT 0 NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FISHISTORY CHAR(1) DEFAULT '0' NOT NULL,
FHISTORYDATE DATETIME,
FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBER BIGINT DEFAULT 0 NOT NULL,
FAUXPROPERTY BIGINT DEFAULT 0 NOT NULL,
FDEMANDBILLENTITY NVARCHAR(36) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMULATEORDERCENTRY') 
 CREATE TABLE T_MRP_SIMULATEORDERCENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCOPENTRYTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOPENTRYMATERIAL BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYVERSION BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYUNIT BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOPENTRYALLQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOPENTRYOPERATION BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYVALIDDATE DATETIME,
FCOPENTRYINVALIDDATE DATETIME,
FCOPENTRYAUXPROPERTY BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMULATIONOUTLINE') 
 CREATE TABLE T_MRP_SIMULATIONOUTLINE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSOURCETYPE CHAR(1) DEFAULT 'B' NOT NULL,
FREQUIREORGID BIGINT DEFAULT 0 NOT NULL,
FBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FROWNO INT DEFAULT 0 NOT NULL,
FCUSTOMERID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREQUIREDATE DATETIME,
FDELIVERYDATE DATETIME,
FPROMISEDATE DATETIME,
FINVQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBERID BIGINT DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FSTOCKORGID BIGINT DEFAULT 0 NOT NULL,
FOPERATORID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMULATIONSUMMARY') 
 CREATE TABLE T_MRP_SIMULATIONSUMMARY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBERID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALARR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSAFETYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEPENDENTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREPLACEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANUSEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRENTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREPLACEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPLANQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPLANCURRENTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLCOUNT INT DEFAULT 0 NOT NULL,
FFINISHQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJUSTSUGGEST NVARCHAR(50) DEFAULT ' ' NOT NULL,
FALLQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAYCANQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAYCURRENTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMULATION') 
 CREATE TABLE T_MRP_SIMULATION (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) 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,
FPLANID BIGINT DEFAULT 0 NOT NULL,
FABCTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRETENTIONDAYS INT DEFAULT 0 NOT NULL,
FRUNLOGID BIGINT DEFAULT 0 NOT NULL,
FSIMULATIONUSERID BIGINT DEFAULT 0 NOT NULL,
FSIMULATIONSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FCLOSESTATUS CHAR(1) DEFAULT 'B' NOT NULL,
FREMARKS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCLOSEUSERID BIGINT DEFAULT 0 NOT NULL,
FCLOSEDATE DATETIME,
FSIMULATIONDATE DATETIME,
FENDDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FISLLC CHAR(1) DEFAULT '0' NOT NULL,
FISBOMCHECK CHAR(1) DEFAULT '0' NOT NULL,
FISALLOWDATEINPAST CHAR(1) DEFAULT '1' NOT NULL,
FDATAVERSIONID BIGINT DEFAULT 0 NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMULATEORDERENTRY') 
 CREATE TABLE T_MRP_SIMULATEORDERENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FVERSIONID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTYTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FQTYNUMERATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYDENOMINATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREQUIREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREQUIREDATE DATETIME,
FFIXSCRAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOSSQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FBOMID BIGINT DEFAULT 0 NOT NULL,
FBOMENTRYID BIGINT DEFAULT 0 NOT NULL,
FENTRYREPLACESTRA NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYREPLACEMETHOD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYREPLACEPRIORITY BIGINT DEFAULT 0 NOT NULL,
FENTRYISREPLACE CHAR(1) DEFAULT '0' NOT NULL,
FENTRYREPLACEMATERIAL CHAR(1) DEFAULT '0' NOT NULL,
FENTRYMATERIALPLANID BIGINT DEFAULT 0 NOT NULL,
FENTRYREPLACEPLAN BIGINT DEFAULT 0 NOT NULL,
FENTRYREPMATERIALS NVARCHAR(510) DEFAULT ' ' NOT NULL,
FENTRYREPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLEADTIME INT DEFAULT 0 NOT NULL,
FWASTAGERATEFORMULA NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL,
FENTRYDROPREQUIREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYAUXPROPERTY BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMULATIONDETAIL') 
 CREATE TABLE T_MRP_SIMULATIONDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPARENTENTRYID BIGINT DEFAULT 0 NOT NULL,
FLEVEL BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALARR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FROWNO INT DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBERID BIGINT DEFAULT 0 NOT NULL,
FISREPLACE CHAR(1) DEFAULT '0' NOT NULL,
FPROMISEDATE DATETIME,
FBEGINDATE DATETIME,
FFINISHDATE DATETIME,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FREQUIREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYQTY DECIMAL(23,10) DEFAULT 0 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
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_SIMULATEFIELDENTRY') 
 CREATE TABLE T_MRP_SIMULATEFIELDENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FFIELDKEY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);



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