Microsoft Dynamics GP: How to Find Inventory Quantity Differences Between IV00102 and IV00112

Microsoft Dynamics GP inventory quantity differences between IV00102 and IV00112

When Microsoft Dynamics GP is configured to use Multiple Bins, inventory quantities are maintained at more than one level. Sometimes the quantity stored at the item level may not agree with the total quantity stored across bins.

This article shows a read-only SQL diagnostic that can help identify differences between:

  • IV00102 — Item Quantity Master
  • IV00112 — Item Site Bin Master

The SQL in this article is intended for diagnostic purposes only. It does not update any Microsoft Dynamics GP tables.

Environment:
Microsoft Dynamics GP
Microsoft SQL Server
Inventory Control (Multiple Bins enabled)
Tables: IV00102 and IV00112
Script type: Read-only diagnostic
Last updated: November 26, 2026

1. When This Diagnostic Applies

This check is relevant when Enable Multiple Bins is enabled in Microsoft Dynamics GP.

Microsoft Dynamics GP Inventory Control Setup
Figure 1: Inventory Control Setup in Microsoft Dynamics GP.
Enable Multiple Bins option in Microsoft Dynamics GP
Figure 2: Enable Multiple Bins option.

2. Understanding IV00102 and IV00112

In IV00102, the record where LOCNCODE = '' is the overall item summary record rather than an individual inventory site.

IV00112 stores bin-level quantity information when Multiple Bins is enabled. For this diagnostic, QTYTYPE = 1 is used for On Hand quantities.

3. Diagnostic SQL: Compare All-Site Quantities

Run the following query in the relevant Dynamics GP company database using an authorized account with read permissions.

Instead of comparing only Available Quantity, the following query compares On Hand, Allocated, and Available separately. This makes the source of a discrepancy easier to identify.

WITH BinTotals AS
(
    SELECT
        RTRIM(ITEMNMBR) AS ITEMNMBR,
        SUM(QUANTITY) AS Bin_QTYONHND,
        SUM(ATYALLOC) AS Bin_ATYALLOC
    FROM dbo.IV00112
    WHERE QTYTYPE = 1
    GROUP BY ITEMNMBR
),
AllSiteTotals AS
(
    SELECT
        RTRIM(ITEMNMBR) AS ITEMNMBR,
        QTYONHND,
        ATYALLOC
    FROM dbo.IV00102
    WHERE LOCNCODE = ''
      AND RCRDTYPE = 1
)
SELECT
    A.ITEMNMBR,

    A.QTYONHND AS GP_AllSite_QTYONHND,
    ISNULL(B.Bin_QTYONHND, 0) AS Bin_QTYONHND,
    A.QTYONHND - ISNULL(B.Bin_QTYONHND, 0) AS QTYONHND_Diff,

    A.ATYALLOC AS GP_AllSite_ATYALLOC,
    ISNULL(B.Bin_ATYALLOC, 0) AS Bin_ATYALLOC,
    A.ATYALLOC - ISNULL(B.Bin_ATYALLOC, 0) AS ATYALLOC_Diff,

    A.QTYONHND - A.ATYALLOC AS GP_AllSite_Available,

    ISNULL(B.Bin_QTYONHND, 0)
        - ISNULL(B.Bin_ATYALLOC, 0) AS Bin_Available,

    (A.QTYONHND - A.ATYALLOC)
        - (
            ISNULL(B.Bin_QTYONHND, 0)
            - ISNULL(B.Bin_ATYALLOC, 0)
          ) AS Available_Diff

FROM AllSiteTotals A
LEFT JOIN BinTotals B
    ON B.ITEMNMBR = A.ITEMNMBR

WHERE
       A.QTYONHND <> ISNULL(B.Bin_QTYONHND, 0)
    OR A.ATYALLOC <> ISNULL(B.Bin_ATYALLOC, 0)

ORDER BY
    A.ITEMNMBR;

4. How to Interpret the Results

In a consistent system, this query should normally return no rows. If rows are returned, one or more totals do not agree.

This does not automatically mean that either IV00102 or IV00112 should be manually updated. It only means that the item requires further investigation.

Example SQL result showing Dynamics GP inventory quantity differences
Figure 3: Example result returned by the diagnostic query.

5. Optional Diagnostic: Compare Quantities by Site

The overall comparison tells you that a discrepancy exists. The following query can help identify which inventory site contains the difference.

