Sage 100

 View Only
  • 1.  Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-02-2021 17:53
    It appears that I have exceeded the MS Access' query capabilities as it crashes consistently when I stack queries (Pass-Through-Query -> Select-Queries -> Union-Query -> Select-Summary-Query) . I have used Access frequently for a long time because the drivers for it are built into Windows and do not require the user to have MS Access installed on any workstations. I need this to work from a BOI or User Defined Script (UDS) using an ADODB connection (I'm open to other methods). I know someone might be able to code this in straight SQL with a text editor, but four levels of sub queries is way too error prone for me.

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------


  • 2.  RE: Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-02-2021 17:57
    We use SQL Express as a bridge for a lot of things.  Add your own database, with View... Linked Server to ProvideX data, or set up a synch to mirror tables (for heavier lifting).  Since it's MS SQL extra drivers are not needed.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 3.  RE: Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-03-2021 04:26
    Thanks Kevin. I do try to incorporate SQL Express instead of MS Access, but I'm looking for a graphical query builder as good or better than Access and more reliable. I'm not a prolific SQL coder so the graphical part is as important. Do you know of any you that would recommend for SQL Server? With Access the foot print on the clients machine is almost non-existent since I don't need to even install Access or drivers - just a tiny MS Access database file (<300KB).

    I'm stacking a select query with running totals on top of a union query that pulls 6 SO, PO and IM Header and Detail tables from pass through queries so I need something adept at managing that so I can just copy the SQL statements instead of a whole DBMS. Access constantly crashes  and I get the same result on multiple updated Office 365 installations.

    I'm looking at FlySpeed SQL at the moment.

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------



  • 4.  RE: Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-03-2021 08:44
    SQL Server Management Studio is now a separate download and free...

    ------------------------------
    Phil McIntosh
    President
    Friendly Systems, Inc.
    Asheville NC
    678.273.4010 ext 5
    ------------------------------



  • 5.  RE: Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-03-2021 08:59
    I'm with Phil.  I use SSMS for SQL and Visual Studio Code for my vbs/powershell needs (all free and powerful). 

    If you can get those queries into SQL, I would build a common-table expression for your running totals and then you can join it in just like a normal table, or you can always have a separate view.

    Feel free to post or DM the query; i love puzzles!



    ------------------------------
    Steve Iwanowski, NextStep Technology Advisors, aka DSD Lancaster PA ¯\_(ツ)_/¯
    ------------------------------



  • 6.  RE: Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-03-2021 11:01
    Those are two different questions.
    • SQL Express is a powerful, stable platform that's relatively easy to deploy and it's free!
    • For building your SQL queries, use whatever you wish.  I've been writing SQL queries since the late 90's, so I can just type most things out, but if you find a query builder tool that you like: great.  You can still deploy using SQL Express.  SQL is a standard language so it's transferrable... you can probably even copy/paste your queries from Access into a SQL Express database, only having to change the data sources to a Linked Server.
    For "how do I" questions, post them here! :-)  My general strategy is to use SQL to consolidate / condense data, and Crystal Reports to format it (including calculating totals).

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 7.  RE: Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-03-2021 20:10
    Edited by Dan Burleson 02-03-2021 21:48
    Don't get me wrong. I've worked with SQL starting at IBM in the 70's and MS Access's SQL view almost daily, but I'm not a SQL guru and don't really want to be.
    So here's the "How do I" question. How do I more easily create and/or optimize this kind of query. The query's objective is to feed into HTML pop-up within Sage 100 that shows an ItemCode's warehouse availability as a running total based on the existing quantity on hand plus the complete portfollio of open SO's (as negatives) and PO's (as positives). I know I could do a Crystal report much easier, but the customer wants a pop-up from order data entry (I've even offered a Crystal Viewer launched from a script).

    Here's a graphical overview of how I am currently doing it:
    Sage 100 Query to Present an ItemCode's Availablility by Warehouse and Existing SO & PO Portfollio"selWaterfall" - Top Level Select Query with Sub Query references the Middle Level Union and Select Queries.
    SELECT IIf(IsNull([WF].[ByDate]),DateSerial(1980,1,1),[WF].[ByDate]) AS ByDate,
    IIf(IsNull([wf].[OrderNo]),"0000000",[wf].[OrderNo]) AS OrderNo,
    selIM_ItemWarehouse2.PrimaryVendorNo AS VendorNo, selIM_ItemWarehouse2.QuantityOnHand,
    WF.CompanyName, WF.Type, selIM_ItemWarehouse2.ItemCode, selIM_ItemWarehouse2.ItemCodeDesc,
    selIM_ItemWarehouse2.WarehouseCode, WF.QtyOnOrder,[QuantityOnHand]+IIf(IsNull([accBalance]),0,
    [accBalance]) AS myBalance, (SELECT SUM(QtyOnOrder) FROM uniOrderWaterfall
    WHERE Format(WF.ByDate,"yyyymmdd")+WF.OrderNo+WF.LineNo >=
    Format(ByDate,"yyyymmdd")+OrderNo+LineNo and WF.Itemcode = ItemCode and
    WF.WarehouseCode = WarehouseCode
    GROUP BY WF.WarehouseCode, WF.ByDate, WF.OrderNo, WF.LineNo) AS accBalance,
    IIf(IsNull([wf].[LineNo]),"0000",[wf].[LineNo]) AS LineNo
    FROM uniOrderWaterfall AS WF RIGHT JOIN selIM_ItemWarehouse2 ON
    (WF.ItemCode = selIM_ItemWarehouse2.ItemCode) AND (WF.WarehouseCode = selIM_ItemWarehouse2.WarehouseCode)
    ORDER BY IIf(IsNull([WF].[ByDate]),DateSerial(1980,1,1),[WF].[ByDate]), IIf(IsNull([wf].[OrderNo]),"0000000",[wf].[OrderNo]);​

    "uniOrderWaterfall" - Middle Level Union Query references Pass Through Queries

    SELECT "P" & [PO_PurchaseOrderDetail]![PurchaseOrderNo] AS OrderNo,
    PO_PurchaseOrderDetail.WarehouseCode, PO_PurchaseOrderHeader.VendorNo, "PO" AS Type,
    "Buy Fm: " & [PurchaseName] AS CompanyName,
    IIf(IsNull([RequiredExpireDate]),DateSerial(1980,1,1),[RequiredExpireDate]) AS ByDate,
    PO_PurchaseOrderDetail.ItemCode, PO_PurchaseOrderDetail.ItemCodeDesc,
    [QuantityOrdered]-[QuantityReceived] AS QtyOnOrder, PO_PurchaseOrderDetail.LineKey,
    Right([LineKey],4) AS LineNo
    FROM PO_PurchaseOrderDetail INNER JOIN PO_PurchaseOrderHeader ON
    PO_PurchaseOrderDetail.PurchaseOrderNo = PO_PurchaseOrderHeader.PurchaseOrderNo
    UNION ALL 
    SELECT "S" & [SO_SalesOrderDetail]![SalesOrderNo] AS OrderNo,
    SO_SalesOrderDetail.WarehouseCode, SO_SalesOrderDetail.VendorNo, "SO" AS Type,
    "Sold To: " & [BillToName] AS CompanyName,
    IIf(IsNull([ShipExpireDate]),DateSerial(1980,1,1),[ShipExpireDate]) AS ByDate,
    SO_SalesOrderDetail.ItemCode, SO_SalesOrderDetail.ItemCodeDesc,
    -([QuantityOrdered]-[QuantityShipped]) AS QtyOnOrder, SO_SalesOrderDetail.LineKey,
    Right([LineKey],4) AS LineNo
    FROM SO_SalesOrderDetail INNER JOIN SO_SalesOrderHeader ON
    SO_SalesOrderDetail.SalesOrderNo = SO_SalesOrderHeader.SalesOrderNo
    ORDER BY ByDate, OrderNo;

    "selIM_ItemWarehouse2" - Middle Level Select Query references Pass Through Queries

    SELECT ptqIM_ItemWarehouse.ItemCode, ptqCI_Item.ItemCodeDesc, ptqIM_ItemWarehouse.WarehouseCode,
    ptqIM_ItemWarehouse.QuantityOnHand, ptqCI_Item.PrimaryVendorNo,
    ptqIM_ItemWarehouse.QuantityOnPurchaseOrder, ptqIM_ItemWarehouse.QuantityOnSalesOrder
    FROM ptqIM_ItemWarehouse INNER JOIN ptqCI_Item ON ptqIM_ItemWarehouse.ItemCode = ptqCI_Item.ItemCode;

    "ptqIM_ItemWarehouse" - Sample Third Level Pass Through Query references Sage 100 tables

    SELECT IM_ItemWarehouse.ItemCode, IM_ItemWarehouse.WarehouseCode,
    IM_ItemWarehouse.QuantityOnHand, IM_ItemWarehouse.QuantityOnSalesOrder,
    IM_ItemWarehouse.QuantityOnPurchaseOrder FROM IM_ItemWarehouse

    The reason I'm looking for a better approach is that MS Access is very unstable and maintaining this is inefficient at best.

    Here's the current result:
    Waterfall Pop-up


    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------



  • 8.  RE: Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-04-2021 00:05
    So my gut reaction would be to re-create selIM_ItemWarehouse2 and uniOrderWaterfall in SQL as views (using LINKED_SERVER_NAME...IM_ItemWarehouse if Sage 100 Std/Adv) and then bring them into Access as Linked Tables.
    If uniOrderwaterfall is in Access, you can try keeping it there and using it to do any UI-driven filtering.

    SQL should be more stable and views are compiled so you'll eke slightly better performance.  I've had good luck over the years migrating Access databases and the create/append/delete queries used to create staging tables with simpler SQL views (or a series of them).

    ------------------------------
    Steve Iwanowski, NextStep Technology Advisors, aka DSD Lancaster PA ¯\_(ツ)_/¯
    ------------------------------



  • 9.  RE: Suggestions for a Query Editor for SOTAMAS90?

    Posted 02-04-2021 10:55
    The SQL you have can be copy / pasted into a new SQL Express database practically unchanged.

    Set up the linked server (as above) and query directly from SQL Express.
    For best user performance, set up your Top Level query to merge into a SQL table of your own (in a non-MAS* database), scheduled, so the user doesn't have to wait for the queries to run each time they access it.
    New SO/PO are merged in; completed SO/PO are removed; quantities are updated... refresh as often as you like.

    SQLCMD is great at scheduling such SQL scripts... it's a free part of the SQL tools included with SSMS.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------