SBO - Approval Procedures at row level

Does anyone know how to create an approval procedure that is triggered by a row field. For example if I want an approval procedure that verifies discount percentage in row level.
There must be a workaround, cause I know this is not a functionality in SBO.
Thanks,
Hernán Baudrit

The way you could solve this is to create a UDF at Header level and link a formatted search which loops through the number of rows in the transaction and returns TRUE if for example the Discount % is greater than allowed.
The coding should be something as follows:
Declare @Counter as integer
Set @Couter = 0
Declare @TempTable TABLE (STAT varchar(50)) -- Temporary table holding results of loop
Declare @LoopFor as integer
Set @LoopFor = (select (*) from (select T1.DocEntry
                                                          from INV1 T0 join OINV T1 on T0.DocEntry = T1.DocEntry
                                                                  where T0.DocNum = $[OINV.DocNum])
While @Counter < @LoopFor
BEGIN
      Declare @Disc as integer
       Set @Disc = ( select T1.DiscPrcnt
                                        from INV1 T0 join OINV T1 on T0.DocEntry = T1.DocEntry
                                                   where T0.DocNum = $[OINV.DocNum]) and T1.LineNum = @Counter
     IF @Disc > 20
     BEGIN
              INSERT @TempTable VALUES ('TRUE')
     END ELSE INSERT @TempTable VALUES ('FALSE')
@Counter = @Counter + 1
END
SELECT Distinct 'TRUE' from @TempTable where STAT = 'TRUE'
Please note that the coding is not 100% accurate but should give you an idea of how to work around the problem.
Next you should write a simple validation query on the value of the UDF to check whether it is set to 'True'.
I hope this helps.

Similar Messages

  • Approval Procedure workaround

    Hi Experts,
    Our client is currently using SBO 2007 A SP00 PL 47 and they want that the approval procedure will have levels during approval. This means that the 2nd approver will not receive the initial approval request, but only after the approver 1 approves the document. I know we don't have this functionality right now, but can you suggest any workaround or any query approval that will accommodate this requirement?
    Many thanks.
    Don

    Hi Don,
    This is standard SAP B1 functionality.
    You can setup multiple Approval Stages, Eg. First level needs to be authorised by the Sales Manager.  Then set up a second stage, eg. Second Level needs to be authorised by the Sales Director.
    On your Approval Template Stages Tab, select the First Level stage first, then underneath it select the Second Level stage.
    Now when a document needs to be approved, it will only go to the Sales Director once it has been approved by a Sales Manager.
    I hope this answers your question.
    Regards,
    Adrian

  • Approval procedure when update sales order that hasn't been approved

    Dear Experts
    I need some advice
    Example:
    - BP credit limit = 100
    - Create New Sales order with amount 90, doesnu2019t need trigger approval procedure, because the amount is still under limit
    - Update the SO amount to be 110, approval procedure should be triggered
    But in SBO, approval procedure is not triggered for update transaction even for SO has not yet been approved, is it a bug? Will it be improved in SBO 8.8?
    Is there any other way to trigger approval procedure in update mode? May be through store procedure or add on?
    Really appreciate your help
    Best Regards
    JeiMing

    Dear Gordon
    I understand the concept for approval will not be triggered anymore for approved SO, because once a transaction has been approved, user will not be allowed to make any changes that related with the approval. And SBO has been made restriction for that. It is good
    But, It doesn't make sense, for SO that even the approval has not been yet executed. And SBO still allow user to make any changes such as quantity and total amount. And SBO do not trigger the approval if the modification meet approval condition
    If SBO was designed not trigger approval in update mode  to avoid endless loop as what you said, why SBO still allow user to make any changes in unapproved SO ? it makes user can avoid the approval
    Don't you think this is a bug ?
    Please advice
    Best Regards
    JeiMing

  • Approval Procedure - SAP loses the changes to the document

    Good morning to all.
    I need an explanation regarding the approval procedures.
    We have recently upgraded the system from version 2007 SP01 PL10 to version 8.81 PL10.
    We have a approval procedure whit 2 level:
    User A => Create the document
    User B => First level approval.
    If User B approve the document then
    User C => Final level approval
    I noticed that in the previous version, during the phase of approvals, was created a single record in the table ODRF. This record was updated with various changes made by users during the approval phase. The changes made ​​during the approval phase regarding UDF
    Now, with the new version, I find myself with the table ODRF registering a record for each change made to the document that is pending approval.
    So, if User B open the document pending approval, saves it as a draft, then edit some UDF and still saves as a draft, in ODRF table we have 2 line (the first for the first save, the second for the UDF edited and so on...)
    But, when you invoke the document itself to approve or modify it, it always loads the first record from the table ODRF, thus losing all the changes.
    Do you have news about this situation? Are there solutions?
    Sorry for my english...

    Hi GORDON.
    Thank for your reply
    After talking with our partners, I confirm that version 8.81 is not possible to make changes to the UDF fields in a document during the approval phase.
    More precisely, the changes can be made, the document can be saved as a draft during the approval procedure, but at the time of approval, the changes are not shown.
    This is because, in the drafts table (ODRF), unlike what happened in the 2007 SP01 PL10 and even in version 8.80, the changes are saved in other records (line) with other draft number ID respect to the original record, and therefore no longer recoverable and / or visible .
    And, I do not understand why, there is no trace in any official document about SAP to that change.
    Sono incazzato....

  • Approval on Row Level

    Hi All,
    I like to set approval on rows where Unit Price is Greater then U_MRP approval should goes to concern heads.
    Is is possible to set approval on Row Level.
    I am using SBO 2005 B, PL 38
    Warm Regards,
    Chintesh Soni

    Hi,
    There is a pdf file relate to approval procedure query that could be used to create approval procedure on the row level. You could also try to browse this link:
    http://blogs.ittoolbox.com/sap/kehinde/archives/approval-procedures-line-level-and-header-level-part-1-9662
    I also try to find the pdf file about it and if I find it I will let you know
    I suggest you to try to create UDF and Query FMS where the UDF is the result of the deviation between unit price and U_MRP.  E.g. Dev_UP. Dev_UP = Unitprice - U_MRP
    The query FMS could be like this :
    $[$38.14.0] - $[$38.U_MRP.0]
    Assign  the query FMS, to the U_Dev_UP and then create a query approval procedure for the U_Dev_UP where the query should state that U_Dev_UP must be as same as zero if not that it should ask approval request. Let me know if you need more detail. Or just mail me.
    Rgds,
    [email protected]

  • Stored Procedure based on Row Level

    Hi
    I have created a Stored Procedure that works perfectly off the Header Level but not on the Row Level, the query is as follows:
    IF @transaction_type='A' AND @Object_type = '13'
    BEGIN
    --AR Invoice
    IF EXISTS (SELECT T0.DocEntry FROM [dbo].[OINV] T0 WHERE T0.Project ='0' OR T0.Project IS NULL AND T0.DocEntry = @list_of_cols_val_tab_del)
    BEGIN
    SET @Error = 10
    SET @error_message = 'Please select Project Code under Accounting Tab > BP Project'
           END
    END
    Now I want to base it off Table - INV1, Field - Project, when executing it in SQL Server all seems good but once running in SBO the Stored Procedure does not trigger causing the user to bypass selecting a Project from the Project Field which is Mandatory; could this be down to T0.DocEntry as there is a DocEntry in INV1 and none in OINV?
    Any suggestions will be appreciated.
    Regards
    Kurt Walters

    Try this one:
    IF @transaction_type='A' AND @Object_type = '13'
    BEGIN
    IF EXISTS (SELECT T0.DocEntry FROM dbo.INV1 T0
    WHERE (T0.Project ='' OR T0.Project IS NULL) AND T0.DocEntry = @list_of_cols_val_tab_del)
    Begin
    SET @Error = 10
    SET @error_message = 'Please set Project Code on every line !'
    End
    END

  • Approval in Row level

    Dear Frnds,
    I want to create one approval process in sales order.
    In sales order row level i have one dimension named as SBUHead,For multiple items there should be only one SBU Head for ex :- "KA" and i enter their as "KA", so approval should gone to SAP userid "KA". When we login through KA in SAP then i should get that approval alert.
    Is it possible or not? if yes then how to write the query for it?
    Please guide me.
    Regards,

    Hi
    Approval Procedure does not work on row level data. It might work when there is only one row but not when there is more than one.
    To block the transaction using the SBO_SP_TransactionNotification Stored Procedure.
    For Ex:
    Approval for Discount in Sales Doc.:
    Select Distinct True Where ($[$38.15.0] > 0)

  • Query base multiple levels  PO approval procedure

    Hi,
    My customer is having following requirement for PO approval procedure and would like to seek for solution.
    The suppliers are either CAPEX or OTHERS supplier which I think of using UDF U_CAPEXSUPPLIER=Y or N in BP master setup.
    OTHERS supplier PO
    <RM2000 approved by local accounts
    >RM2000 approved by CFO or one of directors
    CAPEX supplier PO
    <RM5000 approved by CFO
    >RM5000 approved by one of Board of Directors
    The 2000 and 5000 figures are applicable to both local and foreign purchase. ie if it USD suppliers then limit is USD2000
    Thanks and regards
    Thomas

    Thomas,
    Open Query Generator....Click Execute.....With the Red message at the bottom..you will see the SELECT *
    click on the Pencil icon and copy over each of my queries and save it using a different name.
    Then Add an Approval Stage for each Approver..
    Using the Approval Template..Give a Name...Make Sure Active check box is CHECKED next to the Name
    Select the Originators (users whose document should go through the approval process)..In the document tab select the documents for which this approval applies..Stages Tab..select the associated Approval Stage defined earlier..
    Term tab: Select When the following Applies
    In the lower window...double click onn the first row under Query Name..Select your query and ADD. 
    Make Sure Active check box is CHECKED next to the Name
    Suda

  • Query for terms in approval template of approval procedure

    dears
    i need to write  a user query for approval template terms that chek for any price zero in invoice items .
    i tried the true query
    select 'true' from inv1 where $[inv1.price]=0
    however the invoice executed without asking for approval procedurs.
    any help will be appreciated!!
    talal

    Hi,
    Its not possible on row level Price.
    Try to Document total procedure, it will work.
    SELECT Distinct 'True'  FROM OINV T0 WHERE $[OINV.DocTotal]='0.00'
    Thanks,
    Madhan.

  • Row Level Security using BO SDK - Dynamic Group and Criteria (where clauses)

    To the Universe Gurus out there:
    I have a rather daunting task of implementing a Row Level Security on a number of tables within our project using BO XI R2 SP2 with SQLServer 2005. Given the nature of the requirements around this (listed below), I am going to go with BO SDK to accomplish the creation of Restrictions. That said, I need some insight into some of the problem areas I have listed below. Any help is much appreciated.
    Background:
    We have 11 tables that are to be restricted.
    Each table is accessible to potentially 1..* group of users only.
    For eg SALES is accessible to ALL_SALES members only.
    Each row within each table is accessible to 1..* groups of users only. The restriction will occur on 2 columns Jurisdiction and LineID on SALES table.
    For eg
    1)Rows with NY Jurisdiction and LineID=123 are accessible to NY_SALES_ADMIN group only initially.
    2)NY_ADMIN will then approve that the above rows be open to NY_SALES_INTERNAL group only. This approval in turn will call upon the BO SDK to add a new restriction for the group with appropriate where clause.
    3)At a later point, the above rows will be opened to NY_SALES_EXTERNAL group also.
    This same concept holds good a number of jurisdiction (more or less static) and a dynamic number of LineIDs. So, if 10000 rows of data corresponding to new LineID 999 and Jurisdiction AK are in the table now, they are initially accessible only to AK_SALES_ADMIN group only. No one else should be able to access it.
    Results:
    1) With the way I laid out the business rules above, I am ending up with 528 groups.
    2) There is a restriction created for a unique combination of Jurisdiction and LineID for each table.
    Problems/Questions:
    How can I restrict access to the new rows to one group only. I know that I can let a certain group only look at certain data but how can I restrict that all others cannot look at the same.
    AK_SALES_ADMIN can look at LineID=999 and Jurisdiction='AK'.
    Do I use an Everyone group based restriction? If so, my Everyone group will end up with tons of restrictions. How will they be resolved in terms of priority.
    Am I even thinking of this the right way or is there a more noble way to do this?
    Regards

    the connectinit setting should look something like this:
    declare a date; begin vpd_setup('@VARIABLE('BOUSER')'); Commit; end;
    The vpd_setup procedure (in Oracle) should look like this:
    CREATE OR REPLACE procedure vpd_setup (p_user varchar)IS
    BEGIN
      DBMS_SESSION.set_vpd( 'SESSION_VALUES', 'USERID', p_user );
    END vpd_setup;
    Then you can retrieve the value of the context variable in your vpd functions
    and set the vpd.

  • Approval procedure on item groups

    Hi All
    I would like your assistance on this query, I need a query that will execute an approval procedure when an item with item group name contains or part of the word software is used on the sales quote . 
    I need to know how can i pull the item group from a selected item and display that on a udf and use info on that udf to trigger an approval .
    Thanks
    Bongani
    Edited by: Bongani Dlamini on Jul 13, 2009 1:25 PM

    hai Bongani Dlamini
       Row level approval is not possible in SAP B1,as a work around try this query in approval template,this will help u to check
    only first item,other wise u have to write stored procedure
    SELECT DISTINCT 'True' FROM QUT1 T0 WHERE $[$38.1.1]  =
    (select distinct  itemcode from oitm o1,oitb o2  where
    o1.itmsgrpcod = o2.itmsgrpcod and o1.itemcode = (select $[$38.1.1] ) and o2.ItmsGrpNam like '%Software%'  )

  • Delivery date and approval procedure

    Hello,
    My customer has the next problem. He generate a purchase order after approval procedure was ended. sometimes he wants to update the delivery date field in the row of the purchase order, but he can't do so because approval procedure restrict any changes in row level.
    what can be done to solve it.
    thank you all

    It is always very interesting how people seem to simply accept that the system can not perform basic functions.
    In our company, we are facing some critical issues because of this problem. E.g: a purchase order has been approved and teh supplier rings to inform us of supply delays. The procurement officer can not update the delivery date on the purchase order to document the updated delivery day.
    This is obviously causing some major drama at the warehouse as they rely on the delivery date of purchase orders to prepare the space required to receive goods.
    This is also impacting the work of the procurement manager who will possibly ring the supplier to inform him of delays when relasticly, the company has already been informed.
    The approval process in SAP Business One is lacking a basic function of "loop" or simply a system to identify non critical fields which can be updated once the document has been approved (like a date, some remarks etc.).
    SAP, it is time to work on a few basic ERP things.
    Vincent Motte

  • Approval procedure vs Transaction Notification

    Hello dear experts,
    I have an issue with the approval procedures and the validations I have to do using the Transaction Notificacion Stored procedure.
    this is the scenario and conditions to consider:
    1.A purchase order (Doctotal) that are between 0 and 25,000 USD needs an approval.
    2. A purchase order needs to have all the project column filled in before the approval procedure. this column is in the detail of a document, so all the rows have to be filled in with the right project code otherwise when your request have been submmited and your receive the approval you are not allowed to do any changes in the Detail Document.
    I realized that the approval procedure is launched before the Transaction Notification SP.
    So I decided to add a query for the approval procedure considering the validations in the project column:
    SELECT distinct 'true'
    FROM OPOR
    WHERE $[OPOR.DocTotalSy.number] Between 0 and 24999.99   ---This part works perfeclty!!!
    AND LEN(isnull($[POR1.Project.0],''))>0 and $[POR1.U_SubJob.0]>0  )  --This part does not work
    As you see in the query, I am trying to validate that all the rows have the project code (Project) and a UDF (U_SubJob) filled in.
    Have anybody been done this before? How can I access to the detail values of the document? It is easy to acces values on the header.
    I appreciate any help on this. Thank you very much
    Regards,
    Mary

    Hi,
    You must use both in approval procedure or use both in SBO store procedure transaction notification.
    To request approval for a project, you this following approval query:
    if (SELECT $[$38.31.0]) > ' '
    select 'true'
    the other query is for doctotal approval as follows:
    if ($[opor.doctotalsys.number]) between 0 and 24999.99
    SELECT 'true'
    or
    select distinct 'true' FROM OPOR
    WHERE $[OPOR.DocTotalSy.number] Between 0 and 24999.99
    Both are able to use and work simultanously.
    JimM

  • Querry For Approval Procedure

    Hi All,
    I want to know that, how to generate query for Approval procedure.? I know it is started with <b>DISTINCT 'TRUE'</b>. But how to select this field. If i want to generate querry for approval of row level discount greater than 15%. How to generate it?
    Swapnil

    Dear Suda,
    Now i am telling wat i have actually done and wat is its result. Please try to understand it.
    First of all I have made the querry below-
    SELECT DISTINCT 'True', T1.DiscPrcnt AS 'Discount % per Row', T0.SlpName AS 'Sales Employee Name' FROM  [dbo].[OSLP] T0  INNER  JOIN [dbo].[RDR1] T1  ON  T1.SlpCode = T0.SlpCode   WHERE (T1.DiscPrcnt > 25  )
    In this querry i have typped DISTINCT 'TRUE' manually but keeping the SELECT table as it is.In this case the system is not asking me for any kind of discount (not greater than 25% or not less than 25%)
    After that i have modified above querry as below-
    SELECT DISTINCT 'TRUE' FROM  [dbo].[OSLP] T0  INNER  JOIN [dbo].[RDR1] T1  ON  T1.SlpCode = T0.SlpCode   WHERE (T1.DiscPrcnt > 25  )
    In this qurry i have typped DISTINCT 'TRUE' manually. When i executed this qurry i jst get the true in first row first column place.When i have attached this querry to approval, and after that when i have started for creating purchase order with the originators log in then in this case the system is asking approval for every discount from 0% to 100%.
    Wat shud i do now...Please reply ASAP.
    Swapnil

  • APPROVAL PROCEDURE THROUGH QUERY

    Dear Suda,
    Now i am telling wat i have actually done and wat is its result. Please try to understand it.
    First of all I have made the querry below-
    SELECT DISTINCT 'True', T1.DiscPrcnt AS 'Discount % per Row', T0.SlpName AS 'Sales Employee Name' FROM [dbo].[OSLP] T0 INNER JOIN [dbo].[RDR1] T1 ON T1.SlpCode = T0.SlpCode WHERE (T1.DiscPrcnt > 25 )
    In this querry i have typped DISTINCT 'TRUE' manually but keeping the SELECT table as it is.In this case the system is not asking me for any kind of discount (not greater than 25% or not less than 25%)
    After that i have modified above querry as below-
    SELECT DISTINCT 'TRUE' FROM [dbo].[OSLP] T0 INNER JOIN [dbo].[RDR1] T1 ON T1.SlpCode = T0.SlpCode WHERE (T1.DiscPrcnt > 25 )
    In this qurry i have typped DISTINCT 'TRUE' manually. When i executed this qurry i jst get the true in first row first column place.When i have attached this querry to approval, and after that when i have started for creating purchase order with the originators log in then in this case the system is asking approval for every discount from 0% to 100%.
    Wat shud i do now...Please reply ASAP.
    Swapnil

    Hi, Swapnil!
    You are on the right path, but I'm not sure if you can run this approval procedure at the line level.
    The queries you had are against the wrong table (RDR1 is a Sales Order table) and are missing the link to the active document. You have to add the reference to the active document or else you are pretty much querying against the entire RDR1 table.
    You need something like this:
    SELECT CASE WHEN ($[$38.15.Number] > 25) THEN 'True' ELSE 'False' END
    38 is the grid and 15 is the column for the discount.
    I tried a basic case and it didn't work. I think you need to loop through all the lines, but I'm not sure how to do this.
    You might have to create a header level UDF that changes automatically when the discount column changes, and has some logic to keep the highest discount you have on all the lines (something like: if discount greater than already stored value, update stored value) In the end, monitor this UDF for your approval procedure.
    Hope this helps!
    Liviu

Maybe you are looking for