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
Good to hear it helped Ron.
We have recenlty been through a bunch of similar projects so let me know if you run into anything else.
eConnect is great but has some interesting quirks!
Thanks,
Adam
Adam, I marked your last answer as accepted because we called our GP Partner and that was basically their suggestion as well. I wish I could mark multiple answers because your earlier help also got me past my initial errors (and found something that someone had messed up in our GP setup).
David, we'll take a look at the Mass Apply RM stuff, too.
Recorded demo of Mass Apply Receivables is available at http://www.icansoftware.com
You could also use Mass Apply Receivables to allow you to have the system automatically apply the return to the invoice. With Mass Apply RM, you can store the invoice number in the Customer PO Number field on the return AND then you can run a routine that will find all returns, credits or payments referencing a valid invoice number and do the apply automatically.
Ron,
The other way you could get the result you want would be to integrate the return without any values for the original document number or type. Then, fill those values in after the fact.
This is a bit of a hack but would get the result you want and is simple to implement.
Let me know if you have any questions.
Adam
Well....
I did some digging on my examples and it looks like eConnect might not let you pass the original number and document for a Return. As in, it might only offer that functionality for doing invoices linked to orders or something similar.
This is probably tied to some of the business rules around returns.
So... what I would do is setup a "Invoice" document type with the Document ID set to "RTN" as you did for your Return document setup.
Then, find and integrate these transactions but do them as invoices instead and see if you your ORIGNUMB comes through so that they are linked.
Basically using this method you create a negative invoice which serves the same purpose as a return would.
Let me know if that works.
Thanks!
Adam
Here is everything:
2013-03-14 17:35:30.4926|Info|<?xml version="1.0" encoding="utf-16"?>
<eConnect xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../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>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>RTN</DOCID>
</taSopLineIvcInsert>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>RTN2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUSTOMER</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4402</ITEMNMBR>
<QUANTITY>34.00000</QUANTITY>
<QTYRTRND>34.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>RTN</DOCID>
</taSopLineIvcInsert>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>RTN2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUSTOMER</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4520</ITEMNMBR>
<QUANTITY>120.00000</QUANTITY>
<QTYRTRND>120.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>RTN</DOCID>
</taSopLineIvcInsert>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>RTN2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUSTOMER</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4927</ITEMNMBR>
<QUANTITY>3.00000</QUANTITY>
<QTYRTRND>3.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>RTN</DOCID>
</taSopLineIvcInsert>
<taSopLineIvcInsert>
<SOPTYPE>4</SOPTYPE>
<SOPNUMBE>RTN2862083</SOPNUMBE>
<CUSTNMBR>VALIDCUSTOMER</CUSTNMBR>
<DOCDATE>2013-03-14</DOCDATE>
<ITEMNMBR>A4352</ITEMNMBR>
<QUANTITY>36.00000</QUANTITY>
<QTYRTRND>36.00000</QTYRTRND>
<NONINVEN>1</NONINVEN>
<DOCID>RTN</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>RTN</DOCID>
<SOPNUMBE>RTN2862083</SOPNUMBE>
<ORIGNUMB>2862083</ORIGNUMB>
<ORIGTYPE>3</ORIGTYPE>
<DOCDATE>2013-03-14</DOCDATE>
<CUSTNMBR>VALIDCUSTOMER</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>|
Microsoft.Dynamics.GP.eConnect.eConnectException: Sql procedure error codes returned:
Error Number = 181 Stored Procedure taSopHdrIvcInsert Error Description = Originating Order Type and Originating Order Number are not allowed on Returns
Node Identifier Parameters: taSopHdrIvcInsert
SOPNUMBE = RTN2862083
SOPTYPE = 4
Related Error Code Parameters for Node : taSopHdrIvcInsert
ORIGNUMB = 2862083
ORIGTYPE = 3
SOPTYPE = 4
<taSopHdrIvcInsert><SOPTYPE>4</SOPTYPE><DOCID>RTN</DOCID><SOPNUMBE>RTN2862083</SOPNUMBE><ORIGNUMB>2862083</ORIGNUMB><ORIGTYPE>3</ORIGTYPE><DOCDATE>2013-03-14</DOCDATE><CUSTNMBR>VALIDCUSTOMER</CUSTNMBR><DOCAMNT>432.39000</DOCAMNT><BACHNUMB>RTRN20130314</BACHNUMB></taSopHdrIvcInsert> ---> 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
Can you cut/paste the XML from the last submission?
It is an SOPTYPE 3. Here is what I'm returning (info from the SalesTransactions view)
SOP Type Invoice
SOP Number 2862083
Document Date 2011-12-02 00:00:00.000
Document Amount 432.39000
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156