DROP PROCEDURE TMP_IN_INTRAITEMInsProc
GO
CREATE PROCEDURE TMP_IN_INTRAITEMInsProc
(
    @CORRNBR           int,
    @SITEID            UD_IDSITE,

    @TYPEDOCID         UD_TYPEMOVEID,
    @SEQUENCE          smallint,
    @INVTIDSKU         UD_IDCORPORATIVO,
    @INVTIDBARR        UD_CODIGOBARRA,
    @QTY               UD_STOCK,
    @TAXIGV            numeric(5, 2)               = NULL,
    @STDCOSTPEN        UD_COSTO                    = NULL,
    @STDCOSTUSD        UD_COSTO                    = NULL,
    @STKFISI           bit,
    @INTRDATE          smalldatetime,
    @INTRDATEPROCE    smalldatetime,
    @RLSED             bit,
    @TAXISC	      NUMERIC(5,2),
    @STDCOSTPENOLD     UD_COSTO,	
    @STDCOSTUSDOLD     UD_COSTO,
    @USER1             UD_USER1                    = NULL,
    @USER2             UD_USER2                    = NULL,
    @USER3             UD_USER3                    = NULL,
    @USER4             UD_USER5                    = NULL,
    @USER5             UD_USER5                    = NULL,
    @USER6             UD_USER6                    = NULL,
    @USER7             UD_USER7                    = NULL,
    @USER8             UD_USER8                    = NULL,
    @USER9             UD_USER9                    = NULL)
AS
BEGIN
    BEGIN TRAN

          INSERT INTO TMP_IN_INTRAITEM(CORRNBR,SITEID,TYPEDOCID,SEQUENCE,INVTIDSKU,INVTIDBARR,QTY,
                                   TAXIGV,STDCOSTPEN,STDCOSTUSD,STKFISI,INTRDATE,INTRDATEPROCE,
                                   RLSED,TAXISC,STDCOSTPENOLD,STDCOSTUSDOLD,USER1,USER2,USER3,USER4,USER5,USER6,USER7,USER8,USER9 
                                   )
          VALUES(@CORRNBR,@SITEID,@TYPEDOCID,@SEQUENCE,@INVTIDSKU,@INVTIDBARR,@QTY,@TAXIGV,@STDCOSTPEN,
                 @STDCOSTUSD,@STKFISI,@INTRDATE,@INTRDATEPROCE,@RLSED,@TAXISC,@STDCOSTPENOLD,@STDCOSTUSDOLD,@USER1,@USER2,@USER3,@USER4,
                 @USER5,@USER6,@USER7,@USER8,@USER9 
                 )

    IF (@@error!=0)
    BEGIN
        RAISERROR  20000 'Error insertando en Temporal '
        ROLLBACK TRAN
        RETURN(1)
    
    END

    COMMIT TRAN

END
