CREATE PROCEDURE [dbo].[ApiWmsAutoVeryfiedDocs] as
BEGIN
 declare @WmsDocId int;
 declare @Direction int;


 -- PWP,RWP 
DECLARE Doc_Cursor CURSOR FOR	 
select Id, Direction from dbo.ApiWmsDocuments where 
(OrgDocumentNumber LIKE 'PWP/%' OR OrgDocumentNumber LIKE 'RWP/%'  )  and 
StateId =0
  
OPEN Doc_Cursor;
FETCH NEXT FROM Doc_Cursor INTO @WmsDocId,@Direction
WHILE @@FETCH_STATUS = 0
  BEGIN
	  exec [dbo].ApiAutoSaveWMSDoc @WmsDocId,@Direction;
	  FETCH NEXT FROM Doc_Cursor INTO @WmsDocId ,@Direction;
   END;
CLOSE Doc_Cursor;
DEALLOCATE Doc_Cursor;
END

