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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RSREGISTER' AND KSQL_COL_NAME ='FRELATIVERESOURCE') 
 ALTER TABLE T_MRP_RSREGISTER ADD (FRELATIVERESOURCE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RSREGISTER' AND KSQL_COL_NAME ='FRELATIVETRANSFER') 
 ALTER TABLE T_MRP_RSREGISTER ADD (FRELATIVETRANSFER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PLANPROENTRY' AND KSQL_COL_NAME ='FRESOURCEREGISTER') 
 ALTER TABLE T_MRP_PLANPROENTRY ADD (FRESOURCEREGISTER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PLANPROSCENTRY' AND KSQL_COL_NAME ='FRESOURCEREGISTERS') 
 ALTER TABLE T_MRP_PLANPROSCENTRY ADD (FRESOURCEREGISTERS BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CACULATELOG') 
 CREATE TABLE T_MRP_CACULATELOG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) 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,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPLANTYPE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPLANPROGAMID BIGINT DEFAULT 0 NOT NULL,
FOPERATMODE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISALLOWDATEINPAST CHAR(1) DEFAULT '0' NOT NULL,
FISTOFORMAL CHAR(1) DEFAULT '0' NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FSUMMIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCALCULATEPRO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCALCULATESTATUS NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPLANDATE DATETIME,
FISLLC CHAR(1) DEFAULT '0' NOT NULL,
FISBOMCHECK CHAR(1) DEFAULT '0' NOT NULL,
FRECALUTERESULT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBOMCHECKRESULT NVARCHAR(255) DEFAULT ' ' NOT NULL
);

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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CALPLANCONFIG')
 CREATE TABLE T_MRP_CALPLANCONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) 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,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CALPLANCONFIGENTRY')
 CREATE TABLE T_MRP_CALPLANCONFIGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRUNTYPE NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBIZPLAN BIGINT DEFAULT 0 NOT NULL
);


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