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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_IMINVENTORY') 
 CREATE TABLE T_PUR_IMINVENTORY (
FID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALGROUPID BIGINT DEFAULT 0 NOT NULL,
FRECORGID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOUTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FMINQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMAXQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUPDATETIME DATETIME,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_REPLENISHREQ') 
 CREATE TABLE T_PUR_REPLENISHREQ (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FSUPPLIER BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FORDERSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FBIZPARTNER BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_REPLENISHREQ_L') 
 CREATE TABLE T_PUR_REPLENISHREQ_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_REPLENISHREQENTRY') 
 CREATE TABLE T_PUR_REPLENISHREQENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDELIVERDATE DATETIME,
FINVORG BIGINT DEFAULT 0 NOT NULL,
FORDEREDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERNUM NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FENTRYSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FSRCBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CONMATERIAL') 
 CREATE TABLE T_PUR_CONMATERIAL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FUSEORGID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITOR BIGINT DEFAULT 0 NOT NULL,
FAUDITTIME DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FCTRLSTRATEGY CHAR(1) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX BIGINT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CONMATERIAL_L') 
 CREATE TABLE T_PUR_CONMATERIAL_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,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CONMATERIALENTRY') 
 CREATE TABLE T_PUR_CONMATERIALENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FENTRYUSESTATUS CHAR(1) DEFAULT ' ' NOT NULL
);

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