Trying to create a FMS query that shows available stock quantity on each Sales Order line

Using SAP B1 v 8.82
I realize that I may be going about this in completely the wrong way.  Here's my code:
SELECT (T0.OnHand - T0.IsCommited + (SELECT SUM(ISNULL(T3.U_BO, 0)) FROM RDR1 T3 INNER JOIN OITM T4 ON T4.ItemCode = T3.ItemCode WHERE T3.U_BO > 0 AND T3.ItemCode = $[RDR1.ItemCode])) [available]
FROM OITW T0
INNER JOIN RDR1 T1 ON T1.ItemCode = T0.ItemCode
INNER JOIN ORDR T2 ON T2.DocEntry = T1.DocEntry
WHERE T0.WhsCode = 'ATL' AND T1.WhsCode = 'ATL' AND T2.DocNum = $[ORDR.DocNum] AND T1.LineNum = $[RDR1.LineNum]
GROUP BY T0.OnHand, T0.IsCommited
There is a UDF that I call upon in the RDR1 table called BO.  I created this field so that if a person wants to wait for a new batch they can "backorder" it.  In another UDF called "Available" I set up a user-defined value based on the above query.  The end result should be that whenever someone enters an item, the query finds the level of stock in the warehouse, subtracts the amount already committed, and adds back in any backorder quantities on other orders for the same item.  For example, say there's 1000 units of ITEM1 in stock, 2000 are ordered on SO # 1 and 500 are ordered on SO # 2.  The salesperson who created SO # 1 wants to wait for a new batch and types "2000" in the BO field.  I try to enter a new SO # 3 for 300 pieces.  When I key in ITEM1 on the first line, the field "Available" should update to say "500" (1000 - 2500 + 2000 = 500).
It seems to be working, but only after the document is added.  In the example above I enter SO # 3 with a qty of 300 and when I go back to that SO I see that "Available" shows 200.  Ideally I'd like to see it say 500 while I'm working in the SO before I add it. 

Edit2: Okay it so it works fine for any items that have a history, but it seems that if the item hasn't ever been on a Sales Order (i.e. it's not found in the RDR1 table) I get "no data found".  How can I make it simply return OnHand - IsCommited if it doesn't exist in the RDR1 table, but do the below query if it does?
Actually that's not true.  I've got it working now.  I changed the query a bit and the update trigger, and it feels like it's working exactly like I wanted.  Query below if you're interested.
/*Available FMS Sales Orders*/
SELECT (T0.OnHand-T0.IsCommited+(SELECT SUM(ISNULL(T3.U_BO, 0)) FROM RDR1 T3 WHERE T3.ItemCode = $[RDR1.ItemCode]))
FROM OITW T0
INNER JOIN RDR1 T1 ON T0.ItemCode = T1.ItemCode
WHERE T1.ItemCode = $[RDR1.ItemCode] AND T1.WhsCode = 'ATL'  AND T0.WhsCode = 'ATL'
I have it on Auto Refresh -  When Field Changes "Document Total" - Refresh Regularly.
Edit1: fixed grammatical error.

