web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

eConnect Return Error - GP 10

(0) ShareShare
ReportReport
Posted on by 380

All,

What I am attempting to do is take an invoice that exists in GP with a certain number and return that invoice.  I believe the goal is to return any items to inventory and credit the customer (and possibly affect the status of the original invoice?).

I admit that I don't really understand how I should be setting this.  For instance: Do I use the number of the invoice for the return? For one or both of the properties? (DOCID / SOPNUMBE)  If I use another number (I've tried both ways with the same error), how do I link this return to the original invoice (or do I even need to?)

That being said, I am using this code: (ec and ecs are namespace shortcuts that I added in my using statements section)

var salesInvoice = getSalesInvoice(invoiceNumber);

var eConnect = new ec.eConnectMethods();

var ecType = new ecs.eConnectType();

var salesReturn = new ecs.taSopHdrIvcInsert();
salesReturn.SOPTYPE = 4; // RETURN
salesReturn.DOCID = salesInvoice.Key.Id;
salesReturn.SOPNUMBE = salesInvoice.Key.Id;
salesReturn.CUSTNMBR = salesInvoice.CustomerKey.Id;
salesReturn.BACHNUMB = string.Format("RTRN{0}", DateTime.Today.ToString("yyyyMMdd"));
salesReturn.DOCAMNT = salesInvoice.TotalAmount.Value;
salesReturn.DOCDATE = DateTime.Now.ToString("yyyy-MM-dd");

var lines = new List<ecs.taSopLineIvcInsert_ItemsTaSopLineIvcInsert>();

foreach (var invoiceLine in salesInvoice.Lines)
{
var lineItem = new ecs.taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
lineItem.ITEMNMBR = invoiceLine.ItemKey.Id;
lineItem.NONINVEN = (invoiceLine.IsNonInventory.HasValue && invoiceLine.IsNonInventory.Value)
? (Int16) 1
: (Int16) 0;
lineItem.QTYRTRND = invoiceLine.Quantity.Value;
lineItem.QUANTITY = invoiceLine.Quantity.Value;
lineItem.DOCID = salesReturn.DOCID;
lineItem.SOPNUMBE = salesReturn.SOPNUMBE;
lineItem.CUSTNMBR = salesReturn.CUSTNMBR;
lineItem.SOPTYPE = 4; // RETURN
lineItem.DOCDATE = salesReturn.DOCDATE;

lines.Add(lineItem);
}

ecType.SOPTransactionType = new ecs.SOPTransactionType[1];
ecType.SOPTransactionType[0] = new ecs.SOPTransactionType();
ecType.SOPTransactionType[0].taSopHdrIvcInsert = new ecs.taSopHdrIvcInsert();

ecType.SOPTransactionType[0].taSopHdrIvcInsert = salesReturn;
ecType.SOPTransactionType[0].taSopLineIvcInsert_Items = new ecs.taSopLineIvcInsert_ItemsTaSopLineIvcInsert[lines.Count];
ecType.SOPTransactionType[0].taSopLineIvcInsert_Items = lines.ToArray();

var stringWriter = new StringWriter();
var serializer = new XmlSerializer(typeof(ecs.eConnectType));
serializer.Serialize(stringWriter, ecType);

var returnValue = eConnect.eConnect_EntryPoint(connectionString, ec.EnumTypes.ConnectionStringType.SqlClient, stringWriter.ToString(), ec.EnumTypes.SchemaValidationType.None, string.Empty);

When I run it, I get this error:

Microsoft.Dynamics.GP.eConnect.eConnectException: Sql procedure error codes returned:
Error Number = 3441 Stored Procedure taSopLineIvcInsert Error Description = DOCID does not exist for document type
Node Identifier Parameters: taSopLineIvcInsert
SOPNUMBE = 2862083
SOPTYPE = 4
Related Error Code Parameters for Node : taSopLineIvcInsert
DOCID = 2862083
SOPTYPE = 4

The serialized version of my object looks like this:

