/**Begin D:\PDM_UPGRADE\PDM1\POM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_PRODUCTINBILL_M') 
 CREATE TABLE T_IM_MDC_PRODUCTINBILL_M (
FID BIGINT DEFAULT 0 NOT NULL,
FPRODUCEORG BIGINT DEFAULT 0 NOT NULL,
FCOSTCENTER BIGINT DEFAULT 0 NOT NULL,
FSHIPPERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_PRODUCTINBILL') 
 CREATE TABLE T_IM_MDC_PRODUCTINBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(60) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT 'A' 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,
FBIZOPERATORGROUPID BIGINT DEFAULT 0 NOT NULL,
FBIZOPERATORID BIGINT DEFAULT 0 NOT NULL,
FBIZTIMES DATETIME,
FBIZTYPEIDS BIGINT DEFAULT 0 NOT NULL,
FINVSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FCOMMENT NVARCHAR(512) DEFAULT ' ' NOT NULL,
FBILLCRETYPE CHAR(1) DEFAULT '0' NOT NULL,
FBOOKDATE DATETIME,
FASYNCSTATUS CHAR(1) DEFAULT 'B' NOT NULL,
FSETTLECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FISVIRTUALBILL CHAR(1) DEFAULT '0' NOT NULL,
FINVDC NVARCHAR(5) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_PRBLENTRY_X') 
 CREATE TABLE T_IM_MDC_PRBLENTRY_X (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_PRBLENTRY_R') 
 CREATE TABLE T_IM_MDC_PRBLENTRY_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 BIGINT DEFAULT 0 NOT NULL,
FLOGISTICSBILL CHAR(1) DEFAULT '0' 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,
FRETURNQTYS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNBASEQTYS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNBASEQTYS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNQTYS DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_PRBLENTRY_M') 
 CREATE TABLE T_IM_MDC_PRBLENTRY_M (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FMANUBILL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMANUBILLID BIGINT DEFAULT 0 NOT NULL,
FMANUENTRY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMANUENTRYID BIGINT DEFAULT 0 NOT NULL,
FWORKCENTER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FWORKCENTERID BIGINT DEFAULT 0 NOT NULL,
FWORKSHOP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FWORKSHOPID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODUCTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FQUALITYSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FRECEIVALQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIVEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISCOPY CHAR(1) DEFAULT '0' NOT NULL,
FMATERIALATTR NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_PRBLENTRY') 
 CREATE TABLE T_IM_MDC_PRBLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT 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(50) DEFAULT ' ' NOT NULL,
FOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FKEEPERTYPE NVARCHAR(30) 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(30) DEFAULT ' ' NOT NULL,
FOUTOWNERID BIGINT DEFAULT 0 NOT NULL,
FOUTKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTKEEPERID BIGINT DEFAULT 0 NOT NULL,
FMAINDEPTID BIGINT DEFAULT 0 NOT NULL,
FPRICES DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNTS DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYORGID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDID BIGINT DEFAULT 0 NOT NULL,
FUNITRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MREQOUTBILL_M') 
 CREATE TABLE T_IM_MDC_MREQOUTBILL_M (
FID BIGINT DEFAULT 0 NOT NULL,
FDOCTYPE NVARCHAR(30) 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_MREQOUTBILL_L') 
 CREATE TABLE T_IM_MDC_MREQOUTBILL_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(510) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MREQOUTBILL') 
 CREATE TABLE T_IM_MDC_MREQOUTBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT '0' 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,
FSUPPLYOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUPPLYOWNER BIGINT DEFAULT 0 NOT NULL,
FSETTLEORG BIGINT DEFAULT 0 NOT NULL,
FREQUSERID BIGINT DEFAULT 0 NOT NULL,
FCOSTCENTERORG BIGINT DEFAULT 0 NOT NULL,
FTRANSACTEPATHID BIGINT DEFAULT 0 NOT NULL,
FCOMMENT NVARCHAR(510) DEFAULT ' ' NOT NULL,
FASYNCSTATUS CHAR(1) DEFAULT 'B' NOT NULL,
FISVIRTUALBILL CHAR(1) DEFAULT '0' NOT NULL,
FBILLCRETYPE CHAR(1) DEFAULT '0' NOT NULL,
FBOOKDATE DATETIME,
FSETTLECURRENCY BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MQBENTRY_R') 
 CREATE TABLE T_IM_MDC_MQBENTRY_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 BIGINT DEFAULT 0 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 BIGINT 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,
FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FVMISETTLEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMISETTLEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINRETURNQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMIREMAINSETTLEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVMIREMAINSETTLEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPURCHASEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPURCHASEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINPURQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINPURAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL,
FMVERSION BIGINT DEFAULT 0 NOT NULL,
FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDC_MQBENTRY') 
 CREATE TABLE T_IM_MDC_MQBENTRY (
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,
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,
FENTRYORGID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT3RD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDID BIGINT DEFAULT 0 NOT NULL,
FUNITRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT3RDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FLOTNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPRODUCEDATE DATETIME,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FEXPIRYDATE DATETIME,
FENTRYCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOWNERID BIGINT DEFAULT 0 NOT NULL,
FKEEPERID BIGINT DEFAULT 0 NOT NULL,
FINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FOUTOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTOWNERID BIGINT DEFAULT 0 NOT NULL,
FOUTKEEPERTYPE NVARCHAR(30) 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 '0' NOT NULL
);



/**End D:\PDM_UPGRADE\PDM1\POM_table.sql **/
