Friday, March 2, 2018

Sample Dynamics GP eConnect XML for RM Apply (RMApplyType / taRMApply)

By Steve Endow

A customer asked for sample XML for the RMApplyType / taRMApply eConnect transaction type.  I couldn't find one handy during a search, so I had to cobble together some .NET code and generate the XML.

I'm wondering if there is an easier way to generate the sample eConnect XML.  In theory, eConnect Requester with the eConnect Outgoing Service can send certain XML documents to MSMQ, but that is a hassle to setup properly, and I don't know that all transaction types are supported by eConnect Requester--such RMApplyType.


So, here is a sample Dynamics GP eConnect XML document for RM Apply (RMApplyType / taRMApply)


<?xml version="1.0"?>
<eConnect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <RMApplyType>
                        <eConnectProcessInfo xsi:nil="true" />
                        <taRequesterTrxDisabler_Items xsi:nil="true" />
                        <taAnalyticsDistribution_Items xsi:nil="true" />
                        <taRMApply>
                                    <APTODCNM>SALES100001</APTODCNM>
                                    <APFRDCNM>PYMNT100001</APFRDCNM>
                                    <APPTOAMT>123.45</APPTOAMT>
                                    <APFRDCTY>9</APFRDCTY>
                                    <APTODCTY>1</APTODCTY>
                                    <DISTKNAM>0</DISTKNAM>
                                    <APPLYDATE>2017-04-12</APPLYDATE>
                                    <GLPOSTDT>2017-04-12</GLPOSTDT>
                        </taRMApply>
            </RMApplyType>
</eConnect>


Discount Taken, Apply Date, and GL Post Date are optional, and do not have to be assigned or included in the XML if they are not needed.

Here is the eConnect documentation on taRMApply.


9 comments:

Riaan Taljaard said...

Hi Steve

I have a question. We have developed a tool to take users through workflow of what to apply etc. Mainly for discounts that need approval.

When we use eConnect to generate teh apply, GP does not generate teh tax entry in the GL batch. We have the "Tax Rebate" option marked in teh company setup. When you manually apply GP writes a3rd line in teh GL batch for teh tax when pricessing discount.

Riaan

Steve Endow said...

Hi Riaan,

I'd like to get more information about your GP setup and the transaction you are trying to import.

Can you please contact me at steveendow (at) gmail / com so that I can get more info?

Thanks,

Steve

Pavan Gaddirala said...

Hi Steve,

I'm trying to apply the amounts to the posted invoices by using CreditMemos in GP. It is throwing an exception as "Object reference not set to an instance of an object." at the last line which is in BOLD letters.Below is the sample code . Please tell me where i'm missing.

RMApplyType[] rmarray = new RMApplyType[1];
taRMApply taApplyArray = new taRMApply();
decimal amount = 150;
taApplyArray.APFRDCTY = 7;
taApplyArray.APFRDCNM = "CREDT000000000034";
taApplyArray.APTODCTY = 1;
taApplyArray.APPLYDATE = System.DateTime.Now.ToString();
taApplyArray.APPTOAMT = amount;
taApplyArray.APTODCNM = "STDINV027";
rmarray[0].taRMApply = taApplyArray;

Regards,
Pavan G.

Steve Endow said...

Hi Pavan,

I can't tell why you are getting the object reference error, but I see that my RM Apply code is slightly different. Notice that I don't create an RMApplyType array. I just create a single instance, and then assign it to the eConnect.RMApplyType, and type it as an array (last line of code below).

Since I typically only send one transaction at a time to eConnect, this has always worked for me. Let me know if this works for you.


taRMApply rmApply = new taRMApply();

rmApply.APTODCNM = applyTo;
rmApply.APTODCTY = applyToType;
rmApply.APFRDCNM = applyFrom;
rmApply.APFRDCTY = applyFromType;
rmApply.APPTOAMT = applyAmount;

rmApply.WROFAMNT = 0;
rmApply.DISTKNAM = 0;
rmApply.DISTKNAMSpecified = true;

RMApplyType rmApplyType = new RMApplyType();
rmApplyType.taRMApply = rmApply;

eConnectType eConnect = new eConnectType();
eConnect.RMApplyType = new RMApplyType[] { rmApplyType };

Steve Endow said...

Hi Pavan,

I think I see the cause of the error. On your last line:

rmarray[0].taRMApply = taApplyArray;

rmarray[0] has not yet been assigned, so I'm guessing index 0 is null / empty, so there is no rmarray[0].taRMApply yet.

Give my code sample a try and see if that works for you.

Steve

Pavan Gaddirala said...

Thank u for responding Steve.

Please give me a sample code.i will try and let u know further output.

Pavan.

Pavan Gaddirala said...

Hi Steve,

I have resolved the previous issue .But i'm getting the another Error while CreateTransactionEntity as "
The INSERT statement conflicted with the CHECK constraint "CK__RM20201__DATE1__5105F123". The conflict occurred in database "B_BD", table "dbo.RM20201", column 'DATE1'.
The statement has been terminated." I googled this,some one suggested to me as,do alter that Check Constraint .BUt we should not dot hat .Please suggest me in this regard.

Steve Endow said...

Hi Pavan,

You should NOT alter the Check Constraint. The issue is that you are sending in a Date Time string to eConnect. You must send a date value only.

This is the line that is causing the error:

taApplyArray.APPLYDATE = System.DateTime.Now.ToString();


Try something like this:

DateTime.Today.ToShortDateString();

Pavan Gaddirala said...

Thank you very much Steve.

U r nailed it to explain for queries.I have cleared with your explanations.

Once again Thank u very much..Keep rocking.

Regards,
Pavan .