/**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_IM_MDC_OMOUTBILL') 
 CREATE TABLE T_IM_MDC_OMOUTBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) 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,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FBIZORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDEPTID BIGINT DEFAULT 0 NOT NULL,
FDEPTID BIGINT DEFAULT 0 NOT NULL,
FOPERATORGROUPID BIGINT DEFAULT 0 NOT NULL,
FOPERATORID BIGINT DEFAULT 0 NOT NULL,
FBIZTIME DATETIME,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FINVSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FCOMMENT NVARCHAR(512) DEFAULT ' ' NOT NULL,
FISVIRTUALBILL CHAR(1) DEFAULT ' ' NOT NULL,
FBILLCRETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBOOKDATE DATETIME,
FASYNCSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISCHARGEOFFED CHAR(1) DEFAULT ' ' NOT NULL,
FISCHARGEOFF CHAR(1) DEFAULT ' ' NOT NULL,
FSETTLEORG BIGINT DEFAULT 0 NOT NULL,
FREQUSERID BIGINT DEFAULT 0 NOT NULL,
FCOSTCENTERORG BIGINT DEFAULT 0 NOT NULL,
FSETTLECURRENCY BIGINT DEFAULT 0 NOT NULL,
FSUPPLYOWNERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYOWNER BIGINT DEFAULT 0 NOT NULL,
FTRANSACTEPATHID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_OMOUTBILL_M') 
 CREATE TABLE T_IM_MDC_OMOUTBILL_M (
FID BIGINT DEFAULT 0 NOT NULL,
FDOCTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNEEDTIME DATETIME,
FWORKSHOP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FWORKSHOPID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_OMOUTBILLENTRY') 
 CREATE TABLE T_IM_MDC_OMOUTBILLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDID BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT2ND 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,
FINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FPRODUCEDATE DATETIME,
FEXPIRYDATE DATETIME,
FENTRYCOMMENT NVARCHAR(512) DEFAULT ' ' NOT NULL,
FOWNERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FKEEPERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOWNERID BIGINT DEFAULT 0 NOT NULL,
FKEEPERID BIGINT DEFAULT 0 NOT NULL,
FLOTNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FMATERIALMASTERID BIGINT DEFAULT 0 NOT NULL,
FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FOUTOWNERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTOWNERID BIGINT DEFAULT 0 NOT NULL,
FOUTKEEPERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTKEEPERID BIGINT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISFREEGIFT CHAR(1) DEFAULT ' ' NOT NULL,
FWORKSTATION BIGINT DEFAULT 0 NOT NULL,
FWORKPROCEDUREID BIGINT DEFAULT 0 NOT NULL,
FOPRWORKCENTER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_OMOUTBILLENTRY_M') 
 CREATE TABLE T_IM_MDC_OMOUTBILLENTRY_M (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FMANUBILL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMANUENTRYID BIGINT DEFAULT 0 NOT NULL,
FCANSENDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMANUENTRY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMANUBILLID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_OMOUTBILLENTRY_R') 
 CREATE TABLE T_IM_MDC_OMOUTBILLENTRY_R (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FLOGISTICSBILL CHAR(1) DEFAULT ' ' NOT NULL,
FMVERSION BIGINT DEFAULT 0 NOT NULL,
FSRCSYSTEM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCSYSBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCSYSBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FRETURNBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMISETTLEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMIREMAINSETTLEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMIREMAINSETTLEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMISETTLEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPURCHASEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINPURQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPURCHASEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINPURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_OMOUTBILL_L') 
 CREATE TABLE T_IM_MDC_OMOUTBILL_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(521) DEFAULT ' ' NOT NULL
);



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