Introduction

Sometimes it is necessary to block transactions in SAP. For example manual bookings to the inventory account, or a wrong currency in a price list and so on. Because there are many ways to modify data in SAP (UI, AddOn, B1i, other connectors), the one and only way to validate data is the SAP transaction notification.

There will be 2 parts about this topic:

  • SAP Business One Transaction Notification Part 1
    How the transaction notification works, How to build a debug table
  • SAP Business One Transaction Notification Part 2 (this post)
    Example for a price list validation
  • SAP Business One Transaction Notification Part 3
    Example for a validation on multiple sales documents

Scenario: price lists with currency restrictions

In SAP B1 it is possible to create different price lists and users can fill prices and currencies without any restrictions to the list which is sometimes not asked for. The aim of following transaction notification is to avoid wrong currencies in certain price lists.

Implementation

The implementation contains 2 steps:

  • Set valid currency for each price list
  • Implement transaction notification

Set valid currency for each price list

The first step is to create a user defined field (UDF) on the price list table.

After adding the UDF, it is possible to define, currencies on the different price lists. Navigate to “Inventory > Price lists > Price lists” and define for each price list the corresponding currency.

Hint: This example has only one purchase price list which is used for more than one currency. To not restrict this list, there is no value in the Currency column.

Implement transaction notification

The second step is to implement a transaction notification which blocks wrong currencies in price lists. The explanation of the different parameters in a transaction notification can be found in Part 1. SQL snippet shown below can be pasted into the transaction notification like the other example in Part 1:

IF @object_type = '4' AND @transaction_type IN ('A', 'U')
BEGIN
    IF
    (
        SELECT COUNT(*)
        FROM ITM1 T0
        INNER JOIN OPLN T1 ON T0.PriceList = T1.ListNum
        WHERE CAST(T0.ItemCode AS NVARCHAR(255)) = @list_of_cols_val_tab_del
        AND T0.Currency <> T1.U_Currency AND T1.U_Currency <> '' AND T0.Price <> 0
    ) > 0
    BEGIN
        SET @error = -1
        SET @error_message = 'Transaction Notification: Please choose correct currency'
    END
END

First, the snippet checks, if the user wants to add or update an item, which has the object type 4. Important is the WHERE-part of the snippet: The rule only checks the item, which the user updates with the parameter @list_of_cols_val_tab_del. This speeds up the process. The rest of the WHERE-part is simpe: It compares the currency in the price list (ITM1-table) with the value in the UDF of the OPLN-table. The U_Currency should not be empty, because the small exception of the purchase price list. To avoid blockers when the prices are zero, it filters only for prices which are <> 0.

Result

That’s it. If the user fills correct prices, nothing happens. If the user chooses a wrong price, he gets blocked and receives a message like in the print screen below:

 


Geri Grenacher

ERP Project manager at coresystems ag, Switzerland

7 Comments

Eduardo · September 4, 2013 at 18:42

Hi,

How can I check on a transaction if the new value is different from the previous value when it comes from the same field.


Eduardo

Geri Grenacher · September 5, 2013 at 05:09

Hello. It depends, on which table you are checking those values. If you check for example OITM (items) I think it would possible to compare it with the AITM (items history) or whatever. An easy way to do such validations, how I would make it, is with the coresuite country package. This is the best choice for validations, form enhancements and so on.

Isaac Kalii · August 11, 2014 at 05:45

Hi, how can I block an entry in a UDT if the same entry enty exists in the UDT? Thanks.

Geri Grenacher · August 11, 2014 at 06:41

Hi Isaac. Normally the code column of the UDT is unique. There is no need to block something, because it is not possible to do an entry twice.

SAP Business One Transaction Notification Part 1 | Geri Grenacher · October 13, 2013 at 04:55

[…] SAP Business One 8.81 menu icon with customize and Photoshop SAP Business One Transaction Notification Part 2 […]

SAP Business One Transaction Notification Part 3 | Geri Grenacher · July 31, 2014 at 09:56

[…] Business One Transaction Notification Part 2 Example for a price list […]

Dynamic SAP Business One Transaction Notification | Geri Grenacher · November 14, 2014 at 09:19

[…] did already some blog posts about SAP transaction notifications (Part1, Part2, Part3). This blog shows a specific kind of transaction notification when you need to validate […]

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *