/**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_CALDETAILENTRY' AND KSQL_COL_NAME ='FREQUIREOPERATOR') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FREQUIREOPERATOR BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FSUPPLYOPERATOR') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FSUPPLYOPERATOR BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PURFORECASTENTRY' AND KSQL_COL_NAME ='FISWARNNING') 
 ALTER TABLE T_MRP_PURFORECASTENTRY ADD (FISWARNNING CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PURFORECAST' AND KSQL_COL_NAME ='FWARNNING') 
 ALTER TABLE T_MRP_PURFORECAST ADD (FWARNNING DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_CALDETAILENTRY_E') 
 CREATE TABLE T_MRP_CALDETAILENTRY_E (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FPARENTBOMID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBOMID NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALCDETAIL' AND KSQL_COL_NAME ='FCREATETIME') 
 ALTER TABLE T_MRP_CALCDETAIL ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALCDETAIL' AND KSQL_COL_NAME ='FRUNTYPE') 
 ALTER TABLE T_MRP_CALCDETAIL ADD (FRUNTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PLANORDER' AND KSQL_COL_NAME ='FREMARK') 
 ALTER TABLE T_MRP_PLANORDER ADD (FREMARK NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PLANORDER' AND KSQL_COL_NAME ='DROPSTATUS') 
 ALTER TABLE T_MRP_PLANORDER ADD (DROPSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PLANORDER' AND KSQL_COL_NAME ='FORDERDATE') 
 ALTER TABLE T_MRP_PLANORDER ADD (FORDERDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PLANORDER' AND KSQL_COL_NAME ='FPLANTAG') 
 ALTER TABLE T_MRP_PLANORDER ADD (FPLANTAG NVARCHAR(60) DEFAULT ' ' NOT NULL );

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