DROP PROCEDURE IN_BuscaNroDocumentoProc
GO
CREATE PROCEDURE IN_BuscaNroDocumentoProc
(   @TYPEDOCID	UD_TYPEDOC,
    @VENDIDSS 	UD_IDVENDOR,
    @DOCTYPEID	UD_DOCTYPEID,
    @REFNBR 	CHAR(15)
)
AS
BEGIN



      SELECT 	REFNBR
      FROM 	IN_INTRAHEAD
      WHERE 	TYPEDOCID=@TYPEDOCID AND VENDIDSS=@VENDIDSS AND DOCTYPEID=@DOCTYPEID AND
	   	REFNBR=@REFNBR AND DOCSTATUSID<>'AN'

END