<eConnect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOPTransactionType>
<eConnectProcessInfo xsi:nil="true" />
<taRequesterTrxDisabler_Items xsi:nil="true" />
<taUpdateCreateItemRcd xsi:nil="true" />
<taUpdateCreateCustomerRcd xsi:nil="true" />
<taCreateCustomerAddress_Items xsi:nil="true" />
<taSopSerial_Items xsi:nil="true" />
<taSopLotAuto_Items xsi:nil="true" />
<taSopLineIvcInsert_Items>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUST</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4244</ITEMNMBR>
<QUANTITY>8.00000</QUANTITY>
<QTYRTRND>8.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>2862083</DOCID>
</taSopLineIvcInsert>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUST</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4402</ITEMNMBR>
<QUANTITY>34.00000</QUANTITY>
<QTYRTRND>34.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>2862083</DOCID>
</taSopLineIvcInsert>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUST</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4520</ITEMNMBR>
<QUANTITY>120.00000</QUANTITY>
<QTYRTRND>120.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>2862083</DOCID>
</taSopLineIvcInsert>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUST</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4927</ITEMNMBR>
<QUANTITY>3.00000</QUANTITY>
<QTYRTRND>3.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>2862083</DOCID>
</taSopLineIvcInsert>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUST</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4352</ITEMNMBR>
<QUANTITY>36.00000</QUANTITY>
<QTYRTRND>36.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>2862083</DOCID>
</taSopLineIvcInsert>
</taSopLineIvcInsert_Items>
<taSopLineIvcInsertComponent_Items xsi:nil="true" />
<taSopTrackingNum_Items xsi:nil="true" />
<taSopCommissions_Items xsi:nil="true" />
<taSopLineIvcTaxInsert_Items xsi:nil="true" />
<taCreateSopPaymentInsertRecord_Items xsi:nil="true" />
<taSopUserDefined xsi:nil="true" />
<taSopDistribution_Items xsi:nil="true" />
<taAnalyticsDistribution_Items xsi:nil="true" />
<taSopMultiBin_Items xsi:nil="true" />
<taSopHdrIvcInsert>
<SOPTYPE>4</SOPTYPE>
<DOCID>2862083</DOCID>
<SOPNUMBE>2862083</SOPNUMBE>
<DOCDATE>2013-03-14</DOCDATE>
<CUSTNMBR>VALIDCUST</CUSTNMBR>
<DOCAMNT>432.39000</DOCAMNT>
<BACHNUMB>RTRN20130314</BACHNUMB>
</taSopHdrIvcInsert>
<taSopToPopLink xsi:nil="true" />
<taSopUpdateCreateProcessHold xsi:nil="true" />
<taCreateSOPTrackingInfo xsi:nil="true" />
<taMdaUpdate_Items xsi:nil="true" />
</SOPTransactionType>
</eConnect>|

Most results that I've found when Googling this point to people not setting their SOP Type on all of the line items or not at all in header or line item.  As you can see, I'm not doing either one.  I can't find any good actual guidance for the best practice for how to do this at all and I've spent days going through the SDK Documentation.

I would appreciate any and all help not only into that error, but any correction you can offer to the *manner* that I'm going about this.  Thank you very much in advance.