WITH BinBySite AS
(
    SELECT
        RTRIM(ITEMNMBR) AS ITEMNMBR,
        RTRIM(LOCNCODE) AS LOCNCODE,
        SUM(QUANTITY) AS Bin_QTYONHND,
        SUM(ATYALLOC) AS Bin_ATYALLOC
    FROM dbo.IV00112
    WHERE QTYTYPE = 1
    GROUP BY
        ITEMNMBR,
        LOCNCODE
)
SELECT
    RTRIM(I.ITEMNMBR) AS ITEMNMBR,
    RTRIM(I.LOCNCODE) AS LOCNCODE,

    I.QTYONHND AS Site_QTYONHND,
    ISNULL(B.Bin_QTYONHND, 0) AS Bin_QTYONHND,
    I.QTYONHND - ISNULL(B.Bin_QTYONHND, 0) AS QTYONHND_Diff,

    I.ATYALLOC AS Site_ATYALLOC,
    ISNULL(B.Bin_ATYALLOC, 0) AS Bin_ATYALLOC,
    I.ATYALLOC - ISNULL(B.Bin_ATYALLOC, 0) AS ATYALLOC_Diff

FROM dbo.IV00102 I
LEFT JOIN BinBySite B
    ON B.ITEMNMBR = RTRIM(I.ITEMNMBR)
   AND B.LOCNCODE = RTRIM(I.LOCNCODE)

WHERE I.RCRDTYPE = 2
  AND
  (
       I.QTYONHND <> ISNULL(B.Bin_QTYONHND, 0)
    OR I.ATYALLOC <> ISNULL(B.Bin_ATYALLOC, 0)
  )

ORDER BY
    I.ITEMNMBR,
    I.LOCNCODE;

6. What to Do If Differences Are Found

Do not immediately update IV00102 or IV00112 directly with SQL. Inventory quantities in Dynamics GP can be affected by several related tables and modules.

The supported next step is to investigate the affected items and, when appropriate, use:

Microsoft Dynamics GP → Tools → Utilities → Inventory → Reconcile

Dynamics GP Tools Utilities Inventory Reconcile menu
Figure 4: Opening Reconcile from Tools → Utilities → Inventory.

Before running Reconcile in production:

  1. Make a current database backup.
  2. Preferably test the process in a test company first.
  3. Review unusual or open inventory transactions.
  4. Run the appropriate Dynamics GP reconcile process.
  5. Review the generated Reconcile Report.
  6. Run the diagnostic SQL again.
Dynamics GP Reconcile Inventory Quantities window
Figure 5: Reconcile Inventory Quantities window.

7. Important Safety Considerations

The SQL scripts in this article are intentionally SELECT-only. Avoid directly updating inventory quantity tables simply to force the quantities to match.

UPDATE IV00102 ...
UPDATE IV00112 ...

A direct SQL update may make one table appear correct while leaving other inventory-related records inconsistent. Use supported Dynamics GP processes whenever possible.

Conclusion

  • IV00102 contains item quantity information.
  • The blank LOCNCODE record is the overall item summary record.
  • IV00112 contains bin-level quantities when Multiple Bins is enabled.
  • QTYTYPE = 1 is used for On Hand quantities in this diagnostic.
  • Compare On Hand and Allocated values separately to locate the real discrepancy.
  • Use SQL for diagnosis, not to force inventory balances to match.
  • After Reconcile, review the report and run the diagnostic query again.

Related Articles


Author: Hussain Ali Al Yousef
Originally published: May 9, 2023
Last updated: November 26, 2026
Category: Microsoft Dynamics GP | SQL Server | Troubleshooting

Microsoft Dynamics GP: How to Count Users in Each User Class Using SQL

Count Microsoft Dynamics GP users by User Class using SY01400 and SY40400

To count Microsoft Dynamics GP user accounts by User Class, query the SY01400 (Users Master) table in the system database. This is useful for reviewing user account distribution without opening each account individually.

Run the following read-only queries in SQL Server Management Studio (SSMS) using an authorized account.

Environment:
Microsoft Dynamics GP
Microsoft SQL Server
System Administration and User Management
Database: DYNAMICS (default system database)
Table: SY01400, SY40400
Last updated: November 26, 2026

1. Count Users by User Class

SELECT
    USRCLASS,
    COUNT(USERID) AS USERID_Count
FROM DYNAMICS.dbo.SY01400
GROUP BY USRCLASS
HAVING COUNT(USERID) > 0;

The original query groups accounts by USRCLASS and counts non-NULL user IDs. The HAVING condition is redundant when USERID is guaranteed to be non-NULL.

Example Output

USRCLASS USERID_Count
ACCOUNTING 12
SALES 18
PURCHASING 5
WAREHOUSE 8
ADMIN 3

Illustrative data only; class names and counts are fictional.

2. Include User Classes with No Assigned Users

The original query cannot show empty configured classes. Use SY40400 (Class Master) with a LEFT JOIN to include them.

SELECT
    C.USRCLASS,
    C.DSCRIPTN AS ClassDescription,
    COUNT(U.USERID) AS USERID_Count
FROM DYNAMICS.dbo.SY40400 AS C
LEFT JOIN DYNAMICS.dbo.SY01400 AS U
    ON C.USRCLASS = U.USRCLASS
GROUP BY
    C.USRCLASS,
    C.DSCRIPTN
ORDER BY
    USERID_Count DESC,
    C.USRCLASS;

COUNT(U.USERID), rather than COUNT(*), returns zero for a class without matching users. Accounts without a matching class definition are excluded from this result.

3. Find Users Without an Assigned Class

SELECT
    USERID,
    USERNAME,
    USRCLASS
FROM DYNAMICS.dbo.SY01400
WHERE USRCLASS IS NULL
   OR LTRIM(RTRIM(USRCLASS)) = ''
ORDER BY USERID;

A blank or NULL class is not necessarily a configuration error.

4. Important Considerations

  • These queries count registered accounts, not active sessions or consumed licenses; inactive or disabled accounts may be included.
  • User Classes do not establish effective security permissions. Review security roles and company access separately.
  • DYNAMICS is the default system database name. Adjust it if necessary and verify the referenced columns in your environment.

Related Articles

References


Author: Hussain Ali Al Yousef
Originally published: July 2021
Last updated: November 26, 2026
Category: Microsoft Dynamics GP | SQL Server

Visual Studio: How to Fix Android Emulator Error 0xe0434352

Fix Android Emulator error 0xe0434352 in Visual Studio by checking the Android SDK

While working with Microsoft Visual Studio 2019, I encountered error 0xe0434352 when launching the Android Emulator. Opening Android SDK Manager revealed an installation problem.

Repairing the Android SDK resolved the issue in my development environment. This guide documents the original solution and what to check if the error persists.

Environment:
Microsoft Visual Studio 2019
Android Emulator
Android SDK Manager
Windows
Related versions: Visual Studio 2017 and 2019
Last updated: November 26, 2026

1. The Error Message

The exception unknown software exception
(0xe0434352) occurred in the application
at location 0x00000000766540B2.

This is a general Microsoft .NET CLR exception code, not an Android-specific error. The memory address may vary, and the code alone does not identify the underlying cause.

2. Solution: Repair the Android SDK

Step 1: Open Android SDK Manager

Open Microsoft Visual Studio and navigate to:

Tools > Android > Android SDK Manager
Opening Android SDK Manager from the Tools and Android menus in Visual Studio 2019

Figure 1: Opening Android SDK Manager in Visual Studio.

Step 2: Repair the Android SDK Installation

In my case, opening Android SDK Manager displayed a message indicating that the Android SDK installation needed repair.

If Visual Studio displays a similar notification, follow the repair instructions provided by the SDK Manager.

Visual Studio Android SDK Manager displaying a notification that the Android SDK needs repair

Figure 2: Android SDK Manager reporting that the SDK installation requires repair.

Allow the repair process to complete. An internet connection may be required if the SDK Manager needs to download missing components.

Step 3: Confirm Successful Repair

After the repair process completed, Visual Studio displayed the following confirmation:

Android SDK was repaired successfully.
Visual Studio confirmation message showing that the Android SDK was repaired successfully

Figure 3: Successful completion of the Android SDK repair.

Step 4: Test the Android Emulator Again

Close Android SDK Manager, restart Visual Studio if necessary, and run your Android project with the emulator again. This repair resolved the issue in my original environment.

3. What If the Problem Still Occurs?

If no repair option appears or the error persists, investigate the underlying exception. These are additional troubleshooting suggestions, not steps required in my original case.

Check the Android SDK Configuration

Verify that the SDK platforms, platform-tools, build-tools, emulator and system image are compatible with your project. Check the configured Android SDK location in Visual Studio:

Tools > Options

Look for Android or Xamarin settings; menu names may vary by version.

Check the Windows Application Event Log

Press Windows + R and enter:

eventvwr.msc

Navigate to:

Event Viewer > Windows Logs > Application

Look for entries recorded around the time of the failure, particularly events from .NET Runtime or Application Error.

Review the exception message, faulting module and stack trace when available.

Other Troubleshooting Steps

  • If the emulator cannot initialize, check hardware virtualization and the requirements of the installed emulator version. This is not necessarily the cause of the CLR exception.
  • If Visual Studio itself appears damaged, consider the Visual Studio Installer repair option after simpler checks.

4. Important Considerations

Important: The exception code alone does not identify the underlying cause. Repairing the Android SDK is a possible solution when the failure occurs in the Android development environment, but it is not a universal fix for every 0xe0434352 error.
Recommendation: Start with the least disruptive troubleshooting steps. Do not reinstall Visual Studio, remove development tools, or modify system-wide settings until simpler diagnostic steps have been considered.

5. Visual Studio Version Compatibility

The screenshots document Visual Studio 2019; Visual Studio 2017 is also referenced in the original article. The exact procedure has not been verified on newer versions.

2026 Update:

Microsoft ended support for Xamarin on May 1, 2024.

Developers maintaining legacy Xamarin applications may still find this troubleshooting procedure useful. For new projects, supported .NET for Android or .NET MAUI development environments should be considered.

The original screenshots and repair procedure are preserved for their historical and technical value.

References


Author: Hussain Ali Al Yousef
Originally published: July 2021
Last updated: November 26, 2026
Category: Visual Studio | Android Development | Troubleshooting
Article type: Practical troubleshooting experience

Windows: How to Register and Unregister DLL Files Using Regsvr32

Register and unregister compatible Windows DLL files using Regsvr32

Some Windows applications require self-registering COM or ActiveX components (DLL or OCX files). Regsvr32 registers or unregisters these components; ordinary DLLs and many .NET assemblies do not support this operation.

This guide shows how to use Regsvr32 with 32-bit and 64-bit components, using FM20.dll as the original example.

Environment:
Microsoft Windows
Command Prompt (CMD)
Regsvr32.exe
32-bit and 64-bit COM components
Last updated: November 26, 2026

1. Open Command Prompt as Administrator

  1. Open the Windows Start menu.
  2. Search for cmd or Command Prompt.
  3. Select Run as administrator.
  4. Approve the User Account Control (UAC) prompt if required.
Searching for Command Prompt in Windows using cmd

Figure 1: Searching for Command Prompt in Windows.

Administrator privileges may be required because component registration can modify system-wide Windows Registry settings.

2. Understanding System32 and SysWOW64

One of the most common mistakes when registering DLL files on 64-bit Windows is using the wrong version of Regsvr32.

On standard x64 editions of Windows, the directory names can be misleading.

Directory Architecture
%SystemRoot%\System32 64-bit
%SystemRoot%\SysWOW64 32-bit

Use the 32-bit version of Regsvr32 for 32-bit components and the 64-bit version for 64-bit components.

On 32-bit Windows, the System32 directory contains the 32-bit version of Regsvr32.

The following examples assume that Command Prompt is running natively on the operating system.

3. Register a 32-bit DLL File on 64-bit Windows

The original example in this article demonstrates the registration of FM20.dll, a Microsoft Forms component.

If the appropriate 32-bit version of FM20.dll is already installed in the SysWOW64 directory, use the following commands.

cls
cd /d "%SystemRoot%\SysWOW64"
regsvr32 FM20.dll

The optional cls command clears the screen; cd /d changes the drive and directory.

Original Command Prompt example showing DLL registration using Regsvr32 and FM20.dll

Figure 2: Original DLL registration example using FM20.dll.

Alternative Method: Use the Full File Path

You can explicitly specify both the Regsvr32 executable and the DLL file without changing the current directory.

"%SystemRoot%\SysWOW64\regsvr32.exe" "%SystemRoot%\SysWOW64\FM20.dll"

If the DLL is installed in a different directory, use its actual installation path.

4. Register a 64-bit DLL File

For a 64-bit self-registering COM DLL on x64 Windows, use the Regsvr32 executable located in System32.

"%SystemRoot%\System32\regsvr32.exe" "C:\MyApplication\Example64.dll"

Replace the example path with the actual location of your 64-bit DLL file.

5. How to Unregister a DLL File

The /u parameter instructs Regsvr32 to unregister a compatible component.

Unregister a 32-bit DLL on 64-bit Windows

"%SystemRoot%\SysWOW64\regsvr32.exe" /u "C:\MyApplication\Example32.dll"

Unregister a 64-bit DLL

"%SystemRoot%\System32\regsvr32.exe" /u "C:\MyApplication\Example64.dll"
Warning: Unregistering a shared component may cause applications that depend on it to stop working. Confirm the impact before performing this operation.

6. Regsvr32 Command-Line Options

Option Description
/u Unregisters the component.
/s Suppresses message boxes.
/i Invokes the component's DllInstall function, if supported.
/n Skips DllRegisterServer and must be used with /i.

Use silent mode only when necessary, such as in controlled deployment scripts. During manual troubleshooting, visible error messages are useful for diagnosing failures.

7. Common Regsvr32 Errors and Troubleshooting

  • 0x80070005 (Access denied): Run Command Prompt as administrator and verify permissions and security policies.
  • The specified module could not be found: Check the DLL path and required dependencies; use the official installer or repair procedure if needed.
  • DllRegisterServer entry point was not found: Confirm that the DLL supports self-registration.
  • Architecture mismatch: Match Regsvr32 and all dependencies to the DLL architecture.

8. Important Security Considerations

  • Only register DLL files obtained from trusted and authorized sources.
  • Do not download replacement system DLL files from unofficial DLL download websites.
  • Do not copy DLL files into Windows system directories unnecessarily.
  • Prefer the software vendor's installer or repair utility when available.
  • Remember that Regsvr32 executes registration code contained within the component.
  • Test changes before applying them to production systems.

References


Author: Hussain Ali Al Yousef
Originally published: July 2021
Last updated: November 26, 2026
Category: Windows | IT Administration | Troubleshooting

Microsoft Dynamics GP: How to Combine SOP10200 and SOP30300 Using a SQL View

Combine Microsoft Dynamics GP SOP10200 and SOP30300 using a SQL view

One of the common challenges when developing reports for Microsoft Dynamics GP is retrieving Sales Order Processing (SOP) document lines from both work and history tables.

This article provides a complete SQL Server view that combines SOP10200 and SOP30300 into a single data source, making it easier to retrieve sales transaction details for reporting, business intelligence, and data analysis.

The original script was developed for Microsoft Dynamics GP 2018 R2.

Environment:
Microsoft Dynamics GP 2018 R2
Microsoft SQL Server
Sales Order Processing (SOP)
Originally developed: June 30, 2021
Last updated: November 26, 2026

1. Understanding SOP10200 and SOP30300

Microsoft Dynamics GP stores sales transaction line details in separate tables depending on whether the records are in the work or history stage.

Table Description Data Source
SOP10200 Sales Transaction Amounts Work Work
SOP30300 Sales Transaction Amounts History History

Both tables contain detailed sales transaction information, including item numbers, descriptions, quantities, costs, prices, taxes, shipping information, and inventory-related quantities.

However, their structures are not completely identical. Some columns exist in one table but not in the other.

2. Why Combine Both Tables?

Creating a unified SQL view provides several advantages:

  • Retrieve work and historical sales transaction lines from a single source.
  • Simplify SQL queries and custom reports.
  • Reduce duplicated reporting logic.
  • Support Power BI, SQL Server Reporting Services (SSRS), and Crystal Reports.
  • Identify the original source table for each record.
  • Provide a reusable data source for business intelligence applications.

3. How the SQL View Works

The view uses the SQL Server UNION ALL operator to combine records from both tables.

Unlike a SQL JOIN, which combines related columns horizontally, UNION ALL combines compatible result sets vertically.

SOP10200
Sales Transaction Amounts Work
↓
UNION ALL
↑
Sales Transaction Amounts History
SOP30300
↓
Unified SOP Sales Transaction Lines View

Two additional columns are included to identify the source of each record:

  • Documents_Status: Unposted or Posted.
  • Table: SOP10200 or SOP30300.

For compatibility with the original script, columns that do not exist in one of the source tables are represented using zero values or empty strings.

4. Complete SQL View Script

Open SQL Server Management Studio (SSMS) and select the appropriate Dynamics GP company database.

Use CREATE VIEW if the view does not already exist. If you are updating an existing installation of this view, replace CREATE VIEW with ALTER VIEW.

Always review and test custom SQL objects in a test environment before deploying them to a production database.

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[Hyou_VW_SOP10200&SOP30300]
AS

-- ==================================================
-- View: Hyou_VW_SOP10200&SOP30300
-- Author: Hussain Ali Al Yousef
-- Created: June 30, 2021
-- Article updated: November 25, 2026
-- Microsoft Dynamics GP 2018 R2
--
-- Description:
-- Combine SOP transaction lines from
-- SOP10200 (Work) and SOP30300 (History).
--
-- Blog:
-- https://hussainalyousef.blogspot.com/
-- ==================================================

SELECT
    'Unposted' AS [Documents_Status],
    'SOP10200' AS [Table],
    SOPTYPE,
    SOPNUMBE,
    LNITMSEQ,
    CMPNTSEQ,
    ITEMNMBR,
    ITEMDESC,
    NONINVEN,
    DROPSHIP,
    UOFM,
    LOCNCODE,
    UNITCOST,
    ORUNTCST,
    UNITPRCE,
    ORUNTPRC,
    XTNDPRCE,
    OXTNDPRC,
    REMPRICE,
    OREPRICE,
    EXTDCOST,
    OREXTCST,
    MRKDNAMT,
    ORMRKDAM,
    MRKDNPCT,
    MRKDNTYP,
    INVINDX,
    CSLSINDX,
    SLSINDX,
    MKDNINDX,
    RTNSINDX,
    INUSINDX,
    INSRINDX,
    DMGDINDX,
    ITMTSHID,
    IVITMTXB,
    BKTSLSAM,
    ORBKTSLS,
    TAXAMNT,
    ORTAXAMT,
    TXBTXAMT,
    OTAXTAMT,
    BSIVCTTL,
    TRDISAMT,
    ORTDISAM,
    DISCSALE,
    ORDAVSLS,
    QUANTITY,
    ATYALLOC,
    QTYINSVC,
    QTYINUSE,
    QTYDMGED,
    QTYRTRND,
    QTYONHND,
    QTYCANCE,
    QTYCANOT,
    QTYONPO,
    QTYORDER,
    QTYPRBAC,
    QTYPRBOO,
    QTYPRINV,
    QTYPRORD,
    QTYPRVRECVD,
    QTYRECVD,
    QTYREMAI,
    QTYREMBO,
    QTYTBAOR,
    QTYTOINV,
    QTYTORDR,
    QTYFULFI,
    QTYSLCTD,
    QTYBSUOM,
    EXTQTYAL,
    EXTQTYSEL,
    ReqShipDate,
    FUFILDAT,
    ACTLSHIP,
    SHIPMTHD,
    SALSTERR,
    SLPRSNID,
    PRCLEVEL,
    COMMNTID,
    BRKFLD1,
    BRKFLD2,
    BRKFLD3,
    CURRNIDX,
    TRXSORCE,
    SOPLNERR,
    '' AS [DOCNCORR],
    ORGSEQNM,
    ITEMCODE,
    PURCHSTAT,
    DECPLQTY,
    DECPLCUR,
    ODECPLCU,
    QTYTOSHP,
    XFRSHDOC,
    EXCEPTIONALDEMAND,
    TAXSCHID,
    TXSCHSRC,
    PRSTADCD,
    ShipToName,
    CNTCPRSN,
    ADDRESS1,
    ADDRESS2,
    ADDRESS3,
    CITY,
    [STATE],
    ZIPCODE,
    CCode,
    COUNTRY,
    PHONE1,
    PHONE2,
    PHONE3,
    FAXNUMBR,
    Flags,
    BackoutTradeDisc,
    OrigBackoutTradeDisc,
    GPSFOINTEGRATIONID,
    INTEGRATIONSOURCE,
    INTEGRATIONID,
    CONTNBR,
    CONTLNSEQNBR,
    CONTSTARTDTE,
    CONTENDDTE,
    CONTITEMNBR,
    CONTSERIALNBR,
    BULKPICKPRNT,
    INDPICKPRNT,
    ISLINEINTRA,
    SOFULFILLMENTBIN,
    MULTIPLEBINS,
    Print_Phone_NumberGB,
    DEX_ROW_TS,
    DEX_ROW_ID
FROM dbo.SOP10200

UNION ALL

SELECT
    'Posted' AS [Documents_Status],
    'SOP30300' AS [Table],
    SOPTYPE,
    SOPNUMBE,
    LNITMSEQ,
    CMPNTSEQ,
    ITEMNMBR,
    ITEMDESC,
    NONINVEN,
    DROPSHIP,
    UOFM,
    LOCNCODE,
    UNITCOST,
    ORUNTCST,
    UNITPRCE,
    ORUNTPRC,
    XTNDPRCE,
    OXTNDPRC,
    REMPRICE,
    OREPRICE,
    EXTDCOST,
    OREXTCST,
    MRKDNAMT,
    ORMRKDAM,
    MRKDNPCT,
    MRKDNTYP,
    INVINDX,
    CSLSINDX,
    SLSINDX,
    MKDNINDX,
    RTNSINDX,
    INUSINDX,
    INSRINDX,
    DMGDINDX,
    ITMTSHID,
    IVITMTXB,
    BKTSLSAM,
    ORBKTSLS,
    TAXAMNT,
    ORTAXAMT,
    TXBTXAMT,
    OTAXTAMT,
    BSIVCTTL,
    TRDISAMT,
    ORTDISAM,
    DISCSALE,
    ORDAVSLS,
    QUANTITY,
    ATYALLOC,
    QTYINSVC,
    QTYINUSE,
    QTYDMGED,
    QTYRTRND,
    QTYONHND,
    QTYCANCE,
    QTYCANOT,
    0.00000 AS [QTYONPO],
    QTYORDER,
    QTYPRBAC,
    QTYPRBOO,
    QTYPRINV,
    QTYPRORD,
    QTYPRVRECVD,
    QTYRECVD,
    QTYREMAI,
    QTYREMBO,
    QTYTBAOR,
    QTYTOINV,
    QTYTORDR,
    QTYFULFI,
    QTYSLCTD,
    QTYBSUOM,
    EXTQTYAL,
    EXTQTYSEL,
    ReqShipDate,
    FUFILDAT,
    ACTLSHIP,
    SHIPMTHD,
    SALSTERR,
    SLPRSNID,
    PRCLEVEL,
    COMMNTID,
    BRKFLD1,
    BRKFLD2,
    BRKFLD3,
    CURRNIDX,
    TRXSORCE,
    SOPLNERR,
    DOCNCORR,
    ORGSEQNM,
    ITEMCODE,
    PURCHSTAT,
    DECPLQTY,
    DECPLCUR,
    ODECPLCU,
    0.00000 AS [QTYTOSHP],
    0 AS [XFRSHDOC],
    EXCEPTIONALDEMAND,
    TAXSCHID,
    TXSCHSRC,
    PRSTADCD,
    ShipToName,
    CNTCPRSN,
    ADDRESS1,
    ADDRESS2,
    ADDRESS3,
    CITY,
    [STATE],
    ZIPCODE,
    CCode,
    COUNTRY,
    PHONE1,
    PHONE2,
    PHONE3,
    FAXNUMBR,
    Flags,
    0.00000 AS [BackoutTradeDisc],
    0.00000 AS [OrigBackoutTradeDisc],
    '' AS [GPSFOINTEGRATIONID],
    0 AS [INTEGRATIONSOURCE],
    '' AS [INTEGRATIONID],
    CONTNBR,
    CONTLNSEQNBR,
    CONTSTARTDTE,
    CONTENDDTE,
    CONTITEMNBR,
    CONTSERIALNBR,
    0 AS [BULKPICKPRNT],
    0 AS [INDPICKPRNT],
    0 AS [ISLINEINTRA],
    '' AS [SOFULFILLMENTBIN],
    0 AS [MULTIPLEBINS],
    Print_Phone_NumberGB,
    DEX_ROW_TS,
    DEX_ROW_ID
