/**Begin D:\PDM_UPGRADE\PDM1\OM_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDCOPM_MREQOUTBILL_L') 
 CREATE TABLE T_IM_MDCOPM_MREQOUTBILL_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDCOPM_MREQOUTBILL_M') 
create table T_IM_MDCOPM_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_MDCOPM_MREQOUTBILL') 
 CREATE TABLE T_IM_MDCOPM_MREQOUTBILL (
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,
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(255) DEFAULT ' ' NOT NULL,
FISVIRTUALBILL CHAR(1) DEFAULT '0' NOT NULL,
FBILLCRETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBOOKDATE DATETIME,
FASYNCSTATUS NVARCHAR(30) 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(30) DEFAULT ' ' NOT NULL,
FSUPPLYOWNER BIGINT DEFAULT 0 NOT NULL,
FTRANSACTEPATHID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDCOPM_MQBENTRY_R') 
 CREATE TABLE T_IM_MDCOPM_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,
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,
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,
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_MDCOPM_MQBENTRY_M') 
 CREATE TABLE T_IM_MDCOPM_MQBENTRY_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_MDCOPM_MQBENTRY') 
 CREATE TABLE T_IM_MDCOPM_MQBENTRY (
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,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISFREEGIFT CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDCOM_MREQOUTBILL_M') 
 CREATE TABLE T_IM_MDCOM_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_MDCOM_MREQOUTBILL_L') 
 CREATE TABLE T_IM_MDCOM_MREQOUTBILL_L (
FPKID NVARCHAR(18) 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_MDCOM_MREQOUTBILL') 
 CREATE TABLE T_IM_MDCOM_MREQOUTBILL (
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,
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(255) DEFAULT ' ' NOT NULL,
FISVIRTUALBILL CHAR(1) DEFAULT '0' NOT NULL,
FBILLCRETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBOOKDATE DATETIME,
FASYNCSTATUS NVARCHAR(30) 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(30) DEFAULT ' ' NOT NULL,
FSUPPLYOWNER BIGINT DEFAULT 0 NOT NULL,
FTRANSACTEPATHID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_MDCOM_MQBENTRY_R') 
 CREATE TABLE T_IM_MDCOM_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,
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,
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,
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_MDCOM_MQBENTRY_M') 
 CREATE TABLE T_IM_MDCOM_MQBENTRY_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_MDCOM_MQBENTRY') 
 CREATE TABLE T_IM_MDCOM_MQBENTRY (
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,
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\OM_table.sql **/
