/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_AJSGLOBALSETTING') 
 CREATE TABLE T_BCM_AJSGLOBALSETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FSOURCEORGID BIGINT DEFAULT 0 NOT NULL,
FSHAREORGID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIO NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FAUDITTRIAL NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FFYEAR NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FPERIOD NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FBUSINESSTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFYDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CONVERTDIFFENTITY' AND KSQL_COL_NAME ='FPERIODTXT') 
 ALTER TABLE T_BCM_CONVERTDIFFENTITY ADD (FPERIODTXT NVARCHAR(1000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHKFORMULASETTING' AND KSQL_COL_NAME ='FPERIODTXT') 
 ALTER TABLE T_BCM_CHKFORMULASETTING ADD (FPERIODTXT NVARCHAR(1000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHKEFFECTIVE' AND KSQL_COL_NAME ='FYEARSCOPE') 
 ALTER TABLE T_BCM_CHKEFFECTIVE ADD (FYEARSCOPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CONDIFFEFFECTIVE' AND KSQL_COL_NAME ='FYEARSCOPE') 
 ALTER TABLE T_BCM_CONDIFFEFFECTIVE ADD (FYEARSCOPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_LINKAGEEFFECTIVE' AND KSQL_COL_NAME ='FYEARSCOPE') 
 ALTER TABLE T_BCM_LINKAGEEFFECTIVE ADD (FYEARSCOPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUST' AND KSQL_COL_NAME ='FALLSHAREORG') 
 ALTER TABLE T_BCM_RPTADJUST ADD (FALLSHAREORG NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ANALYSISCHART') 
 CREATE TABLE T_BCM_ANALYSISCHART (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FCODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTYPE CHAR(1) DEFAULT '1' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FTHEMETYPEID BIGINT DEFAULT 0 NOT NULL,
FIMAGESRC NVARCHAR(500) DEFAULT ' ' NOT NULL,
FIMAGENAME NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ANALYSISCHARTACCOUN') 
 CREATE TABLE T_BCM_ANALYSISCHARTACCOUN (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FRANGE CHAR(2) DEFAULT '10' NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ANALYSISTHEMETYPE') 
 CREATE TABLE T_BCM_ANALYSISTHEMETYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FLEVEL INT DEFAULT 0 NOT NULL,
FISLEAF CHAR(1) DEFAULT ' ' NOT NULL
);



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