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

Similar Messages

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

  • Query for Approval Procedure

    Hi all,
    I set up an approval procedure for sales orders, the term is based in this user query:
    SELECT DISTINCT 'TRUE'  WHERE $[$38.14.Number]<$[$38.U_PrecMin.Number]
    We need that query working for every single row of  the sales order, because it only works when it's true on row one, but when a unit price is less than the value of that UDF on row  two or above, the procedure does not work.
    Any suggestion?
    Thanks

    Hi......
    Try this in SP Transnotification.......
    If @Object_type='17' and (@transaction_type ='A' or @transaction_type ='U')
    BEGIN
    declare @Item1 as varchar(100)
    declare @minline1 int
    declare @maxline1 int
    declare @Price1 float
    declare @Price2 float
    set @minline1 = (select min(T0.linenum) from RDR1 T0 where T0.docentry=@list_of_cols_val_tab_del)
    set @maxline1 = (select max(T0.linenum) from RDR1 T0 where T0.docentry=@list_of_cols_val_tab_del)
    while @minline1<=@maxline1
              begin
              select @Item1=T0.itemcode from RDR1 T0 where T0.docentry=@list_of_cols_val_tab_del and T0.linenum=@minline1               
              select @Price1=T0.Price from RDR1 T0 where T0.docentry=@list_of_cols_val_tab_del and  T0.linenum=@minline1
                   select @Price2=T0.U_PrecMin from RDR1 T0 where T0.docentry=@list_of_cols_val_tab_del and  T0.linenum=@minline1
              if      @Price1<@Price2
                   begin
                        set @error=-1
                        set @error_message = 'Price is Less ' + @Item1
                   End
                   set @minline1=@minline1+1
              end
    End
    Regards,
    Rahul

  • Query approval procedures issue

    Hi all
    I'm creating a query for approval procedure in Sales orders. This query is working fine:
    SELECT DISTINCT 'TRUE' FROM ORDR T0
    WHERE CAST ($[ORDR.DocTotal] AS decimal(19,6))>= $[ORDR.U_Credito]
    But the one above give the following error get an error:  Could not commit transaction: Error -1 detected during transaction
      SELECT DISTINCT 'TRUE' FROM ORDR T0
    WHERE CAST ($[ORDR.DocTotal] AS decimal(19,6))>= ($[ORDR.U_Credito]*0.2)
    How can i multiply that field to get 20%.
    The field ORDR.U_Credito is type amount
    Kind Regards,
    Margarida Pedroso
    Edited by: Margarida Pedroso on Nov 6, 2011 12:21 AM
    Edited by: Margarida Pedroso on Nov 6, 2011 12:23 AM
    Edited by: Margarida Pedroso on Nov 6, 2011 12:42 AM

    Hi Margarida Pedroso,
    Try:
    IF $[ORDR.DocTotal.number\] >= ($[ORDR.U_Credito.number\]*0.2)
    SELECT DISTINCT 'TRUE'
    Thanks,
    Gordon

  • 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

  • Query about apporval procedure

    Hello Expert
    Does anyone has ever made a query for approval procedure where the customer is blocked if any payment is overdue
    Thank you

    hi G. DELANOE,
    you can use query for approval procedure with  overdue >= 15 days.
    SELECT DISTINCT 'True' From OCRD T0 inner join oinv t1 on t0.cardcode=T1.cardcode
    WHERE T0.CardCode =$[$4.0.0] and T1.DocStatus='O' AND datediff(day, T1.DocDueDate,GetDate())>= 15
    thanks
    H2

  • Approval procedure only for the check payments

    Hi All,
    Is it possible to intiate the approval procedure only for the check payments in the Outgoing payments ?

    Hi Anand........
    Welcome to SAP Business One Forum.......
    Yes it is absolutely possible to create Approval Procedure for Check Payment.
    Please refer the following Query for Check Approval
    Select Distinct 'True' From OVPM T0 Where T0.CheckAct is Not Null and T0.CheckSum>0
    Apply above Query to Approval Procedure and assign it to proper User. and then check.......
    Regards,
    Rahul

  • 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 that will trigger on Approval Procedures

    Hi All,
    I have this requirements that the user will prevent them to Add the Sales Order by triggering the Approval Procedures. I need the script that i can use to link on the Terms Based on the User Queries. The script will check if the Unit Price is deviates 50% from the original Unit Price.
    Thanks and Regards,
    Melvin

    Hi Melvin,
    User query approval will only work on document header. Line level checking is not possible unless you just care about the first line.
    Thanks,
    Gordon

  • 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

  • Query a stored procedure that exec's a dynamic query. Error Linked server indicates object has no columns

    I have a stored procedure that dynamically creates a pivot query.  The procedure works and returns the correct data.  Now I have a requirement to show this data in reporting system that can only pull from a table or view.  Since you can not
    create a dynamic query in a view I tried to do a select from using openquery. 
    Example 'Select * from OpenQuery([MyServername], 'Exec Instance.Schema.StoredProcedure')
    I get the error back "the linked server indicates the object has no columns".  I assume this is because of the first select statement that is stuffing the variable with column names. 
    CODE FROM PROCEDURE
    Alter PROCEDURE [dbo].[Procedure1]
    AS
    BEGIN
    SET NOCOUNT ON
    Declare @cols nvarchar(2000),
      @Tcols nvarchar(2000),
      @Sql nvarchar (max)
    select @cols = stuff ((
          Select distinct '], ['+ModelName + '  ' + CombustorName
           from CombustorFuel cf
           join Model m on cf.modelid = m.modelid
           join Combustors cb on cf.CombustorID = cb.CombustorID
           where cf.CombustorID > 0
           for XML Path('')
          ),1,2,'')+']'
    Set @Tcols = replace(@Cols, ']', '] int')
    --Print @Tcols   
    --Print @Cols
    Set @Sql = 'Select GasLiquid, FuelType, '+ @Cols +'
    from
     Select GasLiquid, FuelType, ModelName+ ''  '' +CombustorName ModelCombustor, CombFuelStatus+''- ''+CombFuelNote CombFuelStatusNote
      from Frames f
      join Family fa on f.Frameid = fa.frameid
      join Model m on fa.FamilyID = m.FamilyID
      join CombustorFuel cf on m.Modelid = cf.modelid
      Join Combustors c on cf.CombustorId = c.CombustorID
      join FuelTypes ft on cf.FuelTypeID = ft.FuelTypeID
      where cf.CombustorFuelID > 0
        and CombustorName <> ''''
     ) up
    Pivot
     (max(CombFuelStatusNote) for ModelCombustor in ('+ @Cols +')) as pvt
    order by FuelType'
    exec (@Sql)

    Then again, a good reporting tool should be able to do dynamic pivot on its own, because dynamic pivoting is a presentation feature.
    SSRS Supports dynamic columns: Displaying Dynamic Columns in SSRS Report
    SQL Reporting Services with Dynamic Column Reports
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014
    Displaying and reading are two very different things.
    #1) SSRS Needs a fixed field list on the input side to know what what to make available in the designer.
    #2) SSRS cant read "exec (@Sql)" out of a proc, even if there is a fixed number of columns (at
    least it can't use it to auto build the field list from the proc)
    I use dynamic SQL in my report procs on a fairly regular basis and I've found it easiest to simply dump
    the results of my dynamic sql into a temp table at the end of the procs and then select from the temp table.
    Basically, Erland is correct. Stop trying to pivot in the query and let SSRS (or whatever reporting software you're using) handle it with a Martix.
    Jason Long

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

Maybe you are looking for

  • Ipod Does not Play songs

    Ipod does not play music. Instead of playing the song, it just lists the title (like when a song is playing) and then moves to the next song without playing the song. It's as if it automatically forwards to the next song (song titles displays for eve

  • Spawning my own JPopupMenu breaks every single JComboBox in the application

    That's pretty much it. I have determined the problem is in no way caused by the contents of the popup menu, but rather the popup menu itself. I have a popup menu which contains only a button which does nothing (I've tried this same thing with just a

  • Problems with Premiere Elements 9.0.1 on Mac OS X Lion

    Hi, I recently upgraded to Mac OS X Lion and I am having several stability issues with Premiere Elements 9.0.1 now.  None of these issues occurred on Snow Leopard.  I experienced these issues on a machine that was upgraded from Snow Leopard to Lion a

  • Font too small, can't read...how do i enlarge font size

    the text is too small, can't read

  • No 'use a webcam' option when attempting to sign PDF

    I just installed Acrobat XI Pro and I'm attempting to sign a PDF. According to the help, I should be able to scan a signature using a webcam, but I don't see that option available to me. My options are: Type my signature, Draw my signature, Use an im