Dear Experts ,
I am trying to make a transaction which, in case a value in a specific line is 'Approved',the line must not be updated .
The field(U_Status) is in the table 'ZAM_ACT' and the object id is in the table 'ZAM_TSHEET'.
The two tables are connected with the DocEntry where DocEntry from 'ZAM_ACT' is the same for every line and DocEntry for 'ZAM_TSHEET' is unique.
The code i am trying is the folowing :
IF @object_type ='ZAM_TSHEET' AND @transaction_type IN ('U')
begin
DECLARE @DocLine NVARCHAR(20)
DECLARE @Status NVARCHAR(14)
SET @DocLine = 0
WHILE @DocLine = (SELECT COUNT(DocEntry) FROM [@AZAM_ACT] WHERE DocEntry =@list_of_cols_val_tab_del)
BEGIN
SET @Status = (SELECT U_Status FROM [@AZAM_ACT] WHERE DocEntry =@list_of_cols_val_tab_del AND LineId = @DocLine)
IF (@Status = 'Approved' )
BEGIN
SET @error=300216
SET @error_message=N'Not allow this change.Please choose an activity with a different status!'
END
SET @DOCLINE = @DOCLINE + 1
END
end
Best Regards