/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\FMM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROGRAMME') 
CREATE TABLE T_FMM_PROGRAMME (
	FID BIGINT NOT NULL DEFAULT 0,
	FNUMBER VARCHAR(30) NOT NULL DEFAULT ' ',
	FNAME VARCHAR(50) NOT NULL DEFAULT ' ',
	FSTATUS VARCHAR(50) NOT NULL DEFAULT ' ',
	FCREATORID BIGINT NOT NULL DEFAULT 0,
	FMODIFIERID BIGINT NOT NULL DEFAULT 0,
	FENABLE VARCHAR(50) NOT NULL DEFAULT ' ',
	FCREATETIME DATETIME,
	FMODIFYTIME DATETIME,
	FMASTERID BIGINT NOT NULL DEFAULT 0,
	FCREATEORGID BIGINT NOT NULL DEFAULT 0,
	FORGID BIGINT NOT NULL DEFAULT 0,
	FUSEORG BIGINT NOT NULL DEFAULT 0,
	FCTRLSTRATEGY VARCHAR(50) NOT NULL DEFAULT ' ',
	FSOURCEDATAID BIGINT NOT NULL DEFAULT 0,
	FBITINDEX BIGINT NOT NULL DEFAULT 0,
	FSOURCEBITINDEX BIGINT NOT NULL DEFAULT 0,
	FVERSION BIGINT NOT NULL DEFAULT 0,
	FMATERIAL BIGINT NOT NULL DEFAULT 0,
	FYIELDRATE DECIMAL(23,10) NOT NULL DEFAULT 0,
	FBASEUNIT BIGINT NOT NULL DEFAULT 0,
	FEXPANDCONFIG BIGINT NOT NULL DEFAULT 0,
	FPROROUTE BIGINT NOT NULL DEFAULT 0,
	FAUXPRO BIGINT NOT NULL DEFAULT 0
);

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROENTRY') 
CREATE TABLE T_FMM_PROENTRY (
	FID BIGINT NOT NULL DEFAULT 0,
	FENTRYID BIGINT NOT NULL DEFAULT 0,
	FSEQ INT NOT NULL DEFAULT 0,
	FPROCESSNO BIGINT NOT NULL DEFAULT 0,
	FSTATGE BIGINT NOT NULL DEFAULT 0,
	FSTATGEDESC VARCHAR(255) NOT NULL DEFAULT ' ',
	FISSTAGE CHAR(1) NOT NULL DEFAULT '0',
	FWORKCENTER BIGINT NOT NULL DEFAULT 0,
	FPROCTRLSTRATEGY BIGINT NOT NULL DEFAULT 0,
	FPROUNIT BIGINT NOT NULL DEFAULT 0,
	FCOUNT DECIMAL(23,10) NOT NULL DEFAULT 0,
	FVALIDATE DATETIME,
	FINVALIDATE DATETIME,
	FECNNO VARCHAR(64) NOT NULL DEFAULT ' ',
	FUPBOUND DECIMAL(23,10) NOT NULL DEFAULT 0,
	FLOWBOUND DECIMAL(23,10) NOT NULL DEFAULT 0,
	FPROBASEUNIT BIGINT NOT NULL DEFAULT 0,
	FPROBASEQTY DECIMAL(23,10) NOT NULL DEFAULT 0,
	FMILESTONE CHAR(1) NOT NULL DEFAULT '0',
	FSTOREPOINT CHAR(1) NOT NULL DEFAULT '0'
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_ACTIVEENTRY') 
CREATE TABLE T_FMM_ACTIVEENTRY (
	FENTRYID BIGINT NOT NULL DEFAULT 0,
	FDETAILID BIGINT NOT NULL DEFAULT 0,
	FSEQ INT NOT NULL DEFAULT 0,
	FACTIVENUM BIGINT NOT NULL DEFAULT 0,
	FBASICQTY DECIMAL(23,10) NOT NULL DEFAULT 0,
	FACTIVEFORMULA BIGINT NOT NULL DEFAULT 0,
	FACTIVEREPORTFORMULA BIGINT NOT NULL DEFAULT 0,
	FRESOUCE BIGINT NOT NULL DEFAULT 0,
	FACTIVEUNIT BIGINT NOT NULL DEFAULT 0
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_ASSEMBLYENTRY') 
CREATE TABLE T_FMM_ASSEMBLYENTRY (
	FID BIGINT NOT NULL DEFAULT 0,
	FENTRYID BIGINT NOT NULL DEFAULT 0,
	FSEQ INT NOT NULL DEFAULT 0,
	FPARENTENTRYID BIGINT NOT NULL DEFAULT 0,
	FINVESTPRODUCT VARCHAR(50) NOT NULL DEFAULT ' ',
	FPRODTYPE VARCHAR(50) NOT NULL DEFAULT ' ',
	FENTRYMATERIAL BIGINT NOT NULL DEFAULT 0,
	FENTRYDESC VARCHAR(50) NOT NULL DEFAULT ' ',
	FAUXPROPERTYID BIGINT NOT NULL DEFAULT 0,
	FENTRYUNIT BIGINT NOT NULL DEFAULT 0,
	FPRODSTAGE BIGINT NOT NULL DEFAULT 0,
	FSTAGE CHAR(1) NOT NULL DEFAULT '0',
	FENTRYQTYTYPE VARCHAR(50) NOT NULL DEFAULT ' ',
	FQTYNUMERATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FQTYDENOMINATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FGROUPID VARCHAR(50) NOT NULL DEFAULT ' ',
	FVALIDDATE DATETIME,
	FINVALIDDATE DATETIME,
	FGROUPECNNO VARCHAR(64) NOT NULL DEFAULT ' ',
	FCHILDBOM BIGINT NOT NULL DEFAULT 0,
	FPARENTMAT BIGINT NOT NULL DEFAULT 0,
	FPARENTMATNO BIGINT NOT NULL DEFAULT 0,
	FISJUMPLEVEL CHAR(1) NOT NULL DEFAULT '0',
	FOWNERTYPE VARCHAR(50) NOT NULL DEFAULT ' ',
	FOWNERID BIGINT NOT NULL DEFAULT 0,
	FISSUEMODE VARCHAR(50) NOT NULL DEFAULT ' ',
	FISBACKFLUSHNEW VARCHAR(50) NOT NULL DEFAULT ' ',
	FSUPPLYORGID BIGINT NOT NULL DEFAULT 0,
	FISSTOCKALLOC CHAR(1) NOT NULL DEFAULT '0',
	FWAREHOUSEID BIGINT NOT NULL DEFAULT 0,
	FLOCATIONID BIGINT NOT NULL DEFAULT 0,
	FOUTORGID BIGINT NOT NULL DEFAULT 0,
	FOUTWAREHOUSEID BIGINT NOT NULL DEFAULT 0,
	FOUTLOCATIONID BIGINT NOT NULL DEFAULT 0,
	FENTRYVERSION BIGINT NOT NULL DEFAULT 0,
	FASSIGNRATE DECIMAL(23,10) NOT NULL DEFAULT 0,
	FTOBEASSIGNRATE1 DECIMAL(23,10) NOT NULL DEFAULT 0,
	FFIXSCRAP DECIMAL(23,10) NOT NULL DEFAULT 0,
	FASSIGNNUMERATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FASSIGNDENOMINATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FBOMENTRYID VARCHAR(50) NOT NULL DEFAULT ' '
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_STAGEENTRY') 
CREATE TABLE T_FMM_STAGEENTRY (
	FENTRYID BIGINT NOT NULL DEFAULT 0,
	FDETAILID BIGINT NOT NULL DEFAULT 0,
	FSEQ INT NOT NULL DEFAULT 0,
	FBATCHSTARTQTY DECIMAL(23,10) NOT NULL DEFAULT 0,
	FBATCHENDQTY DECIMAL(23,10) NOT NULL DEFAULT 0,
	FISSTAGEFIX CHAR(1) NOT NULL DEFAULT '0',
	FSTAGENUMERATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FSTAGEDENOMINATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FASSIGNSTAGENUMERATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FASSGINSTAGEDENOMINATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FASSIGNEDSTAGENUMERATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FASSGINEDSTAGEDENOMINATOR DECIMAL(23,10) NOT NULL DEFAULT 0,
	FASSGINSTAGEFIXSCRAP DECIMAL(23,10) NOT NULL DEFAULT 0,
	FASSGINEDSTAGEFIXSCRAP DECIMAL(23,10) NOT NULL DEFAULT 0,
	FSTAGESCRAPRATE DECIMAL(23,10) NOT NULL DEFAULT 0,
	FSTAGEFIXSCRAP DECIMAL(23,10) NOT NULL DEFAULT 0,
	FSTAGESOURCEID VARCHAR(50) NOT NULL DEFAULT ' '
);

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