/**Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULECONSUBENTRY') 
 CREATE TABLE T_PUR_MODULECONSUBENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUBMATERIALID BIGINT DEFAULT 0 NOT NULL,
FSUBMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUBCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBUNITID BIGINT DEFAULT 0 NOT NULL,
FSUBBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FSUBSUMCONQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBCURRCONQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBSUMCONBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBCURRCONBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISBACKFLUSHNEW CHAR(1) DEFAULT ' ' NOT NULL,
FSUBSRCBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FSUBMAINBILLENTITY NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBMAINBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBMAINBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBMAINBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBMAINBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FSUBREMARKS NVARCHAR(512) DEFAULT ' ' NOT NULL,
FDOWNSTREAMBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDOWNSTREAMBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDOWNSTREAMBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FDOWNSTREAMBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSALOUTID BIGINT DEFAULT 0 NOT NULL,
FSALOUTENTRYID BIGINT DEFAULT 0 NOT NULL,
FSALOUTNUM NVARCHAR(80) DEFAULT ' ' NOT NULL,
FOVERISSUECONTRL CHAR(1) DEFAULT ' ' NOT NULL,
FEXTRARATIOQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXTRARATIOBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULECONSUBENTRY_L') 
 CREATE TABLE T_PUR_MODULECONSUBENTRY_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FSUBREMARKS NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULECONSUME') 
 CREATE TABLE T_PUR_MODULECONSUME (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) 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,
FCFMID BIGINT DEFAULT 0 NOT NULL,
FCFMDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FCONTACTERID BIGINT DEFAULT 0 NOT NULL,
FBUSINESSTYPEID BIGINT DEFAULT 0 NOT NULL,
FCONSUMETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FSRCTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FORIGIN CHAR(1) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULECONSUMEENTRY') 
 CREATE TABLE T_PUR_MODULECONSUMEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELIDATE DATETIME,
FJOINTDATACHANNELID VARCHAR(80) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULEDELIVERY') 
 CREATE TABLE T_PUR_MODULEDELIVERY (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) 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,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FCONTACTERID BIGINT DEFAULT 0 NOT NULL,
FBUSINESSTYPEID BIGINT DEFAULT 0 NOT NULL,
FORIGIN CHAR(1) DEFAULT ' ' NOT NULL,
FSRCTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FOUTORGID BIGINT DEFAULT 0 NOT NULL,
FOUTSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FOUTBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULEDELIVERYENTRY') 
 CREATE TABLE T_PUR_MODULEDELIVERYENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAMETEXT VARCHAR(255) DEFAULT ' ' NOT NULL,
FPOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELIDATE DATETIME,
FDELIADDR NVARCHAR(255) DEFAULT ' ' NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FSUPLOT NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FDUEDATE DATETIME,
FPRODDATE DATETIME,
FCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FTRACEID BIGINT DEFAULT 0 NOT NULL,
FENTRYSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FPURORGID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLENTITY NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FMAINBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FRELDELIVERQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRELDELIVERBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRELRECIEPTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUMRECIEPTBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMRECIEPTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOMRECIEPTBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FJOINTDATACHANNELID VARCHAR(80) DEFAULT ' ' NOT NULL,
FRECWAREHOUSE BIGINT DEFAULT 0 NOT NULL,
FRECLOCATIONID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULELIST') 
 CREATE TABLE T_PUR_MODULELIST (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) 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,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FENTRYPURORGID BIGINT DEFAULT 0 NOT NULL,
FMFTORDERNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMFTORDERENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPOENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIGIN CHAR(1) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULELIST_L') 
 CREATE TABLE T_PUR_MODULELIST_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULELIST_SUB') 
 CREATE TABLE T_PUR_MODULELIST_SUB (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUBMATERIALID BIGINT DEFAULT 0 NOT NULL,
FSUBMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FQTYTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FFIXSCRAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWASTEFORMULA CHAR(1) DEFAULT ' ' NOT NULL,
FQTYNUMERATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYDENOMINATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBUNITID BIGINT DEFAULT 0 NOT NULL,
FSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBREQUIREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBREQUIREBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIPTSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIPTSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOUTSTOCKSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOUTSTOCKSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONSUMESUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONSUMESUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FISSTEP CHAR(1) DEFAULT '0' NOT NULL,
FUSERATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYMODE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FISSUEMODE CHAR(1) DEFAULT ' ' NOT NULL,
FISBACKFLUSHNEW CHAR(1) DEFAULT ' ' NOT NULL,
FBATCHNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FSUBSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBSRCBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDEMANDDATE DATETIME,
FOVERISSUECONTRL CHAR(1) DEFAULT ' ' NOT NULL,
FEXTRARATIOQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXTRARATIOBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FJOINTDATACHANNELID VARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBREMARKS NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULELIST_SUB_L') 
 CREATE TABLE T_PUR_MODULELIST_SUB_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FSUBREMARKS NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULERECEIPT') 
 CREATE TABLE T_PUR_MODULERECEIPT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) 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,
FCFMID BIGINT DEFAULT 0 NOT NULL,
FCFMDATE DATETIME,
FCFMSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FCONTACTERID BIGINT DEFAULT 0 NOT NULL,
FBUSINESSTYPEID BIGINT DEFAULT 0 NOT NULL,
FORIGIN CHAR(1) DEFAULT ' ' NOT NULL,
FSRCTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FREJECTREASON NVARCHAR(512) DEFAULT '0' NOT NULL,
FREJECTERID BIGINT DEFAULT 0 NOT NULL,
FREJECTDATE DATETIME,
FRECEIPTTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSOURCETYPE CHAR(1) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MODULERECEIPTENTRY') 
 CREATE TABLE T_PUR_MODULERECEIPTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELIDATE DATETIME,
FDELIADDR NVARCHAR(255) DEFAULT ' ' NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FSUPLOT NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FDUEDATE DATETIME,
FPRODDATE DATETIME,
FCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FTRACEID BIGINT DEFAULT 0 NOT NULL,
FENTRYSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FPURORGID BIGINT DEFAULT 0 NOT NULL,
FDELIVERYBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELIVERYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDIFFQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIPTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIPTBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDIFFBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRELRETURNQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRELRETURNBASIQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROCESSTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FJOINTDATACHANNELID VARCHAR(80) DEFAULT ' ' NOT NULL,
FRECWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FRECLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FDOWNSTREAMBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDOWNSTREAMBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDOWNSTREAMBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FDOWNSTREAMBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPOBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPOENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FTRANSDIRBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FTRANSDIRBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLENTITY NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FMAINBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_SALOUTSTOCKENTRY_S') 
 CREATE TABLE T_PUR_SALOUTSTOCKENTRY_S (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUBMATERIALID BIGINT DEFAULT 0 NOT NULL,
FSUBMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUBCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBUNITID BIGINT DEFAULT 0 NOT NULL,
FSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FCONSUMESUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONSUMESUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURCONSUMESUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURCONSUMESUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISBACKFLUSHNEW CHAR(1) DEFAULT ' ' NOT NULL,
FSUBSRCBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL
);


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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_XORDERENTRY_S') 
 CREATE TABLE T_PUR_XORDERENTRY_S (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUBMATERIALID BIGINT DEFAULT 0 NOT NULL,
FSUBMATERIALNAMETEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FQTYTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FFIXSCRAP DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWASTEFORMULA CHAR(1) DEFAULT ' ' NOT NULL,
FQTYNUMERATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTYDENOMINATOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBUNITID BIGINT DEFAULT 0 NOT NULL,
FSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBREQUIREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBREQUIREBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIPTSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECEIPTSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOUTSTOCKSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOUTSTOCKSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNSUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNSUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONSUMESUBQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONSUMESUBBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUBCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FISSTEP CHAR(1) DEFAULT '0' NOT NULL,
FUSERATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYMODE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FISSUEMODE CHAR(1) DEFAULT ' ' NOT NULL,
FISBACKFLUSHNEW CHAR(1) DEFAULT ' ' NOT NULL,
FBATCHNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSRCBILLENTRYSEQ VARCHAR(20) DEFAULT ' ' NOT NULL,
FSUBSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBSRCBILLTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDEMANDDATE DATETIME,
FOVERISSUECONTRL CHAR(1) DEFAULT ' ' NOT NULL,
FEXTRARATIOQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXTRARATIOBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FJOINTDATACHANNELID VARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBREMARKS NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_XORDERENTRY_S_L') 
 CREATE TABLE T_PUR_XORDERENTRY_S_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FSUBREMARKS NVARCHAR(512) DEFAULT ' ' NOT NULL
);



/**End C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
