Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 7915

Formated Search in Approval Procedure

$
0
0

I have a some difficulties with a Approval Procedures based in Sales Quotation against Sales Order and I need help of my fellows...

 

In my limited knowledge, to use a Formated Search into a Approval Procedure(A.P), is necessary who FS return 'TRUE' at value tested and this occurs in my tests over sql server... But, when I put this FS into the A.P nothing happen like I really wish...

 

The reason for this FS is check the "sum of quantities" if a Sales Order is greater than "sum of quantities" in the Sales Quotation origin (Base Document)... when I run this FS under a Sales Order incorrectly created over the Sales Quotation, I can see my criteria been returned like 'true' (see printscreen attachment), but the approval do not open in time Sales Order creation how is expected at the AP normal...

I have my doubts if this problem is been on sintax FS... I made many tests altering the sintax and all return me the result 'true'....

Where you see '= 10' in below codes I have used variable '$[Rdr1.BaseEntry]' to return my number document like a base to check and run the FS...

 

 

Sintaxe 1 (mus simple sintax)

-------------------------------------------------

Declare

@qtCota Numeric(10,4),

@qtPed Numeric(10,4)

 

 

Set @qtCota = (select SUM(Quantity) from qut1 where DocEntry = 10 and unitMsr = 'M2'

group by DocEntry)

 

 

Set @qtPed = (select SUM(Quantity) from rdr1 where BaseEntry = 10 and unitMsr = 'M2'

group by BaseEntry)

 

 

If @qtPed > @qtCota

  Begin

  select 'True', @qtPed as Ped, @qtCota as Cota

  End

Else

  Begin

  select 'false'

  End

----------------------------------------------------------------------------

 

Sintaxe 2 (little more complex sintax)

--------------------------

 

Declare

@qtCota Numeric(10,4),

@numCota Numeric,

@qtPed Numeric(10,4)

 

Set @numCota = (Select distinct rdr1.BaseEntry from Rdr1 inner join Ordr on Rdr1.DocEntry = 10)

 

Select 'true',

(select SUM(Quantity) from rdr1 where BaseEntry = @numCota and unitMsr = 'M2' group by BaseEntry) as Ped ,

(select SUM(Quantity) from qut1 where DocEntry = @numCota and unitMsr = 'M2' group by DocEntry) as Cota

from ORDR a

     inner join RDR1 b on a.DocEntry = b.DocEntry

     inner join QUT1 c on b.BaseEntry = c.DocEntry

     where b.BaseEntry = @numCota

     Group by

     c.DocEntry,

     b.BaseEntry

     Having (select SUM(Quantity) from rdr1 where BaseEntry = @numCota and unitMsr = 'M2'

  group by BaseEntry) >

  (select SUM(Quantity) from qut1 where DocEntry = @numCota and unitMsr = 'M2'

  group by DocEntry)

-------------------------------------------------------------------

 

Sintaxe 3 (a commom sintax)

------------------------

 

Declare

@qtCota Numeric(10,4),

@numCota Numeric,

@qtPed Numeric(10,4)

 

Set @numCota = (Select distinct rdr1.BaseEntry from Rdr1 inner join Ordr on Rdr1.DocEntry = 10)

 

Select

case when

(select SUM(Quantity) from rdr1 where BaseEntry = @numCota and unitMsr = 'M2'  group by BaseEntry) >

(select SUM(Quantity) from qut1 where DocEntry = @numCota and unitMsr = 'M2'  group by DocEntry)

Then 'true'

else 'false'

End

 

 

Anyone can help me to solve this... I'm late to put this function in operation, and my boss is upsetting me a lot for this... lol

 

 

Regards

 

 

Wagner Bezerra


Viewing all articles
Browse latest Browse all 7915

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>