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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY' AND KSQL_COL_NAME IN ('FSCHEDULEQTY')) 
 ALTER TABLE T_PUR_ORDERENTRY ADD (FSCHEDULEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY' AND KSQL_COL_NAME IN ('FSCHEDULEBASEQTY')) 
 ALTER TABLE T_PUR_ORDERENTRY ADD (FSCHEDULEBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_DELIVERYSCHEDULE') 
 CREATE TABLE T_PUR_DELIVERYSCHEDULE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERLINKID BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL,
FLASTUPDATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
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_DELIVERYSCHENTRY') 
 CREATE TABLE T_PUR_DELIVERYSCHENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMATERIALDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASICUNITID BIGINT DEFAULT 0 NOT NULL,
FBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISPRESENT CHAR(1) DEFAULT ' ' NOT NULL,
FDELIVERYDATE DATETIME,
FDELIADDR NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRCVORGID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FPROMISEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROMISEBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROMISEDATE DATETIME,
FSUPPLIERREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FISMEETS CHAR(1) DEFAULT ' ' NOT NULL,
FPROMISESTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FRELATEOUTSTOCKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRELATEOUTSTOCKBASICQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FPOBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPOENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FSRCBILLTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FROWCREATORID BIGINT DEFAULT 0 NOT NULL,
FROWCREATETIME DATETIME,
FROWMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FROWMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_DELIVERYSCHEDULE_L') 
 CREATE TABLE T_PUR_DELIVERYSCHEDULE_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
);

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