CREATE TABLE PROGAGRUPSEMI
(   CDFILIAL          VARCHAR2(04) NOT NULL,
    DTPROGPRODU       DATE         NOT NULL,
    CDPRODUTO         VARCHAR2(10) NOT NULL,
    DTENTPROD         DATE         NOT NULL,
    QTPADPRODPCP      FLOAT        NULL,
    QTVENDAPCP        FLOAT        NULL,
    QTLOTEFABPCP      FLOAT        NULL,
    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_PROGAGRUPSEMI CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT PK_PROGAGRUPSEMI PRIMARY KEY (CDFILIAL, DTPROGPRODU, CDPRODUTO, DTENTPROD)
)
/
CREATE TABLE PREAGRUPSEMICALE
(   CDFILIAL          VARCHAR2(04)  NOT NULL,
    DTPROGPRODCP      DATE          NOT NULL,
    CDPRODUTO         VARCHAR2(10)  NOT NULL,
    DTCONCPROMRP      DATE          NOT NULL,
    NRSEQLOTEDIA      VARCHAR2(03)  NOT NULL,
    QTAFABRICMRP      FLOAT,
    IDGERAOPPREV      VARCHAR2(01) DEFAULT 'N',
    NRORDENAOP        VARCHAR2(10),
    NRORDENASUBOP     VARCHAR2(01),
    CDPRODFINAL       VARCHAR2(10),
    DTENTPRODPROG     DATE,
    NRORDEMPROD       FLOAT,
    QTAFABRICDIA      FLOAT,
    IDGERADO          VARCHAR2(01) DEFAULT 'N' NOT NULL,
    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_PREAGRUPSEMICALE CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT PK_PREAGRUPSEMICALE PRIMARY KEY (CDFILIAL, DTPROGPRODCP, CDPRODUTO, DTCONCPROMRP, NRSEQLOTEDIA)
)
/
