Thursday, October 1, 2015

Block document(per line) using SBO_SP_TransactionNotification

Most of our client are in production and service industry that require per document(lines) blocking. However, we've encounter some limitations in SAP Business One on how to block transaction using SBO_SP_TransactionNotification per line. Most of the solutions in scn.sap.com are in per document(header). So I decided to study and tweak the SBO_SP_TransactionNotificationSBO_SP_TransactionNotification is a stored procedure is to receive notification on any transaction - in other words to do some validation inSAP Business One and prevent the user from doing an action if the validation condition fails. This stored procedure(SP) is created automatically with each database.This stored procedure is fired whenever operations are performed on business objects like document or master records and User-Defined Objects. For more information about the SBO_SP_TransactionNotification or if you don't know how to use SBO_SP_TransactionNotification you may visit this post from scn.sap.com.

Back to our concern, I'll show you on how to achieved that requirements. For example, I want to block all the documents that are in the Item Group of 118 and 120 and also the Customer that has 'CI-' in their code.



 IF (@object_type = '17' AND @transaction_type IN ('A', 'U'))  
      BEGIN   
           SELECT TOP 1 @LINENUM = b.linenum  
                FROM ORDR a inner join RDR1 b on a.DocEntry = b.DocEntry  
                INNER JOIN OITM c on b.itemcode = c.ItemCode  
                          WHERE b.DocEntry = @list_of_cols_val_tab_del and c.ItmsGrpCod in ('118','120') and a.CardCode not like 'CI-%'  
           If NOT @LineNum IS NULL  
                Begin  
                     SET @error = -17  
                     SET @error_message = 'Please select a valid Item Group applicable to your Dealer!'  
                End  
      END  

That's it. You can now block any transactions per line in your document. If you have concerns, please comment below.

1 comment:

  1. How was @LINENUM declared and how does it relate to the submitted transaction set?

    ReplyDelete