CREATE TABLE PEDIDO_IMPORTA 
(
   CDFILDEST       		VARCHAR2(4),
   CDFILLANC       		VARCHAR2(4),
   NRAUTOFORN      	VARCHAR2(10),
   CDVENDEDOR      	VARCHAR2(5),
   DTPROGENTAF     	DATE,
   CDFILIAL        		VARCHAR2(4),
   NRPEDIDO        		VARCHAR2(10),
   CDCLIENTE       		VARCHAR2(21),
   CDMODPGTO       	VARCHAR2(5), 
   CDPRECOBASE     	VARCHAR2(2),
   CDTIPOOPER      		VARCHAR2(2),
   DTPEDIDO        		DATE,
   CDOPELANPED     	VARCHAR2(12),
   IDIMPORTA       		VARCHAR2(1),
   IDUTRELACPRODAF 	VARCHAR2(1),
   IDUTVALIPED     		VARCHAR2(1),
   NRINSJURTRAN    	VARCHAR2(20),
   CDTIPTRANS      		VARCHAR2(4),
   IDPGFRETTRANCLI 	VARCHAR2(1),
   IDLANCPED       		VARCHAR2(1),
   NRORG                       	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     	DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_PEDIMPORTA CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   	NULL,
   DTULTATU                  	DATE                  	NULL,
   NRORGINCLUSAO      	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    	VARCHAR2(12)  	DEFAULT '1' NULL,
   NRORGULTATU          	NUMBER 		DEFAULT  SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        	VARCHAR2(12)  	DEFAULT '1'
)
/
CREATE TABLE TMP_RELACPRODIMP
(
   CDPRODUTO 		VARCHAR2(10),
   VRFATARRED 		FLOAT,
   VRFATOCONV 		FLOAT,
   FATORCALC 		FLOAT,
   NRORG                       	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     	DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_RELACPRODIMP CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   	NULL,
   DTULTATU                  	DATE                  	NULL,
   NRORGINCLUSAO      	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    	VARCHAR2(12)  	DEFAULT '1' NULL,
   NRORGULTATU          	NUMBER 		DEFAULT  SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        	VARCHAR2(12)  	DEFAULT '1'
)
/
CREATE TABLE ITEMPEDIDO_IMPORTA
(
   CDFILIAL     		VARCHAR2(4),
   NRPEDIDO     		VARCHAR2(10),
   CDPRODUTO    		VARCHAR2(10),
   NRITEMPED    		VARCHAR2(10),
   IDSITITEMPED 		VARCHAR2(1),
   QTITEMPED    		FLOAT,
   QTITEMPED2   		FLOAT,
   VRPRTABITPED 		FLOAT,
   DTENTITPED   		DATE,
   CDOPELANPED  		VARCHAR2(12),
   IDIMPORTA    		VARCHAR2(1),
   CDPRODUTOORI 		VARCHAR2(10),
   CDMARCA      		VARCHAR2(5),
   NRORG                       	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     	DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ITEMPEDIMPORTA CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   	NULL,
   DTULTATU                  	DATE                  	NULL,
   NRORGINCLUSAO      	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    	VARCHAR2(12)  	DEFAULT '1' NULL,
   NRORGULTATU          	NUMBER 		DEFAULT  SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        	VARCHAR2(12)  	DEFAULT '1'
)
/
CREATE TABLE IMPORTA_ERRO
(  
   CDFILDEST    		VARCHAR2(4),
   CDFILLANC    		VARCHAR2(4),
   NRAUTOFORN   		VARCHAR2(10),
   CDPRODUTO    		VARCHAR2(10),
   DTPROGENTAF  		DATE,
   ERRO         		VARCHAR2(4000),
   QTPROGENTAF  		FLOAT,
   VRPREUNIAF   		FLOAT,
   VRITEPREBASE 		FLOAT,
   DATA_ERRO    		DATE,
   NRORG                       	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     	DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_IMPERRO CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   	NULL,
   DTULTATU                  	DATE                  	NULL,
   NRORGINCLUSAO      	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    	VARCHAR2(12)  	DEFAULT '1' NULL,
   NRORGULTATU          	NUMBER 		DEFAULT  SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        	VARCHAR2(12)  	DEFAULT '1'
)
/
CREATE TABLE AF_ERRO_IMP
(
   CDFILDEST    		VARCHAR2(4),
   CDFILLANC    		VARCHAR2(4),
   NRAUTOFORN   		VARCHAR2(10),
   IDIMPORTA    		VARCHAR2(1),
   NRORG                       	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     	DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_AFERROIMP CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   	NULL,
   DTULTATU                  	DATE                  	NULL,
   NRORGINCLUSAO      	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    	VARCHAR2(12)  	DEFAULT '1' NULL,
   NRORGULTATU          	NUMBER 		DEFAULT  SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        	VARCHAR2(12)  	DEFAULT '1'
)
/
ALTER TABLE TMP_RELACPRODIMP ADD CDPRODUTOORI VARCHAR2(10)
/
ALTER TABLE PRODPEDXAF ADD DATA_IMP DATE
/
ALTER TABLE IMPORTA_ERRO ADD CDOPERADOR VARCHAR2(12)
/
ALTER TABLE MENSERROPEDAF ADD CDOPERADOR VARCHAR2(12) 