/**Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
 EXEC p_AlterColumn 'T_PUR_CLAIMENTRY', 'FMAINBILLNUMBER', 'NVARCHAR(80)', 'NOT NULL', '1111', ''' ''';

 EXEC p_AlterColumn 'T_PUR_CLAIMENTRY', 'FSRCBILLNUMBER', 'NVARCHAR(80)', 'NOT NULL', '1111', ''' ''';

 EXEC p_AlterColumn 'T_PUR_PROB_ENTRYENTITY', 'FMAINBILLNUMBER', 'NVARCHAR(80)', 'NOT NULL', '1111', ''' ''';

 EXEC p_AlterColumn 'T_PUR_PROB_ENTRYENTITY', 'FSRCBILLNUMBER', 'NVARCHAR(80)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECTIFY') 
 CREATE TABLE T_PUR_RECTIFY (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCANCELSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FCANCELID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FCANCELDATE DATETIME,
FBILLDATE DATETIME,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FCONTACTERID BIGINT DEFAULT 0 NOT NULL,
FVERIFYFEEDBACKTIME DATETIME,
FVERIFYREQUIRETIME DATETIME,
FPCAFEEDBACKTIME DATETIME,
FPCAREQUIRETIME DATETIME,
FICAFEEDBACKTIME DATETIME,
FICAREQUIRETIME DATETIME,
FVERIFYSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FPCASTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FICASTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FVERIFYCONFIRMER BIGINT DEFAULT 0 NOT NULL,
FVERIFYCONFIRMTIME DATETIME,
FVERIFYEXPLANATION NVARCHAR(512) DEFAULT ' ' NOT NULL,
FPCACONFIRMER BIGINT DEFAULT 0 NOT NULL,
FPCACONFIRMTIME DATETIME,
FPCAEXPLANATION NVARCHAR(512) DEFAULT ' ' NOT NULL,
FICACONFIRMER BIGINT DEFAULT 0 NOT NULL,
FICACONFIRMTIME DATETIME,
FICAEXPLANATION NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSUMMARY NVARCHAR(512) DEFAULT ' ' NOT NULL,
FRECTIFICATIONTITLE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FORIGIN CHAR(1) DEFAULT ' ' NOT NULL,
FSRCBILLTYPE CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECTIFYENTRY') 
 CREATE TABLE T_PUR_RECTIFYENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPOBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FRECEIPTBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRECEIPTBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FDETAILS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDETAILS_TAG NCLOB,
FQUAPROBLEM CHAR(1) DEFAULT ' ' NOT NULL,
FLOTNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRECURRENCE CHAR(1) DEFAULT ' ' NOT NULL,
FRCVORGID BIGINT DEFAULT 0 NOT NULL,
FSETTLEORGID BIGINT DEFAULT 0 NOT NULL,
FCURRID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FMAINBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FSRCBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL
);


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


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


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


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


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECCAUSEENTRY') 
 CREATE TABLE T_PUR_RECCAUSEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUSPICIOUSREASON NVARCHAR(512) DEFAULT ' ' NOT NULL,
FVERIFICATIONRESULT NVARCHAR(512) DEFAULT ' ' NOT NULL,
FISROOTCAUSE CHAR(1) DEFAULT ' ' NOT NULL,
FMEMO NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FHEAD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMPLETIONTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECDESCENTRY') 
 CREATE TABLE T_PUR_RECDESCENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FWHATPROBLEM NVARCHAR(512) DEFAULT ' ' NOT NULL,
FOCCURRENCETIME DATETIME,
FOCCURRENCELOCATION NVARCHAR(512) DEFAULT ' ' NOT NULL,
FDISCOVERYPERSON NVARCHAR(512) DEFAULT ' ' NOT NULL,
FHOWDISCOVER NVARCHAR(512) DEFAULT ' ' NOT NULL,
FQUANTITYORDEGREE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FWHYISAPROBLEM NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECEVENTRY') 
 CREATE TABLE T_PUR_RECEVENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FISTHROUGH CHAR(1) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(512) DEFAULT ' ' NOT NULL,
FMEMO NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FHEAD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMPLETIONTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECFMENTRY') 
 CREATE TABLE T_PUR_RECFMENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMEMO NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FHEAD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMPLETIONTIME DATETIME,
FDESCRIBE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FVERIFY NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECPMENTRY') 
 CREATE TABLE T_PUR_RECPMENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMEMO NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FHEAD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMPLETIONTIME DATETIME,
FDESCRIBE NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECTEAMENTRY') 
 CREATE TABLE T_PUR_RECTEAMENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMEMO NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FREPRESENTATIVE CHAR(1) DEFAULT ' ' NOT NULL,
FTEAMROLES CHAR(1) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPROCESS CHAR(1) DEFAULT ' ' NOT NULL,
FEMAIL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(255) DEFAULT ' ' NOT NULL,
FDEPARTMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FRESPONSIBILITY NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RECTMENTRY') 
 CREATE TABLE T_PUR_RECTMENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMEMO NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FHEAD NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMPLETIONTIME DATETIME,
FDESCRIBE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FVERIFY NVARCHAR(512) DEFAULT ' ' NOT NULL
);



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