cancel
Showing results for 
Search instead for 
Did you mean: 

SAP B1 Transaction - Checking same prices between ORDR and OINV

former_member469301
Discoverer
0 Kudos

Hello Guys,

I'm trying to validate the price of Invoice to be the same as Sales Order to prevent an user to make changes in moment of add Invoice document. So I made this code in transaction notification to block the user when he makes a mistake.

But the point is, even if don't change anything I got block and error message appears. I can't see anymore where I got wrong on this code.

Anyone could help me?

IF (@error = 0) AND (@object_type in ('13')) AND (@transaction_type IN ('A'))
		BEGIN
			select @sTmp = 'TRUE',
				   @error_message = 
						case
							when ( T1.Price != T2.Price  ) then 'Price dismatch with base document! Please review the price!'
						end


			FROM [dbo].[OINV] T0 
				INNER JOIN [dbo].[INV1] T1 ON T0.[DocEntry] = T1.[DocEntry] 
				LEFT JOIN [dbo].[RDR1] T2 ON T2.[DocEntry] = T1.[BaseRef]
				INNER JOIN [dbo].[ORDR] T3 ON T3.[DocEntry] = T2.[DocEntry]
				where T3.[DocEntry]  = @list_of_cols_val_tab_del              
				and (
					 ( T1.Price != T2.Price )
					)


			if (@sTmp <> 'FALSE')
			begin
				set @error = 1
			end
		END


View Entire Topic
Abdul
Active Contributor

Dear it seems you are creating the invoices based on the sales order, so try below

IF @transaction_type IN ('A','U') AND @Object_type = '15' BEGIN

IF EXISTS (SELECT T0.[DocNum] FROM INV1 T0 where T1.Price <> (Select (RDR1.Price) FROM RDR1 where RDR1.ItemCode = T0.ItemCode and RDR1.LineNum = T1.Baseine and RDR1.DocEntry = T1.Baseentry ) and T0.DocEntry = @list_of_cols_val_tab_del) BEGIN SELECT @Error = 1001, @error_message = 'Price is wrong' END END

former_member469301
Discoverer
0 Kudos

Hi Sr. Abdul,

First of all I really wonder to thank you for your help, very useful and makes my idea possible. I just had to do a little adjust in code to work for me.

In this section of the code I made this changes, and everything happen.

Thank you so much!!!

IF EXISTS (
			SELECT T0.DocEntry 
			FROM INV1 T0
			where T0.Price <> (Select (RDR1.Price) FROM RDR1 where RDR1.ItemCode = T0.ItemCode and RDR1.LineNum = T0.BaseLine and RDR1.DocEntry = T0.BaseEntry ) 
			and T0.DocEntry = @list_of_cols_val_tab_del
	)