# Dynamics GP eConnect SOP Invoice XML Generator

> Source: https://netray.co/tools/dynamics-gp-econnect-sop-invoice-xml-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in customer, item, quantity and price to get a ready eConnect SOPTransactionType document and the C# call that posts it into Dynamics GP.

## Category

microsoft-dynamics

## Erp

Microsoft Dynamics GP

## Audience

- GP developer
- Integration developer
- ERP administrator

## Tool

**Kind:** template

**Output:** code

**Language:** xml

**Fields:**

#### SOPTYPE

**Key:** sop_type

**Type:** select

**Options:**

- 3
- 2

**Default:** 3

**Help:** 3 = Invoice, 2 = Order

#### Document ID (DOCID)

**Key:** doc_id

**Type:** text

**Default:** STDINV

**Help:** Must exist in Sales Order Processing Document Setup for this SOP type

#### SOP number (SOPNUMBE)

**Key:** sop_number

**Type:** text

**Default:** INV-000123

**Help:** Supply a number. To use the next number from the Document ID, call the taGetSopNumber stored procedure first.

#### Document date (DOCDATE)

**Key:** doc_date

**Type:** date

**Default:** 2026-10-22

#### Customer ID (CUSTNMBR)

**Key:** customer

**Type:** text

**Default:** AARONFIT0001

#### Batch ID (BACHNUMB)

**Key:** batch

**Type:** text

**Default:** EC-SOP-1026

#### Item number (ITEMNMBR)

**Key:** item

**Type:** text

**Default:** 128 SDRAM

#### Quantity (QUANTITY)

**Key:** qty

**Type:** number

**Default:** 2

#### Unit price (UNITPRCE)

**Key:** unit_price

**Type:** number

**Default:** 89.95

#### Extended price (XTNDPRCE)

**Key:** ext_price

**Type:** number

**Default:** 179.90

**Help:** Quantity x unit price. Sum of all lines must equal SUBTOTAL.

#### Site ID (LOCNCODE)

**Key:** site

**Type:** text

**Default:** WAREHOUSE

#### Unit of measure (UOFM)

**Key:** uofm

**Type:** text

**Default:** Each

#### DEFPRICING

**Key:** def_pricing

**Type:** select

**Options:**

- 0
- 1

**Default:** 0

**Help:** 0 = use the prices passed in, 1 = let eConnect look up the GP price

#### CREATEDIST

**Key:** create_dist

**Type:** select

**Options:**

- 1
- 0

**Default:** 1

**Help:** 1 = eConnect creates the GL distributions, 0 = you pass taSopDistribution nodes

#### SQL Server instance

**Key:** sql_server

**Type:** text

**Default:** GPSQL01

#### Company database

**Key:** company_db

**Type:** text

**Default:** TWO

**Blocks:**

#### eConnect XML document (SOPTransactionType)

**Body:** <?xml version="1.0" encoding="utf-8"?>
<eConnect xmlns:dt="urn:schemas-microsoft-com:datatypes">
  <SOPTransactionType>
    <taSopLineIvcInsert_Items>
      <taSopLineIvcInsert>
        <SOPTYPE>{{sop_type}}</SOPTYPE>
        <SOPNUMBE>{{sop_number}}</SOPNUMBE>
        <CUSTNMBR>{{customer}}</CUSTNMBR>
        <DOCDATE>{{doc_date}}</DOCDATE>
        <LOCNCODE>{{site}}</LOCNCODE>
        <ITEMNMBR>{{item}}</ITEMNMBR>
        <UNITPRCE>{{unit_price}}</UNITPRCE>
        <XTNDPRCE>{{ext_price}}</XTNDPRCE>
        <QUANTITY>{{qty}}</QUANTITY>
        <UOFM>{{uofm}}</UOFM>
        <DOCID>{{doc_id}}</DOCID>
        <DEFPRICING>{{def_pricing}}</DEFPRICING>
      </taSopLineIvcInsert>
    </taSopLineIvcInsert_Items>
    <taSopHdrIvcInsert>
      <SOPTYPE>{{sop_type}}</SOPTYPE>
      <DOCID>{{doc_id}}</DOCID>
      <SOPNUMBE>{{sop_number}}</SOPNUMBE>
      <BACHNUMB>{{batch}}</BACHNUMB>
      <LOCNCODE>{{site}}</LOCNCODE>
      <DOCDATE>{{doc_date}}</DOCDATE>
      <CUSTNMBR>{{customer}}</CUSTNMBR>
      <SUBTOTAL>{{ext_price}}</SUBTOTAL>
      <DOCAMNT>{{ext_price}}</DOCAMNT>
      <CREATEDIST>{{create_dist}}</CREATEDIST>
    </taSopHdrIvcInsert>
  </SOPTransactionType>
</eConnect>

#### C# call (Microsoft.Dynamics.GP.eConnect)

**Body:** using System;
using System.IO;
using Microsoft.Dynamics.GP.eConnect;

class PostSopDocument
{
    static void Main()
    {
        string connectionString = "Data Source={{sql_server}};Initial Catalog={{company_db}};Integrated Security=SSPI;Persist Security Info=False;";
        string xml = File.ReadAllText(@"C:\eConnect\{{sop_number}}.xml");

        using (eConnectMethods eConCall = new eConnectMethods())
        {
            try
            {
                // Returns the XML document with any values eConnect assigned
                string result = eConCall.CreateTransactionEntity(connectionString, xml);
                Console.WriteLine(result);
            }
            catch (eConnectException ex)
            {
                // Business rule errors from the ta procedures arrive here
                Console.WriteLine(ex.Message);
            }
        }
    }
}

**Notes:** Verify for your build: reference Microsoft.Dynamics.GP.eConnect.dll from the eConnect install that matches your GP version (eConnect 18.x for GP 18.x). Element names come from the taSopHdrIvcInsert and taSopLineIvcInsert schema in the eConnect Programmer's Guide; check element order against SOPTransactionType.xsd in your eConnect folder if you validate against the schema. DOCAMNT equals SUBTOTAL only when there is no tax, freight, misc or trade discount.

## Content

**Intro:** This generator builds an eConnect SOPTransactionType XML document that creates a Sales Order Processing invoice or order in Dynamics GP 2013 through 18.x, plus a minimal C# program that sends it with eConnectMethods.CreateTransactionEntity. Change the fields and copy both blocks.

**Sections:**

#### How to use it

**Body:** Pick SOPTYPE 3 for an invoice or 2 for an order, then enter a Document ID that exists in Sales Order Processing Setup for that type (STDINV and STDORD in the sample company). Enter the customer, batch, item, site and unit of measure exactly as they exist in GP: eConnect validates every key. Keep XTNDPRCE equal to quantity times unit price and SUBTOTAL equal to the sum of all line extended prices. Save the XML as a file and run the C# program, or pass the string from your own integration service.

**Bullets:**

- One taSopLineIvcInsert node per line inside taSopLineIvcInsert_Items
- Line nodes come before the header node inside SOPTransactionType
- Set DEFPRICING to 1 to let eConnect price the line from the customer price level
- CREATEDIST 1 lets eConnect build distributions from posting setup

#### Where this lands in Dynamics GP

**Body:** eConnect calls the taSopLineIvcInsert and taSopHdrIvcInsert stored procedures in the company database. The document appears in Sales Transaction Entry under the batch you passed (Transactions > Sales > Sales Batches) and is stored in SOP10100 (header) and SOP10200 (lines) until it is posted, after which it moves to SOP30200 and SOP30300. Nothing is posted by eConnect: the batch still needs posting in GP or through a posting tool. The same XML can be dropped on the eConnect incoming MSMQ queue if you use the Incoming Service instead of a direct call.

#### Worked example

**Body:** With the defaults, the program creates invoice INV-000123 for customer AARONFIT0001 dated 2026-10-22 in batch EC-SOP-1026: two units of item 128 SDRAM from site WAREHOUSE at 89.95, extended 179.90. SUBTOTAL and DOCAMNT are both 179.90 because the sample has no tax schedule, freight or misc charges. If the customer has a tax schedule, pass TAXAMNT on the header (and tax nodes or the tax-calculation flags your version supports) and raise DOCAMNT accordingly, otherwise eConnect rejects the document with an amount mismatch error.

#### Gotchas that cause most eConnect errors

**Body:** The Windows or SQL login running the call must be a member of the DYNGRP database role in DYNAMICS and in the company database, otherwise the procedures fail with permission errors. The eConnect runtime version must match the GP version; an 18.x eConnect against a GP 2016 database fails. Dates should be in a format SQL Server reads unambiguously, such as 2026-10-22. Duplicate SOP numbers are rejected, so either manage numbering yourself or call taGetSopNumber before building the XML. Errors come back in eConnectException.Message with the error number and the failing element.

**Cta:** If you want staff to ask GP about open invoices and orders in plain English on your own servers, with eConnect writes kept behind an approval step, we can set that up.

**Faq:**

#### Does Dynamics GP have an API for creating invoices?

**Answer:** GP 2015 and later include a Service Based Architecture (REST) layer, but its coverage is limited and most SOP invoice integrations still use eConnect, which exposes XML schemas and .NET methods such as eConnectMethods.CreateTransactionEntity. Integration Manager is the user tool for file imports and can call eConnect underneath.

#### Why must the line nodes come before the header?

**Answer:** eConnect processes the nodes in document order. taSopLineIvcInsert writes the lines to the work tables first, then taSopHdrIvcInsert writes the header and checks that SUBTOTAL matches the lines already inserted. Putting the header first makes the totals check fail or creates a header with no lines.

#### How is eConnect different from Integration Manager?

**Answer:** Integration Manager is a desktop tool with mapping screens that a user runs against files or ODBC sources, and it can use eConnect underneath. eConnect is a developer library and set of stored procedures you call from your own code, a service or BizTalk. For unattended, real-time invoice creation from another system, eConnect is the usual choice.

#### Can eConnect post the batch as well?

**Answer:** No. eConnect creates unposted transactions in the SOP work tables. Posting is done by a user in GP (Sales Batch Entry or Series Post) or with a third-party posting tool. Plan for a person or scheduled process to post the batch named in BACHNUMB, and keep integration batches separate from manual ones.

## Search terms

dynamics gp api, dynamics gp invoice integration, microsoft dynamics gp api, dynamics gp econnect sop invoice, taSopHdrIvcInsert example, taSopLineIvcInsert xml, econnect CreateTransactionEntity c#, dynamics gp integration manager alternative

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