FROM dbo.SOP30300;
GO

5. Understanding SOP Document Types

The SOPTYPE column identifies the type of sales transaction in Microsoft Dynamics GP.

SOPTYPE Document Type
1 Quote
2 Order
3 Invoice
4 Return
5 Back Order
6 Fulfillment Order

6. Practical SQL Query Examples

Example 1: Retrieve sample sales transaction lines

SELECT TOP (100) *
FROM dbo.[Hyou_VW_SOP10200&SOP30300];

Example 2: Retrieve a specific sales invoice

SELECT
    Documents_Status,
    SOPTYPE,
    SOPNUMBE,
    ITEMNMBR,
    ITEMDESC,
    QUANTITY,
    UNITPRCE,
    XTNDPRCE
FROM dbo.[Hyou_VW_SOP10200&SOP30300]
WHERE SOPNUMBE = 'INV000001'
  AND SOPTYPE = 3
ORDER BY
    LNITMSEQ,
    CMPNTSEQ;

Replace INV000001 with a valid invoice number from your Dynamics GP company database.

Example 3: Retrieve unposted sales orders

SELECT
    SOPNUMBE,
    ITEMNMBR,
    ITEMDESC,
    QUANTITY,
    ATYALLOC,
    QTYREMAI,
    LOCNCODE
FROM dbo.[Hyou_VW_SOP10200&SOP30300]
WHERE Documents_Status = 'Unposted'
  AND SOPTYPE = 2;

Example 4: Retrieve invoice and return lines for an item

SELECT
    Documents_Status,
    SOPTYPE,
    SOPNUMBE,
    ITEMNMBR,
    QUANTITY,
    UNITCOST,
    UNITPRCE,
    XTNDPRCE
FROM dbo.[Hyou_VW_SOP10200&SOP30300]
WHERE ITEMNMBR = 'ITEM001'
  AND SOPTYPE IN (3, 4);

Replace ITEM001 with the required item number.

Example 5: Count transaction lines by document type

SELECT
    Documents_Status,
    SOPTYPE,
    COUNT_BIG(*) AS LineCount
FROM dbo.[Hyou_VW_SOP10200&SOP30300]
GROUP BY
    Documents_Status,
    SOPTYPE
ORDER BY
    Documents_Status,
    SOPTYPE;

This query counts transaction lines rather than unique sales documents. A single SOP document may contain multiple item lines and components.

7. Validate the SQL View

You can compare the number of records in the source tables with the number of records returned by the view.

SELECT
    'SOP10200' AS DataSource,
    COUNT_BIG(*) AS RowCount
FROM dbo.SOP10200

UNION ALL

SELECT
    'SOP30300',
    COUNT_BIG(*)
FROM dbo.SOP30300

UNION ALL

SELECT
    'Combined View',
    COUNT_BIG(*)
FROM dbo.[Hyou_VW_SOP10200&SOP30300];

When the underlying data is not changing during the validation, the combined view should return the sum of the record counts from SOP10200 and SOP30300.

8. Permissions and Security

If Dynamics GP users require access to the custom SQL view, you may optionally grant SELECT permission to the DYNGRP database role.

GRANT SELECT
ON dbo.[Hyou_VW_SOP10200&SOP30300]
TO [DYNGRP];
GO

This step is optional. For external reporting applications, consider granting access only to a dedicated reporting role or authorized database users.

The view exposes potentially sensitive information, including item costs, prices, customer shipping addresses, and contact details. Review access requirements before granting permissions.

9. Important Considerations

Important:
  • The original script was developed for Dynamics GP 2018 R2. Verify column availability and data types before using it with other versions.
  • The labels Unposted and Posted identify the source tables in this view. They should not be interpreted as independently verified accounting posting statuses.
  • Historical SOP documents may include transferred or voided transactions. Additional document header information may be required for accurate financial reporting.
  • Zero values and empty strings used for unavailable columns are compatibility placeholders, not necessarily actual transaction values.
  • The UNION ALL operator does not remove duplicate records.
  • DEX_ROW_ID should not be treated as a globally unique identifier across both source tables.
  • Use appropriate filters when querying large company databases.
  • Do not use this view alone to calculate total recognized sales revenue without applying the necessary document-type, status, currency, and financial reporting rules.

