/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MRP_table.sql **/
 EXEC p_AlterColumn 'T_MRP_PLANDISPATCH', 'FREQPLANNUMBER', 'NVARCHAR(2000)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_MRP_PLANDISPATCH', 'FREQPLANNAME', 'NVARCHAR(2000)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_MRP_PLANDISPATCH', 'FREQPLANID', 'NVARCHAR(2000)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_MRP_PLANDISPATCH', 'FREQPLANLOG1', 'NVARCHAR(2000)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_MRP_PLANDISPATCH', 'FFORECASTNO', 'NVARCHAR(2000)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY_E' AND KSQL_COL_NAME ='FDEMANDSOURCETYPE') 
 ALTER TABLE T_MRP_CALDETAILENTRY_E ADD (FDEMANDSOURCETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PEGINFODATAENTRY' AND KSQL_COL_NAME ='FSUPPLANTAG') 
 ALTER TABLE T_MRP_PEGINFODATAENTRY ADD (FSUPPLANTAG NVARCHAR(60) DEFAULT 'D' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FPARENTBOMID') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FPARENTBOMID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FBOMID') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FBOMID NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FEDITDATE') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FEDITDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FYIELDRATIO') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FYIELDRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FSCRAPRATIO') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FSCRAPRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FDYNAMICSCRAPRATIO') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FDYNAMICSCRAPRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FFIXSCRAP') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FFIXSCRAP DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FDYNAMICSCRAPFORMULA') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FDYNAMICSCRAPFORMULA NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FEDITREASON') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FEDITREASON NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FPLANTAG') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FPLANTAG NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FEVENTID') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FEVENTID NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FRESOLVERIP') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FRESOLVERIP NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FORIGINDEMANDDATE') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FORIGINDEMANDDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FSUPPLANTAG') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FSUPPLANTAG NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_CALDETAILENTRY' AND KSQL_COL_NAME ='FDEMANDSOURCETYPE') 
 ALTER TABLE T_MRP_CALDETAILENTRY ADD (FDEMANDSOURCETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL );

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