*This post is locked for comments

  • Community Member Profile Picture
    on at

    Hi Ron,

    It looks like what you would want to do is

    Get the invoice that you want to return but use that SOPNUMBE and SOPTYPE and pass those to the ORIGNUMB and ORIGTYPE when you are trying to create your return. This should link your return to the original invoice.

    I would expect for the new DOCID and SOPNUMBE you are creating you would pass the DOCID you want to use that exists in GP and some new SOPNUMBE. You should be able to supply your own unique SOPNUMBE or retrieve the next one from GP for your intended DOCID.

    I hope this helps.

    Adam

  • RonCarter Profile Picture
    380 on at

    Adam,

    Thank you for your answer.  The ORIGNUM and ORIGTYPE definitely have to be a factor, but I am still getting an error.  I tried what you said and hd the docid and sopnumbe be different, as well as making them the same.

    Both times, I got the same error (below).  Interestingly, the error is on the LINE insert (which comes first in the serialization).  Do I need to do 2 econnect calls and send only the header and then send only the lines?

    This is the part where some solid documentation would be amazing.  Other things I've tried (right out of the SDK documentation) have failed, so I'm feeling pretty frustrated and helpless.

    Thanks for anyone who looks at this.

    Microsoft.Dynamics.GP.eConnect.eConnectException: Sql procedure error codes returned:

    Error Number = 3441  Stored Procedure taSopLineIvcInsert  Error Description = DOCID does not exist for document type

    Node Identifier Parameters: taSopLineIvcInsert                                

    SOPNUMBE = RTN2862083

    SOPTYPE = 4

    Related Error Code Parameters for Node : taSopLineIvcInsert                                

    DOCID = 2862083

    SOPTYPE = 4

    <taSopLineIvcInsert><SOPTYPE>4</SOPTYPE><SOPNUMBE>RTN2862083</SOPNUMBE><CUSTNMBR>VALIDCUSTOMER</CUSTNMBR><DOCDATE>2013-03-14</DOCDATE><ITEMNMBR>A4244</ITEMNMBR><QUANTITY>8.00000</QUANTITY><QTYRTRND>8.00000</QTYRTRND><NONINVEN>1</NONINVEN><DOCID>2862083</DOCID></taSopLineIvcInsert> ---> Microsoft.Dynamics.GP.eConnect.eConnectException: Error Number = 3441  Stored Procedure taSopLineIvcInsert  Error Description = DOCID does not exist for document type

    And

    Microsoft.Dynamics.GP.eConnect.eConnectException: Sql procedure error codes returned:

    Error Number = 3441  Stored Procedure taSopLineIvcInsert  Error Description = DOCID does not exist for document type

    Node Identifier Parameters: taSopLineIvcInsert                                

    SOPNUMBE = RTN2862083

    SOPTYPE = 4

    Related Error Code Parameters for Node : taSopLineIvcInsert                                

    DOCID = RTN2862083

    SOPTYPE = 4

    <taSopLineIvcInsert><SOPTYPE>4</SOPTYPE><SOPNUMBE>RTN2862083</SOPNUMBE><CUSTNMBR>VALIDCUSTOMER</CUSTNMBR><DOCDATE>2013-03-14</DOCDATE><ITEMNMBR>A4244</ITEMNMBR><QUANTITY>8.00000</QUANTITY><QTYRTRND>8.00000</QTYRTRND><NONINVEN>1</NONINVEN><DOCID>RTN2862083</DOCID></taSopLineIvcInsert> ---> Microsoft.Dynamics.GP.eConnect.eConnectException: Error Number = 3441  Stored Procedure taSopLineIvcInsert  Error Description = DOCID does not exist for document type

    The full XML looks like the one I pasted earlier, except with the additional fields of

    <ORIGNUMB>2862083</ORIGNUMB>

         <ORIGTYPE>3</ORIGTYPE>

    in the header.

  • Community Member Profile Picture
    on at

    Hi Ron,

    In your example, it looks like the DOCID is not right you have it as "2862083" but usually it would be something like "STDORD" or "RTN".

    Let me know if that makes a difference.

    Thanks,

    Adam

  • RonCarter Profile Picture
    380 on at

    I have two examples, one time the DOCID is RTN2862083 and the other time it is just 2862083.  Are you saying it should just be something non-unique like STDORD or RTN for instance?

  • RonCarter Profile Picture
    380 on at

    Also, I just tried with a DOCID of just "RTN" and it also failed.

  • Community Member Profile Picture
    on at

    Hi Ron,

    The DOCID shoudl match an entry in SOP40200 which would be something non-unique like STDORD or RTN.

    Adam

  • RonCarter Profile Picture
    380 on at

    Adam,

    We are really on to something now!  Thank you so much for your help to this point.  I queried that table and I only have these values in there:

    INV            

    PHARMACY      

    ANCILLARY      

    ELECTROTHERAPY

    DME            

    ORD            

    Nothing that looks like a return.  Can you tell me (just a link or what to query) what I'd need to have someone do to add a value in there?  I assume it can be done in the UI?

  • Community Member Profile Picture
    on at

    Hi Ron,

    Under GP >> Sales >> Setup >> Sales Order Processing >> Sales Document Setup.

    That screen should let the user setup a Return ID that would then show up in your table.

    Let me know if that helps!

  • RonCarter Profile Picture
    380 on at

    Adam,

    You are some kind of wizard.  That totally got me past my most recent problem and since I know that, it means that my other things I've tried (including the pasted example Microsoft code) would probably work now.  

    However, I have this error now:Microsoft.Dynamics.GP.eConnect.eConnectException: Error Number = 181  Stored Procedure taSopHdrIvcInsert  Error Description = Originating Order Type and Originating Order Number are not allowed on Returns

    So, it doesn't like the original order type and number I added at your suggestion earlier.  Do you have any other idea as to what I would do to link the return to the invoice if I can't use those?

  • Community Member Profile Picture
    on at

    Ron,

    Make sure the originating order you are using to return is an Invoice Doc Type (SOPTYPE = 3).

    Let me know if that is not it.

    Thanks!

    Adam

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans