Approval procedure query help

Hi there,
at the moment i am creating an approval procedure. This should check if a sales man enter a price that is less than the price from the standard price list. If it is, it should check if the customer already got this price.
If the customer got this price, there is no approval necessary. If the customer did not get this price, an approval procedure should be started.
I started to write this query, ith the idea to check a sum of two price for the approval. But i get an error if i insert this query.
DECLARE @x numeric(18,4)
SELECT @x= (SELECT $[$38.14.])
SELECT @x-T0.Price
FROM ITM1 T0
INNER JOIN OCRD T1 ON T1.CardCode = $[$4.0.0]
WHERE T0.Pricelist = T1.ListNum and T0.ItemCode = $[$38.1.]
Has anyone another idea or tips to solve my issue ?
Regards Steffen

Hi Gordon,
thanks for your reply, i inserted your query and it works from the point, thats not possible to create a order with prices less than standard prices. The system gives this error message :
Could not commit transaction '' (ADOC)
I think, like Suda already explained, the problem is, that it is not possible to base approval on row lines.
What do you think ?
Thanks Steffen

Similar Messages

  • PO approval procedure query

    Hi Everyone I am trying to create a Query for an approval procedure. I have created a user defined table that has a value with a certain budget. Each time a PO is about to get added it checks the budget table to make sure it has not exceeded the budget amount
    Example:
    Budget table has value of $1000 dollars
    1) A PO of $500 hundred dollars is about to get added the query runs and checks against the budget table , the amount is not exceeded and the document gets added.
    2)  A PO of $300 hundred dollars is about to get added the query runs and checks against the budget table , the amount is not exceeded and the document gets added.
    3) A PO with the amount of $400 is about to get added the query runs and checks against the budget table, the amount has been exceeded(total of $1100) the query triggers the approval procedure and the document becomes a draft and waits for approval.
    Here is what I have so far for the query:
    SELECT CASE WHEN SUM(T0.DocTotal)>T1.U_POBUDGET THEN 'TRUE' ELSE 'FALSE' END
    FROM [dbo].[OPOR] T0 INNER JOIN OSLP T1 ON T0.SlpCode=T1.SlpCode
    WHERE T0.TaxDate BETWEEN '4/1/08' AND '4/30/08' AND T0.CardCode=T0.CardCode AND  T0.SlpCode=9
    GROUP BY T1.U_POBUDGET
    I also need the query to be within the range of the current month. Can someone please help me with this thanks

    I do not see that you are referencing the Budget value from your UDT.  Are you saying UDF which is created in the OSLP table?
    Check this
    SELECT 'TRUE' FROM [DBO\].[OPOR\] T0 INNER JOIN [DBO\].[OSLP\] T1 ON T1.SLPCODE = T0.SLPCODE
    WHERE T0.SLPCODE = $\[OPOR.SLPCODE] AND T0.TAXDATE BETWEEN '04/01/2008' AND '04/30/2008'
    GROUP BY T1.MEMO
    HAVING SUM(T0.DOCTOTAL)+$\[$29.0.NUMBER] > T1.U_POBUDGET
    Hard coding the dates might not be a good way to setup the Approval.  for testing purpose it is OK.
    You could try something like MONTH(T0.TaxDate) = MONTH($\[OPOR.TaxDate])

  • SO approval procedure query

    Hi Suda, I am trying to create a approval procedure for a query here is what I have so far:
    SELECT DISTINCT 'TRUE'
    FROM  [dbo].[OITW] T0  INNER  JOIN [dbo].[RDR1] T1  ON  T1.[ItemCode] = T0.[ItemCode] 
    WHERE T1.ITEMCODE = $[RDR1.ITEMCODE] AND T1.WHSCODE=T1.$[RDR1.WHSCODE] AND $[$38.14.NUMBER]<T0.AVGPRICE
    I basically want to check the price of the Unit Price field in the Sales Order against the avg price of an item  that is in the inventory if the Unit field price is less than the average price than the approval procedure should get triggered. I am not sure why the query is not working can you please help me with this. Thanks.

    The transaction notification is a hard block.  It will prevent the transaction from getting added and no drafts are saved.
    But we can give a message to the user asking him to save as draft.
    Search on this link https://websmp204.sap-ag.de/notes for term SBO_SP_TransactionNotification and you will find document explaining the usage of this.
    Please also search the term SBO_SP_TransactionNotification in this Forum.
    There are many threads that I have replied.
    Suda

  • Approval Procedures - Query Base Issue

    Hello Experts,
    I have Set the Approval Procedures in SAP base on One Query
    Query is If Purchase Order Document No > then 29000 then go for Approval Process other wise not going for Approval Procedures
    My Query is
    < SELECT DISTINCT 'True' FROM OPOR N0 where N0.Docnum >'29000' >
    NOW PROBLEM IS WHEN DOCUMENT NO IS 321 THEN SYSTEM GOING FOR Approval Procedures,
    this is to be worng.
    Please guide me
    Dixit Patel

    Hi Dixit.........
    Try this......
    Select Distinct 'True' From OPOR T0 Where T0.DocNum>29000 and
    T0.DocNum=$[OPOR.DocNum.Number]

  • What's wrong with my approval procedure query ?

    Hi everybody,
    This is my query :
    SELECT DISTINCT 'TRUE' FROM RDR1 WHERE $[$38.U_Prix_plancher.number] >=$[$38.Price.number]
    What's wrong with that ?
    Thanks
    Ara

    Ara,
    The problem is not with your Query but the problem is with the way the Query gets trigerred for an Approval Process.
    SAP only recognizes the value of a $[$38.x.x] parameter when that particular row is active.
    I suggest you can test this by simply highlight that particular row which breaks the rule and try to Add the document and you will see that the Approval Procudure will fire.
    Also remember an Approval Procudure works only when you are in Add Mode and does not on Update.
    Regards
    Suda

  • Approval Procedure Query

    Hi, all
    I create U_Dept at document header and I want have an approval base on this U_Dept input. For eg, U_Dept input = A or B. I save 2 queries as below:
    Query A
    SELECT distinct 'true' from OQUT T0
    WHERE T0.U_Dept = 'A'
    Query B
    SELECT distinct 'true' from OQUT T0
    WHERE T0.U_Dept = 'B'
    2 Approval Stage created = manager A and manager B
    2 Approval Template created =
    Template 1 put in Query A, approve by manager A
    Template 2 put in Query B, approve by manager B
    Both template with same originator
    When I simulate the transaction, prompt 2 approval templates either I choose Dept A or Dept B. The result that I wish to reach is if I choose Dept A, template 1 prompt else if I choose Dept B, template 2 prompt. Can this be done?
    Regards
    Cheh Lu

    Hi,
    Try this query if other's query failed:
    For query B:
    if $[oqut.U_Dept] = 'B'
    select 'true'
    for query A:
    if $[oqut.U_Dept] = 'A'
    select 'true'
    Create 2 templates i.e. for A and B. before create 2 templates, you create 2 stages for A and B. Both stages are used different approver.
    The stage A and B are applied to template A and B. it will works fine.
    JimM

  • 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.

  • Query for Credit Limit Approval Procedure

    Hi experts,
    Need your help with an approval procedure query. There is already the option to launch when the BP's balance exceeds the credit limit by a set dollar amount. What we would like is for the procedure to launch when the balance exceeds an additional 10% of their credit limit.
    Ex: Customer's credit limit = $1,000. We want the approval procedure to kick in when the sales document causes their balance to be >= $1,100. Thanks.

    Adding this to the WHERE clause will include the DocTotal
    T0.Balance + $[$29.0.Number]
    SELECT distinct 'true' FROM OCRD T0 WHERE T0.CardCode = $[OINV.CardCode] AND
    (T0.Balance + $[$29.0.Number]) >= T0.[CreditLine] * 1.1

  • Approval procedure in Add On

    Dear All
        In SAP B1 new version 8.82 have approval procedure. please help me a question below:
        In SAP. user account 01 create A/R credit memo DocNo(01) --> it save approval pending.
                    user manager --> approval A/R credit memo DocNo(01) --> A/R credit memo DocNo(01) is created. --> End process. --> success.
        In Add On. I use account:    user account 01 Create A/R credit memo DocNo(02)  -> it save --> A/R credit memo DocNo(02) is created. -->End process. --> no success with approval procedure
        I want to Add On with approval procedure the same as in SAP
        And Add On Code below:
    Input A/R invoice with Object = 13, DocEntry  > to add A/R Credit memo> no success with approval procedure
                    Public Function SO_Return(ByVal DocEntry As Integer, ByVal ObjType As Integer) As Integer
            Dim i As Integer = -1
            Try
                Dim oObj As SAPbobsCOM.Documents
                If ObjType = 13 Then
                    oObj = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
                    ' set properties of the Order object
                    oObj.GetByKey(DocEntry)
                    Dim oARCreditMemo As SAPbobsCOM.Documents
                    oARCreditMemo = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oCreditNotes)
                    oARCreditMemo.CardCode = oObj.CardCode
                    oARCreditMemo.DocDueDate = oObj.DocDueDate
                    oARCreditMemo.NumAtCard = oObj.NumAtCard
                    If oObj.Lines.Count = 1 Then
                        oARCreditMemo.Lines.ItemCode = oObj.Lines.ItemCode
                        oARCreditMemo.Lines.Quantity = oObj.Lines.Quantity
                        oARCreditMemo.Lines.Price = oObj.Lines.Price
                        oARCreditMemo.Lines.BaseEntry = DocEntry
                        oARCreditMemo.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oInvoices
                        oARCreditMemo.Lines.BaseLine = 0 'first line
                    Else
                        MessageBox.Show("A/R Invoice have " + oObj.Lines.ItemCode.ToString() + " rows, don't return. if want, use SAP.")
                        Return i
                    End If
                    i = oARCreditMemo.Add              
                End If
                Return i
            End Function
    it add success but don't approval procedure
        This code is no success with approval procedure. Please help me.
    Thanks.

    Dear friend,
    Thanks for replying,
    But what does it mean "User must add the document through UI to trigger it"?
    Because this function is built for user input data outside SAP, I have to develop by SDK with DI.

  • Query for approval procedure - A/R invoice and A/R credit memo

    Dear all,
    Need one help regarding approval procedure.
    Query :- If we do A/R credit memo and days from A/R invoice to A/R credit memo are geter than 180 then A/R credit memo
                  shoild go to the approval. (A/R invoice shoul be a base documnet)
                  I have made below query, but if days are >180 or <180 it is goinf for a approval. Can any one suggest for this.
    SELECT distinct 'TRUE'
      FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    inner join RIN1 T2 on t2.BaseEntry=T0.DocEntry
    inner join ORIN T3 on T2.DocEntry = T3.DocEntry
    where  DATEDIFF(day,T0.[DocDate],T3.DocDate) > 180
    <a href="http://megaupload2.name/">megaupload</a>, <a href="http://www.btjunkie.name/">btjunkie</a>,  <a href="http://www.freedownloadgames.name/">games</a>

    Hi,
    Try:
    SELECT distinct 'TRUE'
    FROM OINV T0
    inner join RIN1 T2 on t2.BaseEntry=T0.DocEntry AND T2.BaseType = 13
    inner join ORIN T3 on T2.DocEntry = T3.DocEntry
    where DATEDIFF(day,T0.DocDate,T3.DocDate) > 180 AND T3.DocEntry=$[ORIN.DocEntry.number\]
    Thanks,
    Gordon

  • Link Query to Approval procedure

    Hi
    I need to create approval procedure based on query. The gist is: we have some marketing documents with the same BP. When total sum of them amounted to 10000, then approval must launch. I can't create query? moreover I can't create query for one document with over 10000. Could you send me the one with ODPO and DocTotal
    With regards
    Partner / Customer Contact: OOO Turing Consult
    English handling an option?
    Name: Maxim Groonis
    E-mail address: [email protected]
    Phone number

    Hi, Douglas.
    Thanks, you helped a little.
    Could you solve the whole problem.
    Approval procedure must launch if sum in one month (e.g. March, April not a span of 30 days)  in ODPO for one BP more than 10000.
    I insert a code (it doesn't working) only for logic
    SELECT 'TRUE' WHERE
    (SELECT SUM(DocTotal)
    FROM ODPO
    WHERE CardCode = $[ODPO.CardCode]
    and ( month(Docdate)=month($[ODPO.DocDate]) )
    and ( year(Docdate)=year($[ODPO.DocDate]) )
    GROUP BY CardCode)
    >10000
    With regard
    Maxim Groonis

  • 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

  • Query Based Approval Procedure for Sales order .

    Hi 
    I have created query for SO which results above 5000 d 50,000 .
    By using this each query i created two seperate Approval Procedures which So is >5000 d >50000.
    If So>5000 Approval Procedure wants to activate same thing for >50,000., Bur approval Procedure is not working wat will be the cause. i have linked this query In Terms as when the following applies.
    If SO >5000 approved by user A.
    If SO>50,000approved by User A & B.
    Regards
    Giridharan

    Hi Giri
    Your query for the first should be as follows:
    SELECT DISTINCT TRUE
    WHERE $[$29.0.NUMBER] > 5000 AND $[$29.0.NUMBER] < 50000
    For the second query:
    SELECT DISTINCT TRUE
    WHERE $[$29.0.NUMBER] > 50000
    The query you were trying to use is looking at the table which will only apply to documents already posted, and as that query is not being filtered specifically it is bringing back all the records and getting confused. You must reference to the runtime value of the document being posted.
    Kind regards
    Peter Juby

  • 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

  • Approval Templates: Inventory Transfer - based on Query (help)

    This is a newbie question but I don't have time to read or dig thru forum sorry.
    We have an Approval Template setup to alert/approve Inventory Transfers but it is set to Always on the Terms tab.
    We would like to modify it for only transfers into a certain set of warehouses).  How do i create a query that will determine the Warehouse Code (if warehouse code is:'WHL','ITL','RTL','WEB','CTO-WHL','CTO-ITL') on transfer and send the alert/approval notification.
    I know this has been done 1000 times over but please enlighten me.
    SELECT whsecode FROM wtr1 in ('WHL','ITL','RTL','WEB','CTO-WHL','CTO-ITL')

    Hi David......
    There are few Threads discussed on Forum that Approval Procedure for Row level is not possible. Ther may be some work around in doing this.
    You may search this post in forum as it is readily available........
    Approval procedure
    Regards,
    Rahul

Maybe you are looking for

  • Special device does not exist, FSTAB Issue

    I set up this arch64 install last night, and till now I've managed all right except for one niggling issue.  For some odd reason, when I installed everything I forgot to add my "sandbox" partition in Fstab.  I thought I could just generate a UUID the

  • [SOLVED] No prompt after update to 3.3.6-1-ARCH

    After doing an upgrade and a reboot (fail save, the otherone doesn't work) my arch stopped working (booting) Linux janus 3.3.6-1-ARCH #1 SMP PREEMPT Sun May 13 10:52:32 CEST 2012 x86_64 GNU/Linux /boot/grub/menu.lst: # Config file for GRUB - The GNU

  • Cannot remove lost mode when found findmyiphone

    Hello, I've had a good look online but cannot find anything that helps free up my phone. Phone was stolen, I located it using findmyiphone and put it into lost mode. After going to the address it was located at and getting denial (and all surrounding

  • ISE Admin Menu Access Policy and Network Resources

    Hello Board, Does someone experience the same issue as me, if using an Admin Menu Access Policy? First of all, I'm using the latest ISE release (1.1.3.124 with patch 1). I created a custom Administrator Menu Access Policy (Admin Access -> Authorizati

  • Connecting JAVA with  Video Card

    Hai,... Can someone tell me how to connect Java with a video card (like Matrox, dec-link, etc)? Because i want to display a video using that video card to a TV monitor. Is there any tutorial about this? and about connecting JAVA with other device? Th