CREATE TABLE TRABSEMIACABADOPED
   (CDFILIAL 		  VARCHAR2(4) NOT NULL, 
    NRPEDIDO 		  VARCHAR2(10) NOT NULL, 
    NRITEMPED 		  VARCHAR2(10) NOT NULL, 
    CDPRODUTO 		  VARCHAR2(10) NOT NULL, 
    QTAPRODUZIR 	  FLOAT(126) NOT NULL, 
    CDPRODINSUMO 	  VARCHAR2(10) NOT NULL, 
    QTINSUMO 		  FLOAT(126) NOT NULL, 
    NRORDPROD 	   	  VARCHAR2(10), 
    NRSUBORDPROD 	  VARCHAR2(1), 
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    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',
		CONSTRAINT CKC_IDATIVO_TRABSEMIACABADOPED CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_TRABSEMIACABADOPED PRIMARY KEY (CDFILIAL, NRPEDIDO, NRITEMPED, CDPRODUTO, CDPRODINSUMO)
)
/

CREATE TABLE TRABPRODACABPED
   (CDFILIAL		  VARCHAR2(4) NOT NULL, 
    NRPEDIDO 		  VARCHAR2(10) NOT NULL , 
    NRITEMPED 		  VARCHAR2(10) NOT NULL , 
    CDPRODUTO 		  VARCHAR2(10) NOT NULL , 
    QTAPRODUZIR 	  FLOAT(126) NOT NULL , 
    NRORDPROD 		  VARCHAR2(10), 
    NRSUBORDPROD 	  VARCHAR2(1), 	
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    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',
		 CONSTRAINT CKC_IDATIVO_TRABPRODACABPED CHECK (IDATIVO IN ('S','N')),
		 CONSTRAINT PK_TRABPRODACABPED PRIMARY KEY (CDFILIAL, NRPEDIDO, NRITEMPED)
)
/