Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8894

Help needed for Stored procedure

$
0
0

I'm using this code for initializing an approval procedure.I want  to create an exception for customers whose  card code is ,C-KL-KKD -185 & C-KL-TCR-1204 in this procedure.How  to do this.Anyone please help.

 

GO

/****** Object:  StoredProcedure [dbo].[SP_Nocil_CreditDays_60]    Script Date: 04/04/2014 16:49:28 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER PROCEDURE [dbo].[SP_Nocil_CreditDays_60]

  @list_of_cols_val_tab_del NVARCHAR(255), @error_message NVARCHAR(255) OUTPUT

AS

BEGIN

  declare @RowCount int

 

  select

  @RowCount=COUNT(RDR1.ItemCode)

  from ORDR

  inner join RDR1 on ORDR.DocEntry=RDR1.DocEntry

  inner join OITM on RDR1.ItemCode=OITM.ItemCode and OITM.U_SeriesGrp='N' and isnull(ORDR.U_Approved,'N')='N'

  where

  ORDR.DocEntry=@list_of_cols_val_tab_del

 

  if @RowCount>0

  begin

  select @RowCount=0

  select

  @RowCount=COUNT(OINV.DocEntry)

  from

  OINV

  inner join INV1 on OINV.DocEntry=INV1.DocEntry

  inner join OITM on INV1.ItemCode=OITM.ItemCode and OITM.U_SeriesGrp='N'

  where

  OINV.DocTotal-OINV.PaidToDate>0 and DATEDIFF(Day,OINV.DocDate,GETDATE())>60

  and OINV.CardCode=(select ORDR.CardCode from ORDR where ORDR.DocEntry=@list_of_cols_val_tab_del)

 

  if @RowCount>0

  begin

  select @error_message= 'This document required approval. Please select Approval to "Yes" to continue'

  return -1

  end

  else

  begin

  return 0

  end

  end

  return 0

End


Viewing all articles
Browse latest Browse all 8894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>