/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\POM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMANUSTOCKENTRY') 
 CREATE TABLE T_POM_XMANUSTOCKENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALUNITID BIGINT DEFAULT 0 NOT NULL,
FBOMREVERSION BIGINT DEFAULT 0 NOT NULL,
FQTYTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FUSERATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYNUMERATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYDENOMINATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFIXSCRAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTISSUEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNISSUEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISCANNEGATIVE CHAR(1) DEFAULT '0' NOT NULL,
FCHILDBOMID BIGINT DEFAULT 0 NOT NULL,
FCHILDBOMVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCHILDAUXPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYMODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FBATCHNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATION BIGINT DEFAULT 0 NOT NULL,
FOUTORGUNITID BIGINT DEFAULT 0 NOT NULL,
FOUTWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FISSUEMODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUPPLYTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FWASTAGERATEFORMULA NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISSTOCKALLOT CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMANUSTOCKENTRY_A') 
 CREATE TABLE T_POM_XMANUSTOCKENTRY_A (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FISBACKFLUSH CHAR(1) DEFAULT '0' NOT NULL,
FBACKFLUSHTIME NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISKEYPART CHAR(1) DEFAULT '0' NOT NULL,
FOVERISSUECONTRL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISSINHIGHLIMIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXTRARATIOQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISSINLOWLIMIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLACKRAITIOQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLEADTIME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLEADTIMEUNIT NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDEMANDDATE DATETIME,
FREJECTEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFEEDINGQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWIPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANSENDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOPRNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FALLOTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISBOMEXTEND CHAR(1) DEFAULT '0' NOT NULL,
FWORKPROCEDUREID BIGINT DEFAULT 0 NOT NULL,
FPROCESSSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPRWORKCENTER BIGINT DEFAULT 0 NOT NULL,
FMACHININGTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUPPLIER BIGINT DEFAULT 0 NOT NULL,
FISBACKFLUSHNEW NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISBULKMATERIAL CHAR(1) DEFAULT '0' NOT NULL,
FENTRYCHANGETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMANUSTOCKENTRY_B') 
 CREATE TABLE T_POM_XMANUSTOCKENTRY_B (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSTOCKENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTOCKID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTOCKNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODUCTBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRODUCTBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FPRODUCTTRANSID BIGINT DEFAULT 0 NOT NULL,
FSTOCKENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODUCTNO BIGINT DEFAULT 0 NOT NULL,
FENTRYORDERNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODEPTORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMANUSTOCKENTRY_L') 
 CREATE TABLE T_POM_XMANUSTOCKENTRY_L (
FPKID NVARCHAR(18) DEFAULT ' ' NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCHILDREMARKS NVARCHAR(250) DEFAULT ' ' NOT NULL,
FSETUPLOCATION NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMFTORDER') 
 CREATE TABLE T_POM_XMFTORDER (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) 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,
FENTRUSTDEPT BIGINT DEFAULT 0 NOT NULL,
FTRANSACTIONTYPE BIGINT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FREMARK NVARCHAR(500) DEFAULT ' ' NOT NULL,
FBIZTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREASON NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMFTORDERENTRY') 
 CREATE TABLE T_POM_XMFTORDERENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPARENTENTRYID BIGINT DEFAULT 0 NOT NULL,
FPRODUCTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FPRODUCEDEPT BIGINT DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPLANBEGINTIME DATETIME,
FPLANENDTIME DATETIME,
FBOMID BIGINT DEFAULT 0 NOT NULL,
FEXPENDBOMTIME DATETIME,
FREPLACENO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROCESSROUTE BIGINT DEFAULT 0 NOT NULL,
FROUTEREPLACE BIGINT DEFAULT 0 NOT NULL,
FPLANSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTASKSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FKITTINGSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPICKSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBIZSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FAUXPROPERTY BIGINT DEFAULT 0 NOT NULL,
FMANUVERSION BIGINT DEFAULT 0 NOT NULL,
FECNVERSION BIGINT DEFAULT 0 NOT NULL,
FESTSCRAPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAUXPTYUNIT BIGINT DEFAULT 0 NOT NULL,
FAUXPTYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMANFTECHSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCHANGETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSRCBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMFTORDERENTRY_E') 
 CREATE TABLE T_POM_XMFTORDERENTRY_E (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FPARENTENTRYID BIGINT DEFAULT 0 NOT NULL,
FBATCHNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINWARCONSIGNER BIGINT DEFAULT 0 NOT NULL,
FINWARDEPT BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSE BIGINT DEFAULT 0 NOT NULL,
FLOCATION BIGINT DEFAULT 0 NOT NULL,
FISCONTROLQTY CHAR(1) DEFAULT '0' NOT NULL,
FINWARMAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINWARMIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOUTPUTOPERATION BIGINT DEFAULT 0 NOT NULL,
FQUALIFIEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNQUALIFIEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREPAIRQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREWORKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPICKINGPAIRS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQUAINWAQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAITCHECKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNQUAINWAQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRINWAQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREPINWAQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPLANSURETIME DATETIME,
FTRANSMITTIME DATETIME,
FSTARTWORKTIME DATETIME,
FENDWORKTIME DATETIME,
FCLOSETIME DATETIME,
FENDCASETIME DATETIME,
FSOURCEBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FHEADBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRPTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTOCKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRCVINHIGHLIMIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRCVINLOWLIMIT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMFTORDERENTRY_S') 
 CREATE TABLE T_POM_XMFTORDERENTRY_S (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) 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,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FMFTDEPTORGID BIGINT DEFAULT 0 NOT NULL,
FBOMID BIGINT DEFAULT 0 NOT NULL,
FOMVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREPLACENO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAUXPROPERTY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTRANSACTIONTYPEID BIGINT DEFAULT 0 NOT NULL,
FORDERNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERENTRYID BIGINT DEFAULT 0 NOT NULL,
FMFTINQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARKS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPROCESSROUTE BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLAUXQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLAUXUNIT BIGINT DEFAULT 0 NOT NULL,
FISCHANGED CHAR(1) DEFAULT '0' NOT NULL,
FBIZTIME DATETIME,
FREASON NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMFTORDERENTRY_S_L') 
 CREATE TABLE T_POM_XMFTORDERENTRY_S_L (
FPKID NVARCHAR(18) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMFTORDERLOG') 
 CREATE TABLE T_POM_XMFTORDERLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLVERSION BIGINT DEFAULT 0 NOT NULL,
FXBILLID BIGINT DEFAULT 0 NOT NULL,
FXBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZTIME DATETIME,
FXREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLJSON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSRCBILLJSON_TAG NCLOB,
FXBILLJSON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FXBILLJSON_TAG NCLOB,
FXMDJSON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FXMDJSON_TAG NCLOB,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FXBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FXBILLENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_XMFTSTOCKLOG') 
 CREATE TABLE T_POM_XMFTSTOCKLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLVERSION BIGINT DEFAULT 0 NOT NULL,
FXBILLID BIGINT DEFAULT 0 NOT NULL,
FXBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZTIME DATETIME,
FXREASON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLJSON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSRCBILLJSON_TAG NCLOB,
FXBILLJSON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FXBILLJSON_TAG NCLOB,
FXMDJSON NVARCHAR(255) DEFAULT ' ' NOT NULL,
FXMDJSON_TAG NCLOB,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FXBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FXBILLENTRYSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYCHANGETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MANUSTOCKENTRY_A' AND KSQL_COL_NAME ='FENTRYCHANGETYPE') 
 ALTER TABLE T_POM_MANUSTOCKENTRY_A ADD (FENTRYCHANGETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTORDERENTRY_S' AND KSQL_COL_NAME ='FISCHANGED') 
 ALTER TABLE T_POM_MFTORDERENTRY_S ADD (FISCHANGED CHAR(1) DEFAULT '0' NOT NULL );

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