10. Extending the View for Reporting

This view focuses on sales transaction lines. Additional information can be retrieved from the corresponding SOP document header tables.

Document Stage Header Table Line Table
Work SOP10100 SOP10200
History SOP30200 SOP30300

The corresponding header and line tables can be related using both SOPTYPE and SOPNUMBE.

Joining each line source to its corresponding header source enables additional reporting capabilities, including:

  • Customer numbers and customer names.
  • Document dates and posting dates.
  • Document totals and currencies.
  • Salesperson and sales territory analysis.
  • Document status and void information.
  • Sales order fulfillment and historical sales analysis.

11. Frequently Asked Questions

Why use UNION ALL instead of UNION?

UNION ALL preserves all records from both result sets without performing duplicate elimination. This is appropriate when the objective is to combine transaction lines while preserving their original data.

Does this SQL view modify Dynamics GP transaction data?

No. The script creates a database view that retrieves existing records. It does not insert, update, or delete records in the Dynamics GP transaction tables.

Can I use this view with Power BI or SSRS?

Yes. The view can be used as a SQL Server data source for Power BI, SSRS, Crystal Reports, and other reporting applications, subject to the required database permissions.

Does the view work with other Dynamics GP versions?

It may work with other versions, but table structures and available columns should be verified before deployment. The original script targets Dynamics GP 2018 R2.

Conclusion

Combining SOP10200 and SOP30300 into a single SQL Server view provides a practical and reusable approach to accessing Microsoft Dynamics GP sales transaction lines.

By preserving the transaction details and identifying their original source, the view simplifies reporting and provides a foundation for more advanced business intelligence, sales analysis, and ERP reporting solutions.

Related Articles

References


Author: Hussain Ali Al Yousef
Originally published: July 2021
Original script: June 30, 2021
Last updated: November 26, 2026
Category: Microsoft Dynamics GP | SQL Server

Welcome to My Technical Blog: Sharing Knowledge and Practical IT Solutions

Welcome to Hussain Al Yousef’s technical blog about practical IT solutions and knowledge sharing

Welcome to my technical blog!

Creating a blog to share my knowledge, practical experience, and technical solutions has been a personal ambition for many years. Throughout my career in Information Technology, I have benefited from the knowledge shared by technology professionals around the world. This blog is my way of giving back to that community.

About Me

My name is Hussain Ali Al Yousef, an Information Technology professional based in Saudi Arabia, with over 20 years of professional experience in IT, enterprise applications, ERP systems, database management, and business reporting.

My interests include solving real-world technical problems, improving business processes, and developing practical applications.

What You Will Find on This Blog

The blog focuses on practical technical knowledge and professional experiences across six areas:

Microsoft Dynamics GP and ERP Systems

ERP administration, troubleshooting, system integration, and inventory, sales, purchasing, and financial reporting.

Microsoft SQL Server

Practical T-SQL queries, views, stored procedures, database administration, and troubleshooting.

Business Intelligence and Reporting

Power BI, SQL Server Reporting Services (SSRS), Crystal Reports, dashboards, and data visualization.

Software Development

Desktop and web applications, Python, development tools, and practical programming solutions.

Artificial Intelligence and Developer Tools

AI-assisted development, developer productivity tools, and practical applications of emerging technologies.

IT Administration and Troubleshooting

Microsoft Windows, application configuration, error diagnosis, and system administration.

My Approach to Knowledge Sharing

My goal is not simply to provide code snippets or quick answers, but to explain how and why solutions work. Where appropriate, articles include practical examples, source code, screenshots, compatibility notes, and technical references.

Older articles may be reviewed and updated to improve their accuracy and practical value while preserving original solutions and screenshots where relevant.

Important Considerations

The information on this blog is intended for educational and informational purposes. Review and test technical solutions, scripts, and configuration changes in an appropriate environment before applying them to production systems.

The views and opinions expressed here are my own and do not necessarily represent those of any organization or employer.

Explore the Blog

Browse the published articles using the blog's navigation and topic labels.

Explore Technical Articles

Thank You for Visiting

Whether you are an IT professional, developer, system administrator, ERP specialist, student, or simply interested in technology, I hope you find something useful here.

Knowledge grows when it is shared.

May God guide me in this endeavor.

Thank you for visiting, and welcome to my blog.

Best regards,
Hussain Ali Al Yousef

Connect with me on LinkedIn


Author: Hussain Ali Al Yousef
Last updated: November 26, 2026
Category: About

Microsoft Dynamics GP: How to Find Inventory Quantity Differences Between IV00102 and IV00112

When Microsoft Dynamics GP is configured to use Multiple Bins , inventory quantities are maintained at more than one level. Sometimes the qu...