Formatted Search to do calculation

Hi all,
I have written an SQL query for my formatted search that reads
select $|$170.12.0|
This is to return the Total Amount Due in incoming payment form. But when I applied this to one of the UDF I created, it returns an error "Internal error (3006) occurred [message 131-183]"
As long as it can return the total amount due, I can use it for calculation when my SQL query is developed.
Can anyone please enlighten me?
Thank you very much.
Regards.

Hi Kevin,
I just seen your updated Thread.
$[$-12.66.number]
If you found that than it is Very good, But still I would really like to tell you.
12 is 'Item', 66 is 'variable', for that field and number is to take only numeric value, i.e not to take currency sign.
Cheer's
Have a good day.
Regards
Ashutosh T

Similar Messages

  • Formatted search which perform calculation

    hi all,
    i want to design formatted search which does Arithmatic calculation of two user defind field  and display result in third UDF.
    i have designed formatted search but it gives internal error .
    Is there diff. syntax for using arithmatic operator in formatted search.
    i want to add,sub,mul runtime values from two UDF and display result in third UDF.
    please give me example.
    TIA.
    Chetan.

    Hi Chetan,
    Use the following syntax after eliminating / from it,
    /$[/$38.U_UDF1.Number]-/$[/$38.U_UDF2.Number]
    Regards,
    /Siddiq

  • Formatted search calculation

    I am trying to add a formatted search to sales order rows that takes the sales order qty times a user defined field which is a varchar field. I tried the following which does not work. Can anyone help.
    cast(u_salescaseqty as dec(18,6)) * $[$38.11.0.number]
    Thanks in advance

    Keith,
    I just gave you the format, t actual query should be
    CAST($\[$38.u_salescaseqty] AS DECIMAL(18,6)) * $\[$38.11.Number]
    I believe the u_salescaseqty is available in the document rows level.  Also make sure both your user fields are visible and active. 
    Let me know how it goes.
    Another way to check if the values are being passess to the Query is to manually test the FMS.
    Steps;
    Attach the Query to U_ExtCaseQty field
    Then After entering the details of the Items in the row, keep your cursor on this user field (U_ExtCaseQty )
    Go to Tools > Queries > User Queries > and open your saved query.
    By this you can see if the field values are being passed and the formats are correct.
    Let me know
    If need be you can send me the screen shot of the query and the form to [email protected]
    Best wishes
    Suda

  • Help needed for Formatted Search

    Hai Experts,
    would like to ask you some clarification on Formatted Search. In the
    query I found $http://$44.2.1 given in the criteria part.
    In some articles it was mentioned that, the 44 meant for the table
    connected with the form and 2 is field index and so on.
    Can you please explain how to find out those numbers and field index.
    I need to work out planty of FMS to fetch data into
    UDF automatically based on user input.
    Regards
    Anand

    Hi Anand,
    You may check these threads first:
    Re: Vendor default GL FMS help
    Re: Runtime data calculation
    Thanks,
    Gordon

  • Formatted Search Error -  Help Needed

    Hi All,
    My client has a peculiar purchase process. They are into chemical trading and do their purchase as follows:
    The vendor gives discount based on the volume and not on the quantities purchased. Thus, an item X if purchased in 250gm will cost $ 20 while the same item if purchased in 50gm may come to $15. So, the user wants to enter this values in the purchase order and want the unit price to be calculated based on this. Assuming the clients wants 1kg quantities of item X, he would like to fill  250 x gm  @ $20 in separate UDFs and based n these values, the system should calculate the unit rice for this item.
    What I did was as follows:
    a)  I created 3 UDFs each for the Base Quantity (U_BPQty), Base UoM(U_BPUnit),  Base Price (U_BasePrice). Thus the user enters 250, gm, 20 respectively as explained in the above example.
    b) I created one field  (U_UnitQty) to convert the base unit into purchasing unit. For this, I am writing a query to get the conversion factor value into the PO. Thus if the Purchasing UoM is KG and the base unit in which the supplier is charging is G, then I am populating 1000 in this field.   
    c) One more UDF to convert the base price into the unit price is captured is created. So, if 250gm cost $20 and my client wants 1kg, I am first getting the value of 4 in this UDF. This I am getting by dividing the value obtained from the step b) with the value in U_BPQty. 
    Once I get this value, I then calculate the unit price by multiplying 4 with $20 which will populate $80 in my Unit Price field through another FMS.
    I wrote a formatted search for converting this base unit to purchasing units. Given here is the FMS which is giving an error. For the sake of another functionality, I created a UDF for Purchasing UoM as well (U_UoM).
    Declare @UQty as varchar
    Declare @BPC as varchar
    set @UQty = $[POR1.U_UnitQty]
    set @BPC = SELECT
    (Case
    when $[POR1.U_UoM]  = 'kg' and $[POR1.U_BPUnit] = 'kg' then 1
    when $[POR1.U_UoM]  = 'kg' and $[POR1.U_BPUnit] = 'g' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'kg' and $[POR1.U_BPUnit] = 'mg' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'g' and $[POR1.U_BPUnit] = 'kg' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'g' and $[POR1.U_BPUnit] = 'g' then 1
    when $[POR1.U_UoM]  = 'g' and $[POR1.U_BPUnit] = 'mg' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'mg' and $[POR1.U_BPUnit] = 'g' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'mg' and $[POR1.U_BPUnit] = 'kg' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'mg' and $[POR1.U_BPUnit] = 'mg' then 1
    when $[POR1.U_UoM]  = 'kl' and $[POR1.U_BPUnit] = 'kl' then 1
    when $[POR1.U_UoM]  = 'kl' and $[POR1.U_BPUnit] = 'l' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'kl' and $[POR1.U_BPUnit] = 'ml' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'l' and $[POR1.U_BPUnit] = 'kl' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'l' and $[POR1.U_BPUnit] = 'l' then 1
    when $[POR1.U_UoM]  = 'l' and $[POR1.U_BPUnit] = 'ml' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'ml' and $[POR1.U_BPUnit] = 'l' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'ml' and $[POR1.U_BPUnit] = 'kl' then (@UQty/$[POR1.U_BPQuantity.NUMBER])
    when $[POR1.U_UoM]  = 'ml' and $[POR1.U_BPUnit] = 'ml' then 1
    else 1
    end)
    Select @BPC
    I would like to know  where I am going wrong or if there is any simpler method for the above scenario?     
    Thanks and regards,
    Bharath S

    Try the third line change to:
    set @UQty = $[POR1.U_UnitQty.number]

  • Automatic Delivery Date Calc with Formatted Search

    Hi,
    I'm trying to have the delivery date on purchase orders automatically calculated by using document date plus a value from the business partner master data (avragelate) which we are using as shipping time.
    What I have as my query is the following:
    Select $[$46.0.1]+t0.[avragelate] from ocrd t0 where $[$4.0.1]=t0.[cardcode]
    This is however returning an internal error when it runs.
    I have the formatted search set to run this query when the document date changes.
    Any ideas?
    Thanks,
    Michael

    Where are you linking this Formatted Search and how did you try to execute this?
    I don't generally post code before testing as I value the solution I provide and its importance to you...
    I had tested this and it worked just fine. 
    You should save this query and link this to the Delivery Date on the PO screen.
    I see you are a new member to the SDK forums.  If time permits please read through this link to know about the recognition program.. https://www.sdn.sap.com/irj/sdn/crphelp#section19
    Please let me know
    Suda

  • Date Difference Query Syntax Formatted Search

    Hi Experts,
    My client renders a service(warehousing of Cargo) on time and material basis,therefore the Quantity column of the AR Invoice represents the number of days the cargo was warehoused.
    I want to create a formatted search with reference to a query on this field to help me compute the number of days automatically. The number of days is normally calculated by Subtracting the the Admission date(Serial Number Details Table "OSRI", field "InDate" from the document date of the invoice) from the AR invoice document date.
    Considering that the Item is serial number managed, the item serial number will connect the Serial Number details table to the AR Invoice table.
    Can anybody help me with the syntax of the query that will achieve the above for me.
    Waiting to hear from you .
    Thanks

    If you have many serial numbers for an item, there will be no way to identify which serial number was actually selected in the invoice till the time the Invoice is added.
    So knowing the Serial Number that was selected on that Invoice is important and what you select in the Serial number selection window on the Invoice is stored in temporary location and cannot be referencing by looking into OSRI table.
    If there are multiple serial numbers with different InDate's, how could you calculate?
    Is there a Delivery Step?  Delivery > Invoice
    OR
    Do you copy SO > AR Invoice directly
    Suda

  • Formatted Search - BOM

    Hi There,
    I was wondering if anyone could assist on the following formatted search related query.
    On the Bill of Materials screen I have added a UDF to the Header where I will do some calculations. But before that I have to be able to select the OITT.Code (BOM Code) and be able to use it in my query.
    I know that in Marketing documents I can use $[$38.1.0] to get the Item code on line level, but how do I get it on Headers?
    If anyone can assist it would be greatly appreciated.
    Kind Regards,
    Wynand Cilliers.

    For the Header level fields the Column parameter does not apply.  Therefore it would be
    $[$Field.0.Type]
    For OITT.Code, that is displayed on the screen as Product No. use
    $[$4.0.0]

  • Formatted Search on Item Master

    Experts,
    I have a client who sells commodities. They need their Pricelists to be updated with each Purchase, because of fluctuating Prices.
    If I can get the following Formatted Search to work, I believe that Iu2019ll have a solution:
    I created a UDF on the Item Master Inventory tab rows, which I called OITW.U_Test
    I need to populate this UDF with the following calculation: (OITW.OnHand * OITW.AvgPrice) + (T1.OnOrder * (Sum of all the quantities on open POu2019s)) / (OITW.OnHand + T1.OnOrder)
    Here is the logic behind it: This UDF must show a modified Moving Average. Because POu2019s does not update the AvgPrice (only the Goods Receipt PO) this is cause for concern for this client who might have Sales Orders for Items that is not in stock yet, and posted as a lower AvgPrice.
    Here is what I have done so far:
    Select T0.ItemCode, T1.OnHand, T1.AvgPrice, T1.OnOrder,
         T1.OnHand*T1.AvgPrice as 'InStock Value',
         T1.OnOrder* ?????? as 'PO Value'
    From OITM T0 INNER JOIN OITW T1 ON T0.ItemCode = T1.ItemCode
         INNER JOIN POR1 T2 ON T0.ItemCode = T2.ItemCode
    Any help will be appreciated.
    Marli

    Gordon,
    I tested this and you are right, to use a FS will not work because of the refresh issue.
    I'm now working on a Stored Procedure that will update this UDF when a PO is Added or Updated. My experience with Stored Procedures is limited to True or False statements. (If this is true, do not add the Document, if it is false add the document)
    My question is: Can I populate the UDF, with a Value according to my query, with a Stored Procedure?
    Thanks for your help.
    Marli

  • Problems using a formatted search to link order lines to order header

    Hi,
    I'm having a nightmare trying to get the main lines table to populate the header within a sales order using a formatted search.
    I have created a UDF on the header for total value, and where items entered onto the order are of a certain type I need the header UDF to be sumated.
    Basically I have three parts for packaging (PACK1, PACK2 and PACK3), and the header has a UDF called U_TotPack
    Someone did sugest the following query, but this doesn't appear to work either:
    select sum(t0.linetotal) from rdr1 t0 inner join ordr t1 on t0.docentry = t1.docentry
    where t1.docnum = $[ORDR.DocNum] and t0.itemcode in ('PACK1', 'PACK2', 'PACK3')
    If it is a problem for me to use the line total field (as it is a variable calculation) I am happy to total the quantities for the items found, but I just can't seem to build any form of relationship between the header and lines.
    Hope someone out there is able to help as this one has really got me stumped.
    Cheers,
    J

    Hi Julian,
    I'm assuming you are trying to populate the header UDF before the Order is added to the system? If yes then it is not possible to achieve this via a formatted search, only SDK. A header FS cannot properly access line information, it only works the other way around - header info to line level.
    I presume the reasoning is that which line should your header FS take a value from? The FS syntax also doesn't allow you to loop throught all lines.
    The SQL that someone else suggested would only work for a sales order already added to the database. Hope this helps.
    Regards,
    Andrew.

  • Delivery - Sales Order executes formatted search

    Hi
    Found a very strange behaviour of B1:
    When making a new Delivery, which contains a formatted search in the lines, based on an sales order the value of the delivery  (position) gets newly calculated -> the formatted search gets executed!. This is imho very very strange because when referencing an order i want the value SIMPLY from there (All other fields get copied too).
    the formatted search is based on a saved query:
    SELECT $[$38.11.NUMBER]*$[$38.U_AnzMenge.NUMBER]
    -Autorefresh Yes
    -When altering Column
    -Display Saved Values
    Any suggestions?
    TIA

    Hi there,
    Can try:
    SELECT 'Price'=CASE WHEN $[$38.44.NUMBER]=0 THEN 2*2
    ELSE
    (SELECT T0.Price From RDR1 T0 INNER JOIN ORDR T1 ON T0.DocEntry=T1.DocEntry
    WHERE T1.DocNum=$[$38.44.NUMBER] AND T0.ItemCode=$[$38.1.0])
    END
    This query only workable for local currency or currency specify in your Delivery Order. If your Sales Order line detail have different currency then you will need to modify the query.
    Hope this help...

  • Formatted search to calculate GP%

    Hi, all
    I put a formatted search Query to define GP% (UDF) in Sales Order row. My query is:
    SELECT (($[$38.21.NUMBER] / $[RDR1.QUANTITY.NUMBER]) - $[$38.37.NUMBER]) / $[$38.37.NUMBER] * 100
    38.21.NUMBER = Open Amount
    RDR1.Quantity.Number = Quantity
    38.37.NUMBER = Gross Profit Base Price
    I want the result is exactly same with Gross Profit of order table - GP % (right click Sales Order interface - Gross Profit...). The calculation is defining correct at GP% UDF. But when 38.37.NUMBER is 0 price, the UDF is come out 0 instead of 100 (At Gross Profit of order table, the GP % field is 100).
    Reason I put formatted search is want defined GP % at alert management. Thanks.
    Regards
    Cheh Lu

    Hi Chehlu............
    Its a staandard functionality of SAP. It gives GP at Sales level based on valuation method.
    You have to just right click on the form and select the Gross Profit option.
    It will give you GP on Sales Order.
    Regards,
    Rahul

  • Formatted Search calling a stored procedure

    Hello all,
    I am having a problem getting a formatted search to work when I call a stored procedure from SAP (I am doing this because of a bug we discovered and need to get the client live Feb 1).  The stored procedure works fine when passing variables from within SQL Server, but fails when using SAP.  The problem seems to be where I need to get a UDF from the item master table, but not sure.  Thanks in advance
    The call from SAP query is:
    declare @LineType as varchar(6)
    declare @Width as numeric (19,6)
    declare @LI as numeric (19,6)
    declare @LN as numeric (19,6)
    declare @LD as numeric (19,6)
    declare @HI as numeric (19,6)
    declare @HN as numeric (19,6)
    declare @HD as numeric (19,6)
    declare @QtyOrd as numeric (19,6)
    Select @Width = $[OITM.U_WTH]
    FROM OITM
    WHERE OITM.ItemCode = $[$38.1]
    exec TBC_CHOP
    @Width,
    @LineType = $[$38.U_LINETYPE],
    @LI =$[$38.U_LI],
    @LN =$[$38.U_LN],
    @LD =$[$38.U_LD],
    @HI = $[$38.U_HI],
    @HN = $[$38.U_HN],
    @HD = $[$38.U_HD],
    @QtyOrd = $[$38.U_QTYORD]
    The stored procedure is:
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    -- =============================================
    -- Author:          <Mark Rueff
    -- Create date: <Jan 5, 2009>
    -- Description:     <Chop Calculation>
    -- =============================================
    ALTER PROCEDURE [dbo].[TBC_Chop]
         -- Add the parameters for the stored procedure here
    @LineType AS varchar(6) ,
    @Width AS numeric(19, 6),
    @LI AS numeric(19, 6) ,
    @LN AS numeric(19, 6),
    @LD AS numeric(19, 6),
    @HI AS numeric(19, 6),
    @HN AS numeric(19, 6),
    @HD AS numeric(19, 6) ,
    @QtyOrd AS numeric(19,6)
    AS
    BEGIN
         -- SET NOCOUNT ON added to prevent extra result sets from
         -- interfering with SELECT statements.
         SET NOCOUNT ON;
        -- Insert statements for procedure here
    SELECT
    CASE
    WHEN @LineType = 'c' AND @Width >= 3
    THEN ROUND((((ROUND((((@Width * 10) + 5) / 10), 1) * 8) + (((@LI + (@LN / @LD)) + (@HI + (@HN / @HD))) * 2) + 4) / 12) * @QtyOrd, 1)
    WHEN @LineType = 'c' AND @Width < 3
    THEN
        CASE
        WHEN RIGHT(CONVERT(int,(@Width * 10)), 1) > 0 AND RIGHT(CONVERT(int, (@Width * 10)), 1) < 5
        THEN ROUND(((((ROUND((@Width - 0.5), 0) + 0.5 * 8)  + (((@LI + (@LN / @LD)) + (@HI + (@HN / @HD))) * 2) + 4) / 12) * @QtyOrd), 1)
        ELSE ROUND((((ROUND(@Width, 0) * 8) + (((@LI + (@LN / @LD)) + (@HI + (@HN / @HD))) * 2) + 4) / 12) * @QtyOrd, 1)
        END
    WHEN @LineType = 'j' AND @Width >= 3
    THEN ROUND((((ROUND((((@Width * 10) + 5) / 10), 1) * 8) + (((@LI + (@LN / @LD)) + (@HI + (@HN / @HD))) * 2) + 4) / 12) * @QtyOrd, 1)
    WHEN @LineType = 'j' AND @Width < 3
    THEN
        CASE
        WHEN RIGHT(CONVERT(int, (@Width * 10)), 1) > 0 AND  RIGHT(CONVERT(int, (@Width * 10)), 1) < 5
        THEN ROUND(((((ROUND((@Width - 0.5), 0) + 0.5 * 8) + (((@LI + (@LN / @LD)) + (@HI + (@HN / @HD))) * 2) + 4) / 12) * @QtyOrd), 1)
        ELSE ROUND((((ROUND(@Width, 0) * 8) + (((@LI + (@LN / @LD)) + (@HI + (@HN / @HD))) * 2) + 4) / 12) * @QtyOrd, 1)
        END
    WHEN @LineType = 'r'
    THEN ROUND(((((@Width * 2) + (@LI + (@LN / @LD))) / 12) * @QtyOrd), 1)
    WHEN @LineType = 's'
    THEN @QtyOrd * 1.5
    WHEN @LineType = 'o'
    THEN @QtyOrd
    WHEN @LineType = 'l'
    THEN @QtyOrd
    ELSE 0
    END
    END

    Mark,
    I believe the syntax of your formatted search is not right. I guess you are trying to get the U_Width from Item Master and the other values from the current form.
    SELECT @Width = T0.U_WTH FROM [dbo].[OITM] T0.WHERE T0.ItemCode = $[$38.1.0]
    EXEC TBC_CHOP @Width, $[$38.U_LINETYPE.0], $[$38.U_LI.0], $[$38.U_LN.0],
    $[$38.U_LD.0], $[$38.U_HI.0], $[$38.U_HN.0], $[$38.U_HD.0], $[$38.U_QTYORD.Number]
    If you see I have added a third parameter which is the Type to the formatted seach field selection $[$Item.Column.Type]
    I have made then all 0 but you may change it as per the col type.  This Type should be 0 for Char type columns, Number for numeric columns and Date for Date type cols
    Suda

  • Formatted Search Inconsistency

    Hi All,
    Quite frustrated with a formatted search at the moment. Your help is appreciated. I've got an amount and a percentage field. I want to work out the amount after discount.
    If I do this calculation in a matrix, it works fine, but on the header of a record it does not. Herewith my queries: (I have the same fields on header of invoice and on rows): Amount field is Units and Totals, Price and Perc field is Units and Totals, Percentage.
    In matrix (working):
    SELECT $[$38.U_Amount.Number] - ($[$38.U_Amount.Number] * $[$38.U_Perc.Number] / 100)
    On header (NOT working):
    SELECT $[$U_Amount.0.Number] - ($[$U_Amount.0.Number] * $[$U_Perc.0.Number] / 100)
    I have also tried with $[Table.Field], but that doesn't work on either header or lines.
    Please help,
    Thanks!!!
    Adele.

    OK, got it working.
    I didn't know you can do it this way, but the way I got is solved is as follows. 
    SELECT $[OINV.U_Amount.Number] - ($[OINV.U_Amount.Number] * $[OINV.U_Perc.Number] / 100)
    I thought the .Number was only for the notation of $[$Item.Row.Type]
    Now it's working!!!
    Thanks Ibai for the other notation and thanks Juha for suggesting the query window.
    Thanks for your help.

  • Retrieving the value using formatted search

    Hi everyone. I have a question regarding on how I can get the value of the user-defined field in the title of a marketing document. I would like to get the value using formatted search and sql query.
    Here's the format I am currently using.
    $[$ <Item>.<Pane>.<Variable>]
    Is my format correct? Thanks.
    Regards,
    Omann

    Hi Omann,
    You can refer to fields in an entry screen using the syntax
    $[Table name.Field name]
    The table name is the name of the table belonging to the entry screen, for example, OINV for the A/R invoice entry screen.
    You can also use the fieldu2019s item number and fieldu2019s column number to refer to a field on the entry screen. By doing this, the query applies to all document entry screens. The syntax is then
    $[$Fieldu2019s item number.Fieldu2019s column number.NUMBER/CURRENCY/DATE/0]
    The system is able to uniquely identify each field of a document using the fieldu2019s index number and fieldu2019s column number. If you have activated the debug information under View  Debug Information, the system displays the fieldu2019s item number and the fieldu2019s column number in the status bar.
    You use the NUMBER parameter if the field concerned contains an amount and a currency key, and you want to extract the amount only. 
    You use the CURRENCY parameter if the field concerned contains an amount and a currency key, and you want to extract only the currency key.
    You use the DATE parameter if the field concerned is a date field and you want to use it for calculations.
    Regards, Yatsea

Maybe you are looking for

  • Unable to insert data in the table

    Hi, I've a document which has a doctype that points to a URL. When I try to insert this document in the table (xmltype column), I am getting the following errors: ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00263: co

  • Purchase of Fixed Asset

    Hi Where does the account code combination of asset item defaults while creating purchase order.How asset item are defined in inventory.where does the clearing account come from while creating purchase order? Please let me know the complete flow with

  • Please tell me how to CANCEL all the signing/encrypting thingy in order to get a working e-mail as before !

    Thanks a lot in advance - I just need a basic advice to make Thunderbird operational, even without any encryption or signature systems- happy new year !

  • Need Bluetooth Drivers For G430 38Q

    My inbuilt bluetooth is not working coz no drivers. I cant install drivers from the cd coz it has vista drivers and i have xp. Plz .. Someone provide me with XP drivers

  • I need help with incorrectly uninstalled Intuos driver

    I incorrectly uninstalled an Intuos driver and completely deleted it by emptying the trash.  When I try to reinstall I get a message the driver is still on my disk? How do I remedy this, get it back so I can uninstall it correctly?   Thanks OSX 10.9.