Query for approval
I have updated SBO_SP_TransactionNotification for validating sales order.The query is as follows -
if @object_type = '17' and @transaction_type IN ('A')
begin
declare curItem cursor for Select PriceBefDi,ItemCode,SeriesName FROM
RDR1 INNER JOIN ORDR ON RDR1.DocEntry=ORDR.DocEntry
INNER JOIN OUSR ON OUSR.UserId=ORDR.UserSign
INNER JOIN NNM1 ON NNM1.Series=ORDR.Series
WHERE ORDR.DocEntry=@list_of_cols_val_tab_del AND USER_Code<>'manager'
declare @dblPrice numeric(10,2),@dblItemPrice numeric(10,2)
declare @strItemCode varchar(20),@strSeriesName as varchar(40)
open curItem
fetch next from curItem into @dblPrice,@strItemCode,@strSeriesName
while @@fetch_status = 0
begin
SET @dblItemPrice=(select price from itm1 where itemcode=@strItemCode and pricelist=(select listnum from opln where listname='Sales price list' ))
if @dblItemPrice>0 and charindex('DEM',@strSeriesName)=0
begin
if @dblPrice<@dblItemPrice AND charindex('REP',@strSeriesName)=0
begin
set @error =1
set @error_message = 'The price of the item ' + @strItemCode + ' should be equivalent to sales price list i.e.' + cast(@dblItemPrice as varchar)
end
else
begin
if @dblPrice>@dblItemPrice
begin
set @error =1
set @error_message = 'The price of the replacement item ' + @strItemCode + ' should not be greater than sales price list i.e.' + cast(@dblItemPrice as varchar)
end
end
end
fetch next from curItem into @dblPrice,@strItemCode,@strSeriesName
end
close curItem
deallocate curItem
end
This stored procedure is working correctly as per the requirement.Sales order can not be added if the price is less than sales price list.
Now I want to remove this validation and add approval for this.If the rule is violated ,then the document will go for approval.In SAP I have created query for approval as,
SELECT DISTINCT 'True' FROM OITM WHERE ITEMCODE=$[$38.1] AND U_Discount_Percent < $[$38.15]
UNION
SELECT (CASE WHEN $[$38.14]<>(select price from itm1 where itemcode=$[$38.1] and pricelist=(select listnum from opln where listname='Sales price list' ))
THEN 'True' ELSE 'False' END)
Here I am getting the price as varchar.Is it possible to call stored procedure SBO_SP_TransactionNotification from query ?
Hi Dilip,
I have tried the following query for approval :
SELECT 'TRUE'
FROM OITM JOIN ITM1 ON OITM.ItemCode=ITM1.ItemCode
JOIN OPLN ON OPLN.ListNum=ITM1.PriceList AND UPPER(LTRIM(RTRIM(OPLN.ListName)))='SALES PRICE LIST'
WHERE OITM.ItemCode =$[$38.1.0] AND $[$38.14.NUMBER] != ITM1.Price
It works for all the lines in Sales Order.Even If there is a single item with Price before Discount not equal to Sales Price List Value,
System will send the document for approval.
I have put the condition $[$38.14.NUMBER] ! = ITM1.Price assuming that the price in SO should be exactly equal to Sales Price Price List .
Try this query at your end and let me know the result.
Thanks and Regards,
Pooja Singh.
Similar Messages
-
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 -
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?
ThanksHi......
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 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!!
talalHi,
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. -
Approval Query For A/R Delivery
Hi
I have made a query for Approval Procedure, only those Delivery documents will go for approval for which A/R Down payment Request has not been made. But it is not working properly Kindly Correct the query.
SELECT Distinct 'True' where dln1 t0 inner join odln t1 on t0.docentry = t1.docentry inner join ordr t2 on t0.baseentry = t2.docentry and t2.docentry not in (Select distinct t4.baseentry from dpi1 t4) and
t2. docentry = $[DLN1.Baseentry]
Thanks
RashidHi Rashid,
B1 does not support approval queries on document lines. you can query only document header.
you can either try to workaround it with all sorts of aggregate UDFs in the header, or alternatively take a look at:
[http://www.beonesolutions.com/ip/Solutions/ap.html|http://www.beonesolutions.com/ip/Solutions/ap.html]
all details, including the ability to query all document tables, are in:
[http://www.beonesolutions.com/files/Approval_Pro_Brochure.pdf|http://www.beonesolutions.com/files/Approval_Pro_Brochure.pdf]
Gilan -
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?
SwapnilDear 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 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
GiridharanHi 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 -
Dear Sir / Madam;
Please Help, We try to made Query for PO Approval with condition if PO Type "ITEM" have to approve by Purchasing Manager, but for PO Type "SERVICE" have to approve by General Affair Manager.
We Create Query for this condition " SELECT * FROM OPOR WHERE T0.[DOCTYPE]='I'
We already create the stage, and this query is not work. But if try to set the total Doc greater than 1000000, it is work.
Dear Sir / Madam, please help me to send me the right query ?
Thanks for your help
Regards
PetrusHi,
I suggest to add select distinct 'true' or select 'true' for in your query like previous answer.
Here are the solutions for your problem:
A. for doc type is not as same as service :
SELECT distinct 'true' FROM OPOR T0
where $[OPOR.doctype] = N'S'
B. For doctype is not as same as item:
SELECT distinct 'true' FROM OPOR T0
where $[OPOR.doctype] = N'I'
Both have been tested and work well.
Rgds, -
Query base approval for PO Unit Price
Dear All,
I want a Query Base approval
Scenario: If Purchase Order Unit Price Exceed form 10000/- INR then Purchase Order Goes to the Approval
Do any one have a Query base approval for above Scenario?In an approval query you can not access all the row level data. (Only the first line.) So you can not connect your approval on row level conditions.
I can suggest one (but a little uncomfortable and complicated) workaround for approval on line level:
1. Create a header level UDF e.g. named ForApproval with possible values Y and N, with default value N.
2. Write code in the SBO_SP_TransactionNotification stored procedure, that signals an error message u2018You should set ForApproval to Y!u2019 if U_ForApproval=u2019Nu2019 and there is any line with fulfilling your criteria.
3. Set an approval procedure according to the header level ForApproval field. -
Approval Query for Invoices with Items Onhand below zero.
Dear Experts,
I would like to make an approval procedure applicable on A/R Invoice.
When ever one of the Invoice items OnHand amount is below ZERO - I need the Approval Procedure to Popup and this way the Produce of the Invoice will be blocked.
Is there any way to write a query on Approval Template for that?
Thanks!
Regards,
D.MedalionHi D.Medalion
Please Follow some step
First Create Approval Stages in Administration ->Approval Procedures->Approval Stages
First -
Administration ->Approval Procedures->Approval Templates->Documents-> Click On A/R Invoice .
Second- Administration ->Approval Procedures- Approval Templates->Terms->When the Following Applies->Click Tick On Deviation from Commitment and ration Drop Down Choose Greater or Equal
Thanks & Regard
Khan Imran -
Approval Query for Outgoing Payment
Hi All Experts,
I have to Create Approval for Outgoing Payment where payment means is Cash,Cheque or Bank Transfer but not Credit Card.
In other words approval should be raised for all payment means other than Credit card payment means.
For which I have Created Query as follows
select Distinct 'true' FROM dbo.OVPM T0
Left join dbo.VPM3 T1 on T0.DocEntry=T1.Docnum
WHERE T0.CreditSum=0 And T1.CreditAcct is null
payments goes for approval but Credit Card payment also goes for Approval which is not required.
Please Help me to Correct the Query.
Regards,
Gayatri Shukla.Hi,
Little modification to your query. Try this.
select Distinct 'true' FROM dbo.OVPM T0
Left join dbo.VPM3 T1 on T0.DocEntry=T1.Docnum
WHERE T0.CreditSum = 0
Regards,
Amrut Sabnis. -
Approval Query for AP Invoices Containing Budget Related GL Account
Hi Experts,
I would like to create a approval template for all AP invoices that include a GL account that is related to the budget. Can you please help me with the approval query?
Thank you!
JaneHello Gordon Du,
"B1 approval will only apply to document level. If you want to check line level, only the first line can be subjected to."
I was thinking to trigger the approval process based on a document (AP invoice) containing relevant cost centres on a line by line basis as entered via one of the enabled dim fields.
Writing a trigger query for each cost centre effected? This does not appear to be a good solution, what is a better direction. Is there another way? (PO are not yet used via SAPB1)
Currently my invoices add, but do not trigger the approval process based on my attempts thus far.
Can the originator manually choose an approval pathway?
If this is against posting etiquette delete and advise.
I am a relative newbie to SAP B1, so am happy to be pointed to relevant help files. I arrived via google searching and arrived here.
Thankyou. -
Approval Query for Receipt from production
Hi experts,
I want to define an approval process for receipt from production.
The condition is below:
Only if it is " Receipt from production" then the goods receipt document should go to approval of quality.
If is any unplanned direct goods receipt then system should allow to add it straightly.
To do so, Please provide me the required query.
regards
Ravindran SrinivasanHi Ravindran,
I once encounter same problem like this. And I found out that, unfortunately, approval procedure can't work on receipt from production document.
Yes, we all know that receipt from production and inventory goods receipt are actually same object type in SAP B1 and stored in same table. But, try it by yourself in your testing database, even if you apply the approval templates for goods receipt document, and you apply the condition as "always", you won't get prompted for approval if you try to add the receipt from production document.
However, I said this based on my experience with version prior to 8.81 and 8.82. But somehow I have a strong feeling that this issue still not yet realized by SAP.
Best Regards,
Hendry Wijaya -
Query support for approval templates
hi
i want set approval on the base of query so i write query as follow
SELECT T0.[CardName], T0.[CreditLine] FROM OCRD T0 INNER JOIN OCRG T1 ON T0.GroupCode = T1.GroupCode INNER JOIN OINV T2 ON T0.CardCode = T2.CardCode
WHERE T1.[GroupName] ='INSTATION' AND
T0.[CreditLine] >= 0 AND
T0.[CreditLine] <=50000
GROUP BY T0.[CardName],T0.[CreditLine]
but on this condition approval is not set so if i write query wrong then pls send updated quer
regards,
sandipHi
There are plenty of threads how to write user defined query for writing approval query .
You have to use something like this ;
Select Distinct true ...
Here is what I found for you
Re: HELP TO WRITE A QUERY
Please search forum first
Thank you
Bishal
Edited by: BIshal Adhikari on Dec 11, 2008 9:59 AM -
Query regarding Note for approval
Hi
From which table we can find 'Note for Approval' against a shoping cart in SRMGo to BBP_PD, give your shopping cart number and scroll down, you will find the Notes for approval under
Attachments:
LongTexts:
Thanks.
Maybe you are looking for
-
Folders open without toolbars, windows to not refresh, other issues
I am having a problem on my Mac G5 Dual 2GHz, it is running OS 10.4.11 For the past few days when ever I open certain folders on our network volumes the finder windows always open without a toolbar and there are a variety of problems with these folde
-
Released Credit Value on a sales order is showing 0.00
Hi When I create and save a sales order, the released credit value (VBAK-AMBTL) is intermittently showing up as 0.00 when I look up in VBAK table. Can someone let me know why the credit value is 0.00? Please guide me on what to look for. Regards, Vic
-
Windows 8.1 key expiring soon
I bought a new Asus T200T laptop running windows 8.1 on 11 January 2015 but since last few days,my PC keep notifying me "Your Windows License will expire soon" and when I checked my pc settings,it shows that my license will expire on March 4,2015 Doe
-
Workflow - AVCHD - Arrange in AE - Transcoding?
Hi, I've been reading these forums for hours - so I am very sorry if my question has already been asked before. I plan to record with my Panasonic camcorder and edit the MTS' in Premier. When all the clips have been careful edited and cutted I want t
-
Plug in Issue with Bridge and Photoshop
When attempting to access Bridge in Photoshop (CS5 Extended) I received the following message: "Could not complete the browse in Bridge command because Photoshop was unable to find the JavaScript Plug-in". I have never received this message when usi