Skip to Content
avatar image
Former Member

Need modification SPT

Hi experts

i need to some modification in SPT

In this SPT i need either Cost center or Project, any one should be Noted in the JE, when i add using OR its not working

the below given is the SPT Coding

pls guid to sort it out

Regards

IF (@Object_Type='30') AND (@transaction_type in ('A', 'U'))
BEGIN 
	IF (EXISTS (SELECT T0.Account FROM JDT1 T0 INNER JOIN OACT T1 ON T0.Account = T1.AcctCode WHERE T1.GroupMask IN ('4','5','6','7') and ISNULL(T0.ProfitCode, '') = '' AND  T0.TransId = @list_of_cols_val_tab_del))
	BEGIN 
		SET @error = 10 SET @error_message = N'Its Mandatory to Choose The Cost Center Code / Project Code, For any Clarification Please Contact Finance Department'
	END
END
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 20, 2016 at 11:55 PM

    Hi Shahan

    You need add the new field in your where clause.

    IF (@Object_Type='30') AND (@transaction_type in ('A', 'U'))
    BEGIN 
    	IF (EXISTS (SELECT T0.Account FROM JDT1 T0 INNER JOIN OACT T1 ON T0.Account = T1.AcctCode 
    		WHERE T1.GroupMask IN ('4','5','6','7') AND 
    		(ISNULL(T0.ProfitCode, '') = '' OR  ISNULL(T0.Project, '') = '') AND  T0.TransId = @list_of_cols_val_tab_del))
    	BEGIN 
    		SET @error = 10 SET @error_message = N'Its Mandatory to Choose The Cost Center Code / Project Code, For any Clarification Please Contact Finance Department'
    	END
    END
    

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Shahan

      I understood that Cost Center and Project are mandatory. In my previous query the two fields should be filled.

      If what you need is that Cost Center OR Project should be filled, this is the correct query:

      IF (@Object_Type='30') AND (@transaction_type in ('A', 'U'))
      BEGIN 
      	IF (EXISTS (SELECT T0.Account FROM JDT1 T0 INNER JOIN OACT T1 ON T0.Account = T1.AcctCode 
      		WHERE T1.GroupMask IN ('4','5','6','7') AND 
      		(ISNULL(T0.ProfitCode, '') = '' AND  ISNULL(T0.Project, '') = '') AND  T0.TransId = @list_of_cols_val_tab_del))
      	BEGIN 
      		SET @error = 10 SET @error_message = N'Its Mandatory to Choose The Cost Center Code / Project Code, For any Clarification Please Contact Finance Department'
      	END
      END

      Kind Regards,

      Diego Lother