/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DEFICITBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_DEFICITBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DEFICITBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_DEFICITBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_INITBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_INITBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_INVBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_INVBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_OTHERINBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_OTHERINBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_OTHEROUTBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_OTHEROUTBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SURPLUSBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_SURPLUSBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SURPLUSBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_SURPLUSBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSINBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_TRANSINBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSINBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_TRANSINBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_STATUSADJUSTENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_STATUSADJUSTENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_STATUSADJUSTENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_STATUSADJUSTENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_TRANSOUTBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_TRANSOUTBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOTADJUSTENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_LOTADJUSTENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOTADJUSTENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_LOTADJUSTENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TYPEADJUSTENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_TYPEADJUSTENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TYPEADJUSTENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_TYPEADJUSTENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY' AND KSQL_COL_NAME ='FINLOTNUMBER') 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY ADD (FINLOTNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY' AND KSQL_COL_NAME ='FINLOTID') 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY ADD (FINLOTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILL' AND KSQL_COL_NAME ='FHASAPBUSBILL') 
 ALTER TABLE T_IM_PURRECBILL ADD (FHASAPBUSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSAPPLYENTRY_Y' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_TRANSAPPLYENTRY_Y ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSAPPLYENTRY_Y' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_TRANSAPPLYENTRY_Y ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILLENTRY' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_MREQBILLENTRY ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FJOINPRICEQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FJOINPRICEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FJOINPRICEBASEQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FJOINPRICEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FREMAINJOINPRICEQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FREMAINJOINPRICEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FREMAINJOINPRICEBASEQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FREMAINJOINPRICEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FVERIFYQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FVERIFYBASEQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FVERIFYBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FUNVERIFYQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FUNVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FUNVERIFYBASEQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FUNVERIFYBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FPURCHASEDQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FPURCHASEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FREMAINPURQTY') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FREMAINPURQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FPURCHASEDAMOUNT') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FPURCHASEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FREMAINPURAMOUNT') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FREMAINPURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_PURRECBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVCOUNTBILLENTRY_X' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_INVCOUNTBILLENTRY_X ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ADJUSTBILLENTRY' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_ADJUSTBILLENTRY ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_SALOUTBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_SALOUTBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_PURINBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_PURINBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_BIZTYPEENTRY' AND KSQL_COL_NAME ='FALLOWMANUALADD') 
 ALTER TABLE T_IM_BIZTYPEENTRY ADD (FALLOWMANUALADD CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PRODUCTINBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_PRODUCTINBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PRODUCTINBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_PRODUCTINBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ADJUSTBILLSUBENTRY' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_ADJUSTBILLSUBENTRY ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME ='FPURCHASEDQTY') 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FPURCHASEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME ='FREMAINPURQTY') 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FREMAINPURQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME ='FPURCHASEDAMOUNT') 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FPURCHASEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME ='FREMAINPURAMOUNT') 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FREMAINPURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME ='FLOGISTICSBILL') 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILLENTRY_R' AND KSQL_COL_NAME ='FMVERSION') 
 ALTER TABLE T_IM_MREQOUTBILLENTRY_R ADD (FMVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_ASSEMBBILL_L') 
 CREATE TABLE T_IM_ASSEMBBILL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(510) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_ASSEMBBILLSUBENTRY') 
 CREATE TABLE T_IM_ASSEMBBILLSUBENTRY (
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALMASTERID BIGINT DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FLOTNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FPRODUCEDATE DATETIME,
FEXPIRYDATE DATETIME,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FUNIT2NDID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSAGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FINVTYPE BIGINT DEFAULT 0 NOT NULL,
FINVSTATUS BIGINT DEFAULT 0 NOT NULL,
FOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOWNER BIGINT DEFAULT 0 NOT NULL,
FKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FKEEPER BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOMMENT NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILL_F' AND KSQL_COL_NAME ='FEXRATETABLE') 
 ALTER TABLE T_IM_PURINBILL_F ADD (FEXRATETABLE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILL_F' AND KSQL_COL_NAME ='FEXRATEDATE') 
 ALTER TABLE T_IM_PURINBILL_F ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILL_F' AND KSQL_COL_NAME ='FEXRATETABLE') 
 ALTER TABLE T_IM_SALOUTBILL_F ADD (FEXRATETABLE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILL_F' AND KSQL_COL_NAME ='FEXRATEDATE') 
 ALTER TABLE T_IM_SALOUTBILL_F ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_F' AND KSQL_COL_NAME ='FEXRATETABLE') 
 ALTER TABLE T_IM_PURRECBILLENTRY_F ADD (FEXRATETABLE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_F' AND KSQL_COL_NAME ='FEXRATEDATE') 
 ALTER TABLE T_IM_PURRECBILLENTRY_F ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILL' AND KSQL_COL_NAME ='FISVIRTUALBILL') 
 ALTER TABLE T_IM_MREQOUTBILL ADD (FISVIRTUALBILL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_ASSEMBBILLENTRY') 
 CREATE TABLE T_IM_ASSEMBBILLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALMASTERID BIGINT DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FLOTNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FPRODUCEDATE DATETIME,
FEXPIRYDATE DATETIME,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROCESSINGFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOWNERID BIGINT DEFAULT 0 NOT NULL,
FKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FKEEPERID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FENTRYCOMMENT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FINVACCID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_ASSEMBBILL') 
 CREATE TABLE T_IM_ASSEMBBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(60) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) 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,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FBIZTIME DATETIME,
FDEPTID BIGINT DEFAULT 0 NOT NULL,
FOPERATORID BIGINT DEFAULT 0 NOT NULL,
FOPERATORGROUPID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL
);



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