CREATE TABLE TRABPEDIDOOP(
	CDFILIAL VARCHAR2(4) NOT NULL , 
	NRSEQTRABPEDIDOOP VARCHAR2(10) NOT NULL , 
	NRPEDIDO VARCHAR2(10) NOT NULL,  
	NRITEMPED VARCHAR2(10) NOT NULL, 
	CDPRODUTO VARCHAR2(10),  
	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_TRABPEDIDOOP CHECK (IDATIVO IN ('S','N')),
	 CONSTRAINT PK_TRABPEDIDOOP PRIMARY KEY (CDFILIAL, NRSEQTRABPEDIDOOP, NRPEDIDO, NRITEMPED)
)
/
CREATE TABLE TRABPEDIDOOPSEMI(	
    CDFILIAL VARCHAR2(4) NOT NULL, 
	NRSEQTRABPEDIDOOP VARCHAR2(10) NOT NULL, 
	CDPRODUTO VARCHAR2(10), 
	CDPRODINSUMO VARCHAR2(10), 
	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_TRABPEDIDOOPSEMI CHECK (IDATIVO IN ('S','N')),
	 CONSTRAINT PK_TRABPEDIDOOPSEMI PRIMARY KEY (CDFILIAL, NRSEQTRABPEDIDOOP, CDPRODUTO, CDPRODINSUMO, NRORDPROD, NRSUBORDPROD)
)
/

