ALTER TABLE ITCOMANDAVEN ADD IDDIVIDECONTA VARCHAR2(1) DEFAULT 'N' NOT NULL
   CONSTRAINT CKC_IDDIVIDECONTA_ITCOMANDAVEN CHECK (IDDIVIDECONTA IN ('S','N'))
/

ALTER TABLE ITCOMANDAVEN ADD NRPRODORIG VARCHAR2(6) NULL
/

CREATE TABLE ITCMDVENORIG
(
    CDFILIAL            VARCHAR2(4)            NOT NULL,
    NRVENDAREST         VARCHAR2(10)           NOT NULL,
    NRCOMANDA           VARCHAR2(10)           NOT NULL,
    NRPRODCOMVEN        VARCHAR2(6)            NOT NULL,
    CDPRODUTO           VARCHAR2(10)           NOT NULL,
    QTPRODCOMVEN        FLOAT                  NOT NULL,
    VRPRECCOMVEN        FLOAT                  NOT NULL,
    TXPRODCOMVEN        VARCHAR2(2000)         NULL    ,
    IDSTPRCOMVEN        VARCHAR2(1)            DEFAULT '1' NOT NULL
        CONSTRAINT CKC_IDSTPRCOMVEN_ITCMDVENORIG CHECK (IDSTPRCOMVEN IN ('1','2','3','4','5','6','7')),
    VRDESCCOMVEN        FLOAT                  DEFAULT 0 NOT NULL,
    NRLUGARMESA         VARCHAR2(3)            NULL    ,
    DTHRINCOMVEN        DATE                   NOT NULL,
    IDPRODIMPFIS        VARCHAR2(1)            DEFAULT 'N' NOT NULL
        CONSTRAINT CKC_IDPRODIMPFIS_ITCMDVENORIG CHECK (IDPRODIMPFIS IN ('S','N')),
    CDLOJA              VARCHAR2(10)           NULL    ,
    VRACRCOMVEN         FLOAT                  DEFAULT 0 NOT NULL,
    NRSEQPRODCOM        VARCHAR2(3)            NULL    ,
    NRSEQPRODCUP        VARCHAR2(10)           NULL    ,
    CDCAIXACOLETOR      VARCHAR2(3)            NULL    ,
    VRPRECCLCOMVEN      FLOAT                  NULL    ,
    CDPRODPROMOCAO      VARCHAR2(10)           NULL    ,
    CDVENDEDOR          VARCHAR2(4)            NULL    ,
    CDSENHAPED          VARCHAR2(5)            NULL    ,
    DSOBSPEDDIGCMD      VARCHAR2(2000)         NULL    ,
    IDORIGPEDCMD        VARCHAR2(3)            DEFAULT 'FOS' NULL
        CONSTRAINT CKC_IDORIGPEDCMD_ITCMDVENORIG CHECK (IDORIGPEDCMD IN ('FOS','MOB')),
    NRORG             NUMBER 	   DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO	        VARCHAR2(1)    DEFAULT 'S'	NOT NULL,
    	CONSTRAINT CKC_IDATIVO_ITCMDVENORIG CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO          DATE                   NULL,
    DTULTATU            DATE                   NULL,
    NRORGINCLUSAO       NUMBER                 NULL,
    CDOPERINCLUSAO      VARCHAR2(12)           NULL,
    NRORGULTATU         NUMBER                 NULL,
    CDOPERULTATU        VARCHAR2(12)           NULL,
        CONSTRAINT PK_ITCMDVENORIG PRIMARY KEY (CDFILIAL, NRVENDAREST, NRCOMANDA, NRPRODCOMVEN)
)
/