Similar Messages

  • FMS to Find total number of Quantity for all Sales Orders

    Hi Experts,
    I am trying to get the total number of quantities for the current document. Kindly help me out how to find it out for the current document.
    Currently I am giving the document no. to the query by modifying the query every time before executing it.  but how can i do this without giving the document numbers and executing the query directly.
    Kindly help ...
    Thanks and regards,
    Amit.

    Hi,
    Please follow below steps to get total quantity.
    1. Run below query first in query generator
    SELECT sum(T1.[Quantity]) FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry WHERE t0.docnum = $[ORDR.docnum]
    2. After execute, save it under query manager with required name
    3. Open sales order and run saved query
    4. Total quantity will be displayed in query result.
    refer below screen shot:
    Thanks & Regards,
    Nagarajan

  • I am trying to create an executable vi that will call out another vi and show its front panel in the executable​. When I try this I recieve this error message "top level vi (my main vi) was stopped at unknown on the block diagram of (my sub vi)

    I am trying to create an executable vi that will call out another vi and show its front panel in the executable.  When I try this I recieve this error message "top level vi (my main vi) was stopped at unknown on the block diagram of (my sub vi)

    Well the most common way is to enclude the vi's in the build spec either directly in the dependancies that the App builder automatically generates OR by declaring them in the build spec as "additional enclusions" (like you must do for dynamic vi calls in your app.
    I have heard rummors about My.app Stuff.vi in a nugget Intaris posted- and I've wanted to dig deaper into Intaris' claims- but have not tried it myself.
    If you go down the stuff.vi route Keep us curious guys posted
    Jeff

  • IN NEED OF A SCCM 2012 QUERY THAT SHOWS LAST TIME SOFTWARE WAS USED OR OPENED

    Hello
    I am in need of an SCCM 2012 query that shows PCs that have Visio , Adobe Professional and Visual Studio and the last time each was used or opened. I have the query below which give me the PC name and the product. Any assistance will be very helpful
    select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    like "%adobe acrobat%pro%"
    select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    like "%visio%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%viewer%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%service pack%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%security
    update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%hydra%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%MUI%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    not like "%amd%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%microsoft visio%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%vision%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%add-in%"
    select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    = "Microsoft Visual studio 2012 devenv" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%hotfix%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%security%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    not like "%update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%service%"

    Did you create a software metering rule for each software title? if not then you need you do that first and it will take over a week before you see results.
    Also keep in mind that your query will only find x86 software titles.
    http://www.enhansoft.com/

  • I am trying to create a PDF document that calculates Gains and Losses in Mutual Funds. The calculation scripts are repetitive from line to line. The scripts work well until I reach the line 32. Script stops calculating...

    I am trying to create a PDF document that calculates Gains and Losses in Mutual Funds. The calculation scripts are repetitive from line to line. The scripts work well until I reach the line 32. Although I am using the same script as the fields above in the columm, the script eventually stops calculating and I can't figure out why. Is there a limit of how many calculation scripts you can enter? I will attempt to attach my pdf as soon as I figure out how. Thanks.

    For e31 :
    var e30 = +getField("e30").value ;
    var c31 = +getField("c31").value ;
    if ( (e30 !== 0) && (c31 !== 0) ) event.value = e30 + c31 ;
    else event.value = "";
    for e32 :
    var e31 = +getField("e31").value ;
    var c32 = +getField("c32").value ;
    if ( (e31 !== 0) && (c32 !== 0) ) event.value = e31 + c32 ;
    else event.value = "";
    for e33 :
    var e32 = +getField("e32").value ;
    var c33 = +getField("c33").value ;
    if ( (e32 !== 0) && (c33 !== 0) ) event.value = e32 + c33 ;
    else event.value = "";
    Java console doesn't show any error... That's why I am wondering if it's not a limitation issue... or memory issue, because they are maybe too many rows or something....
    The c value is not calculated.

  • HT4718 i need to install a fresh copy of OS X onto my macbook pro 13. i did erase the old partition "macintosh hd" & now when i am trying to create a new partition, it shows "partition failed..couldnt unmount disk"...pls help !!

    i need to install a fresh copy of OS X onto my macbook pro 13. i did erase the old partition "macintosh hd" & now when i am trying to create a new partition, it shows "partition failed..couldnt unmount disk"...pls help !!

    First of all, I have to ask, why to you "need" to install a fresh copy of OSX?
    This may mean that your hard drive is failing, so hopefully you have a backup.
    I'm assuming you were in your recovery partition when you did this.
    I would, from the recovery partition, repair your hard drive and permissions.
    When to Run First Aid in Mountain Lion's Disk Utility - For Dummies
    And then try to create the partition again.
    If that doesn't work, you have a few options:
    Try a third party utility like DiskWarrior or TechTool which may be able to repair your hard drive:
    DiskWarrior 4 - The Disk Utility for Mac Disk Repair, Mac Directory Repair, Mac Disk Recovery, Mac Data Recovery or Techtool Pro 7
    Try internet recovery, perhaps erase the entire hard drive and reinstall ML.
    If nothing else works, then I'd replace the HD and start over.

  • Query that show total discount on A/R Invoice

    Dear all,
    I would like to have query that show summary of each invoice number that show 'Total of discount'  ( 'Total of discount' = total of discount in line item + discount of total invoice ). Data that I would like to show on this query is as follow :
    Invoice No, Invoice Date, Customer Code, Total before discount, 'Total of discount',  Total Amount, Vat amount
    Please kindly suggest the way to get this data.
    Thanks you in advanced.
    Angnam

    Hi Angnam K,
    Try This one...hope this will serve your purpose.
    SELECT  DocEntry, DocNum,   CardCode, CardName, DocDate, [Total Before Discount] , [Totaldiscount]+  [OinvDiscount] as [Total of discount], VatSum [Total Tax]      FROM (
    SELECT T0.DocEntry,T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], SUM(T1.[LineTotal])[Total Before Discount],
    SUM(T1.[PriceBefDi] * T1.Quantity *T1.[DiscPrcnt])/100 as [Totaldiscount]
    ,Case When T0.[DiscPrcnt] <> 0 Then  (SUM(T1.[LineTotal])/ T0.[DiscPrcnt]) Else 0 end [OinvDiscount] ,T0.VatSum
    FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    Group By T0.DocEntry,T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DiscSum] ,T0.[DiscPrcnt],T0.VatSum )Sales
    thanks,
    Kumar
    Edited by: itskumaramit on Jul 13, 2011 12:43 PM

  • SCCM 2012 QUERY THAT SHOWS SOFTWARE INSTALLED AND LAST TIME IT WAS USED OR OPENED

    Hello
    I am in need of an SCCM 2012 query that shows PCs that have Visio , Adobe Professional and Visual Studio and the last time each was used or opened. I have the query below which give me the PC name and the product. Any assistance will be very helpful
    select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    like "%adobe acrobat%pro%"
    select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    like "%visio%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%viewer%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%service pack%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%security
    update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%hydra%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%MUI%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    not like "%amd%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%microsoft visio%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%vision%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%add-in%"
    select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    = "Microsoft Visual studio 2012 devenv" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%hotfix%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%security%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    not like "%update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%service%

    See me reply to your other post with the exact same details, in the CM07 forum.
    http://www.enhansoft.com/

  • OTL I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?

    Hi
    I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
    I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
    Thanks
    Ruby

    Ruby,
    you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP.

  • How to create a popup window that shows detail information when press submi

    hi,all
    how to create a popup window that shows detail information when press the submit button ?I mean,when I press the button "Sumit"there will appear a popup window that shows the detail information you typed before.it means are u sure to submit,it is like some confirmation window.
    how to do achieve this ?help plz .
    best regards
    hlee
    Edited by: hlee on 2011-4-15 上午1:26

    hey,vee
    thanks for your response,but i had already read this thread before i put up a new question.any way,thanks.
    best regards
    hlee

  • Cancel Sales Order lines that are picked

    Hi
    1. I'm trying to cancel sales order lines through process order api that are picked and delivery status is Staged/Pick Confirmed. The error is
    You are not allowed to cancel Order Line because:
    Line has been pick confirmed/staged.
    I'm unable to perform by below means
    1.There is a processing constraint on the field SCHEDULE_ARRIVAL_DATE.
    Delete the processing constraint and retry the cancel line process - Processing constraint form the fields are protected against update
    2.Navigate to the shipping transaction form and query the order. Select the line and enter 0 at shipped quantity.Save the record.Ship confirm the line, this will cause the line to be backordered.Query the order line in the order entry form and cancel this. - Shipping transactions form the fields are protected against update
    2. Is there a way to cancel Internal Sales Order(ISO) lines of one OU and the corresponding internal requisition is another OU
    Thanks
    kumar

    If you are in R12, there are some enhancements from Oracle that allows updating/cancelling certain Internal requistion fields and Internal orders automatically. You may need to disable few processing constraints too.
    As of Now Oracle support change to following attribute at OM side
    1 Order Quantity
    2 Request Date
    3 Schedule date
    4 Arrival date
    Similarly if we make changes in following fields in Approved IR
    1 Quantity
    2 Need by Date
    These changes will got reflected in ISO
    Plus cancel the IR line or ISO line, the other one gets cancelled automaically.
    To cancel the picked line, first undo the pick confirmation process by back ordering. or unassign the delivery details from the delivery (if created already) and cancel the delivery.In either case, you need to manually trasnfer the qty from staging area to original locations. Oracle doesn't automatically move the qty back, (undo move order transaction).
    Ganesan.

  • Create purchase order with reference to Sales order Line item

    Hi All,
    i had a requirement that i need to create the Purchase order with reference to sales order line item...
    In T.code me27 client requied a input field for sales order no and with that order reference he want the data of line item to PO creation line item screen.....
    please sujjust......how to proceed......
    regards,
    Ravi Nemani

    Hi
    Go to SPRO->Logistic general->Tax on goods movement->India->Movement types.
    Here you will find the group of movement types check which movement types is mantained for the out side movement groups or inward movement.
    also check the Material Master in MRP view if the collective requirements (02) is mantained.
    Regards
    Sri

  • How to save LIST_LINE_ID of Price List when create Sales Order Line

    I dont know how save the LIST_LINE_ID of the Price List on Sales Order or anywhere when create Sales Order Line.
    I create with the following steps:
    Step 1: Create Price List for Item A with two line: Line 1 (Unit Price = 10,5, Pricing Attribute with Tax Classification Code = 5%), Line 2 (Unit Price = 11, Pricing Attribute with Tax Classification Code = 10%)
    Step 2: I create Sales Order Line with Item A, Tax Classification Code = 5% --> Unit Selling Price = List Price = 10,5 but dont bookorder
    Step 3: I update the Unit Price of Line 1 into 11.55.
    Step4 : I book this Sales Order. Howerver, I use form personalization to customize Book Event: if the Unit Price of Item on Price List > Unit Selling Price then cant not Book. But I dont konw List Price of Sales Order belong the line of Price List.
    Please help me check this issue. Thanks for your supports.
    BinhTC
    Email: [email protected]

    Bob's right - except that if you have OM: List Price Override Privilege set to 'Unlimited' (and from your scenario it sounds as if you have) it is possible that the value in unit_list_price will vary from what was originally retrieved from the price list.
    In that case, a safer bet is to use :LINE.original_list_price in your personalization as this will always contain what was originally retrieved and will mean you can avoid any repeat lookup via list_line_id.
    Regards,
    Jon

  • Formatted Search query on Sales Order Lines

    Hi Experts,
    I have a client that needs a Formatted Search that will bring back values according to the following Scenario:
    The Formatted search will be placed on the Sales Order Lines RDR1.U_UPC field.
    On a Sales Order I have created UDFs: RDR1.U_Label and RDR1.U_UPC
    On the BP Master Data I have created the UDFs: OCRD.U_UPCChoice
    On the Item Master Data I have created the UDFs: OITM.UPCRetail and OITM.UPCLoc and OITM.UPCItem and
    OITM,UPCOther
    When the RDR1.U_Label field is '1', I need the RDR1.U_UPC to be the text 'not Applicable'
    When the RDR1.U_Label field is '2', I need it to look at the OCRD.U_UPCChoice.
         If that value is '1' then it must bring back the OITM.UPCRetail Value back in the RDR1_UPC field,
         If that value is '2' then it must bring back the OITM.UPCLoc Value back in the RDR1_UPC field,
         If that value is '3' then it must bring back the OITM.UPCItem Value back in the RDR1_UPC field,
         If that value is '4' then it must bring back the text 'Look at Attachment'
    Any help would be greatly appreciated.
    Thanks,
    Marli
    Edited by: Marli Schutte on Aug 31, 2009 6:29 PM

    Hi Marli,
    Try this:
    IF $[RDR1.U_Label] = '2'
    SELECT Case T0.U_UPCChoice
    When 1 THEN T1.U_UPCRetail
    WHEN 2 THEN T1.U_UPCLoc
    WHEN 3 THEN T1.U_UPCItem
    WHEN 4 THEN 'Look at Attachment'
    END
    FROM dbo.OCRD T0, dbo.OITM T1
    WHERE T0.CardCode = $[$4.0.0] AND T1.ItemCode = $[$38.1.0]
    Thanks,
    Gordon

  • Create multiple single unit wip jobs for total sales order line qty

    Hi all,
    I want to know if there's a standard way to create multiple single unit wip jobs from a sales order line which has 2 or more units, i mean...
    I have a sales order line with item A with 3 units. If I progress the sales order, a single job is automatically created in WIP with 3 units to be created. What i want is to create 3 jobs with one unit each, all of them linked to the sales line order...
    Thanks in advance!
    Regards!
    Answered.........
    Edited by: user604737 on Nov 10, 2010 3:51 PM

    Hi Sandeep
    We have similar requirement (SO qty = 3 then 3 WIP jobs should be created). However when planning releases WIP jobs it does not tie back(reserve) the jobs to sales order.
    Are you aware of any standard way to do the same??
    Regards
    Mudit Gupta

Maybe you are looking for