Skip to Content

Hi all,

Today I will write a little about approval template, I went through a situation recently with this resource and I would like to share my experience.

Recently on the SAP B1 SDK space, appeared a thread asking help to do a query for approval template on the line level of the document. After read a little about this subject, I saw in many other threads in the SAP B1 spaces, comments talking that is not possible use information of the line level to build approval templates.

At the company that I work I know that are done approval templates on line level, then, I went check this resource and I got those considerations:

Is it possible to use approval templates at the line level?

Yes, it is.

Is it possible to do a query for approval template using data from header and line together?

Yes. it is.

A real sample: Approval template for sales order.

e.g. Line level

At this query, I don’t want that SAP allow sales order with any line with discount greater than 20 %


SELECT CASE WHEN $[$38.15.NUMBER] > 20 THEN 'TRUE' ELSE 'FALSE' END

e.g. Header level

At this query, I don’t want that SAP allow sales order with header discount greater than 20%.


SELECT CASE WHEN $[$24.0.NUMBER] > 20 THEN 'TRUE' ELSE 'FALSE' END

e.g. Header and line level

At this query, I don’t want that SAP allow sales order with any line discount greater than 20% for the customer C00001


SELECT CASE WHEN $[$38.15.NUMBER] > 20 AND $[$4.0.0] = 'C00001'  THEN 'TRUE' ELSE 'FALSE' END

Is it possible group values from the lines in query, from approval templates?

No. The query will be executed line by line, and if any of them returns ‘TRUE’, the approval procedure will be started. Because of this execution, line by line is not possible use resources like SUM(valor), for example.

Obs.: After some tests, I saw that the sintax $[TABLE.FIELD] doesn’t work correctly on approval template, so, in the scenarios that I mentioned, our queries should use always the sintax $[$ITEM.COL].

The information shared here, were tested on SAP B1 9.0 PL 11  and 9.1 PL 12.

That’s all folks, hope it helps.

Leave your feedback about this subject and share your experience about it.


Best regards,

Diego Lother


View Diego Lother's profile on LinkedIn

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Chia-Wei Hsu

    Hi Diego,

    Thanks for this great sharing.

    I tested it and wonder why your query works

    SELECT CASE WHEN $[$38.15.NUMBER] > 20 THEN ‘TRUE’ ELSE ‘FALSE’ END

    but below one fail?

    SELECT CASE WHEN $[$38.15.0] > 20 THEN ‘TRUE’ ELSE ‘FALSE’ END

     

    Best regards,

    Alex Hsu

    (0) 
    1. DIEGO LOTHER Post author

      Hi Chia-Wei Hsu,

       

      This happens because in the first case I cast my variable as number, so, the comparision is number (variable) with number(20).

      On the second query you cast your variable to a string. The sintax “0” represent a cast as string. So, the comparision is string(variable) with number (20). Then fails.

      Hope it helps.

      Kind Regards,

      Diego Lother

      (0) 
  2. Damian Grabowski

    Diego,

    I will double check your solution, but I am almost 100% sure that I already tried that before and the QUERY was executed only for the first row of the document.

    Best regards,

    Damian

    (0) 
    1. DIEGO LOTHER Post author

      Hi Damian,

      Maybe in older versions of SAP Business One. I tested on SAP B1 9.0 PL 11  and 9.1 PL 12 and works fine. Approval procedure execute line by line. If something not work for you let me know.

      Kind Regards,

      Diego Lother

      (0) 

Leave a Reply