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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Problem in taPopCreateDistributions

(0) ShareShare
ReportReport
Posted on by

I can't seem to convince microsoft there's an issue with this join in the taPopCreateDistributions sp

It appears they changed it at one point, but I think it should be    where a.POPIVCNO = @I_vPOPRCTNM and a.POPRCTNM = s.POPRCTNM and a.RCPTLNNM = s.RCPTLNNM/*70845*/

the original is below.   With their Join, it's not getting the right Purchasing distribution (type 1)

Can someone check the logic here, and let me know if I'm right?

insert into #temp
(
DTYPE,
DTAMT,
CTAMT,
ORDTAMT,
ORCTAMT,
DTINDEX,
XCHGRATE
)
select
1,
case
when @I_vXCHGRATE <> 0 and @I_vRTCLCMTD = 0 and isnull(sum(a.PPVTotal),0) > 0
then sum(round(isnull((a.PPVTotal) * a.QTYINVCD * s.XCHGRATE,0), @FUNDECPLCUR))
when @I_vXCHGRATE <> 0 and @I_vRTCLCMTD = 1 and isnull(sum(a.PPVTotal),0) > 0
then sum(round(isnull((a.PPVTotal) * a.QTYINVCD / nullif(s.XCHGRATE,0),0), @FUNDECPLCUR))
when @I_vXCHGRATE = 0 and isnull(sum(a.PPVTotal),0) > 0
then sum(round(isnull(a.PPVTotal,0), @FUNDECPLCUR))
else 0
end,
case
when @I_vXCHGRATE <> 0 and @I_vRTCLCMTD = 0 and isnull(sum(a.PPVTotal),0) < 0
then abs(sum(round(isnull((a.PPVTotal) * a.QTYINVCD * s.XCHGRATE,0), @FUNDECPLCUR)))
when @I_vXCHGRATE <> 0 and @I_vRTCLCMTD = 1 and isnull(sum(a.PPVTotal),0) < 0
then abs(sum(round(isnull((a.PPVTotal) * a.QTYINVCD / nullif(s.XCHGRATE,0),0), @FUNDECPLCUR)))
when @I_vXCHGRATE = 0 and isnull(sum(a.PPVTotal),0) < 0
then abs(sum(round(isnull(a.PPVTotal,0), @FUNDECPLCUR)))
else 0
end,
case
when isnull(sum(a.PPVTotal),0) > 0
then sum(round(isnull(a.PPVTotal,0), @I_vDECPLUSED))
else 0
end,
case
when isnull(sum(a.PPVTotal),0) < 0
then abs(sum(round(isnull(a.PPVTotal,0), @I_vDECPLUSED)))
else 0
end,
a.PURPVIDX,
s.XCHGRATE
from POP10600 a (nolock), POP10500 s (nolock), IV00101 c (nolock), POP10310 d (nolock)
where a.POPIVCNO = @I_vPOPRCTNM and a.POPRCTNM = s.POPRCTNM and a.RCPTLNNM = s.POLNENUM/*70845*/ and c.ITEMNMBR = s.ITEMNMBR and
c.VCTNMTHD in(1,2,3) and d.Landed_Cost = 0 and d.POPRCTNM = @I_vPOPRCTNM and d.RCPTLNNM = a.RCPTLNNM
group by a.POPIVCNO, a.PURPVIDX, s.XCHGRATE

*This post is locked for comments

I have the same question (0)
  • MG-16101311-0 Profile Picture
    26,225 on at

    Dan Peltier, what say you? OP seems to have a point.

  • Dan Peltier Profile Picture
    on at

    The cold hard callout, I like it. :)

    OP is correct, this proc was changed at one point. The '70845' correlates with an internal bug number, so I'm guessing the lines with that number are the exact ones that were changed. I opened up the details of this bug, and this is the problem description:

    When calling the procs, taPopEnterMatchInvHdr and taPopEnterMatchInvLine to match a landed cost that is marked as Flat Amount per unit the distributions do not balance.  Also, when comparing to a manually entered invoice, a different PPV account is used and the amounts differ.

    The original bug was found on GP 2013 R2, and was fixed in GP 2016 RTM. The code in question was the code that was added in GP 2016 to resolve the specific condition where using taPopEnterMatchInvHdr and taPopEnterMatchInvLine  to match a LC that is marked as Flat Amount per unit creates unbalanced distributions.

    If this specific code is causing distribution errors for OP's integration, then where I'd have to start in debugging this would be a sample document to execute, as this error is really going to occur under very specific data conditions. Whatever sample we were running when testing this bug out obviously ran satisfactorily when the Dev's shipped this code, so there's probably an additional consideration with the OP's document that is different than what we initially tested on. Our code currently pulls the POP10500.POLNENUM rather than the POP10500.RCPTLNNM, so if there's a data condition where that is incorrectly calculating the distributions, and it needs to pull the Receipt number instead of the PO Number, then I would need to see a sample eConnect call that can reproduce this issue. I'd be happy to dig into this in my lab and the decrypted procs to walk through and see why it's calculating improperly, but without the context of how this specific call is miscalculating I cannot answer why we're pulling the POLNENUM instead of the RCPTLNNM column.

    Long story short, do you have an eConnect execution example that reproduces this issue that I can debug? If you have code that can create the document with the specific data condition, that would help a lot.

  • Community Member Profile Picture
    on at

    is there a way for me to attach a file on this?    I have a couple of excel spreadsheets with the data in them

  • Community Member Profile Picture
    on at

    the actual distribution should be around 73 or so.... if it had picked up the negative amounts on the inventory adjustments

    INV_51454068 16384 1696 0.00000 0.00000 93.03000 93.03000 1
    INV_51454068 32768 2417 0.00000 0.00000 264.82000 264.82000 1
    INV_51454068 49152 2317 4175.77000 4175.77000 0.00000 0.00000 7
    INV_51454068 65536 2323 0.00000 0.00000 3839.42000 3839.42000 9

    New Join

    popivcno poprctnm poprctnm rcptlnnm RCPTLNNM itemnmbr poprctnm
    INV_51454068      RCPT2018012500269 -5.59 RCPT2018012500269 16384 16384 000009781319019488BN            INV_51454068     
    INV_51454068      RCPT2018012500270 -16.77 RCPT2018012500270 16384 16384 000009781319019488BN            INV_51454068     
    INV_51454068      RCPT2018012500271 0 RCPT2018012500271 32768 32768 000009781319133160BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 16384 16384 000009781319017125BN            INV_51454068     
    INV_51454068      RCPT2018012500271 0 RCPT2018012500271 49152 49152 000009781464138744BN            INV_51454068     
    INV_51454068      RCPT2018012500272 0 RCPT2018012500272 32768 32768 000009781464138744BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 131072 131072 000009781319058562BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 32768 32768 000009781319020132BN            INV_51454068     
    INV_51454068      RCPT2018012600351 2.56 RCPT2018012600351 49152 49152 000009781319029180BN            INV_51454068     
    INV_51454068      RCPT2018012600351 1.11 RCPT2018012600351 65536 65536 000009781319030896BN            INV_51454068     
    INV_51454068      RCPT2018012600351 1.91 RCPT2018012600351 81920 81920 000009781319035303BN            INV_51454068     
    INV_51454068      RCPT2018012500273 4.26 RCPT2018012500273 32768 32768 000009781319035327BN            INV_51454068     
    INV_51454068      RCPT2018012600351 4.26 RCPT2018012600351 98304 98304 000009781319035327BN            INV_51454068     
    INV_51454068      RCPT2018012500273 -2.2 RCPT2018012500273 65536 65536 000009781319058548BN            INV_51454068     
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 147456 147456 000009781319087326BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 180224 180224 000009781319072902BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 147456 147456 000009781319059491BN            INV_51454068     
    INV_51454068      RCPT2018012600351 -0.08 RCPT2018012600351 278528 278528 000009781429260183BN            INV_51454068     
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 81920 81920 000009781319058593BN            INV_51454068     
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 98304 98304 000009781319061784BN            INV_51454068     
    INV_51454068      RCPT2018012500273 1.5 RCPT2018012500273 114688 114688 000009781319063108BN            INV_51454068     
    INV_51454068      RCPT2018012500273 3.5 RCPT2018012500273 131072 131072 000009781319065461BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 212992 212992 000009781319111571BN            INV_51454068     
    INV_51454068      RCPT2018012300432 0 RCPT2018012300432 32768 32768 000009781319125189BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 229376 229376 000009781319125189BN            INV_51454068     
    INV_51454068      RCPT2018012200144 0 RCPT2018012200144 16384 16384 000009781319133054BN            INV_51454068     
    INV_51454068      RCPT2018012600351 4.47 RCPT2018012600351 262144 262144 000009781429219549BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 294912 294912 000009781441124579BN            INV_51454068     
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 196608 196608 000009781457669347BN            INV_51454068     
    INV_51454068      RCPT2018012700108 0 RCPT2018012700108 16384 16384 000009781464109362BN            INV_51454068     
    INV_51454068      RCPT2018012600351 -5.94 RCPT2018012600351 163840 163840 000009781319059538BN            INV_51454068     
    INV_51454068      RCPT2018012500273 2.18 RCPT2018012500273 16384 16384 000009780716739005BN            INV_51454068     
    INV_51454068      RCPT2018012500273 5.4 RCPT2018012500273 49152 49152 000009781319035365BN            INV_51454068     
    INV_51454068      RCPT2018012600351 64.8 RCPT2018012600351 114688 114688 000009781319035365BN            INV_51454068     
    INV_51454068      RCPT2018012300432 0 RCPT2018012300432 16384 16384 000009781319061784BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 196608 196608 000009781319083502BN            INV_51454068     
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 212992 212992 000009781464122262BN            INV_51454068     
    INV_51454068      RCPT2018012500273 8.6 RCPT2018012500273 229376 229376 000009781464140815BN            INV_51454068     
    INV_51454068      RCPT2018012400670 0 RCPT2018012400670 16384 16384 000009781498603041BN            INV_51454068     
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 245760 245760 000009781501314711BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 311296 311296 000009781501315411BN            INV_51454068     
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 327680 327680 000009781501315657BN            INV_51454068     
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 262144 262144 000009781609015121BN            INV_51454068     
    INV_51454068      RCPT2018012600351 -2.44 RCPT2018012600351 344064 344064 000009781903436813BN            INV_51454068     

    Existing

    popivcno poprctnm ppvtotal poprctnm rcptlnnm RCPTLNNM
    INV_51454068      RCPT2018012600351 2.56 RCPT2018012600351 49152 16384
    INV_51454068      RCPT2018012600351 1.11 RCPT2018012600351 65536 32768
    INV_51454068      RCPT2018012500273 4.26 RCPT2018012500273 32768 16384
    INV_51454068      RCPT2018012600351 1.91 RCPT2018012600351 81920 49152
    INV_51454068      RCPT2018012600351 4.26 RCPT2018012600351 98304 65536
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 131072 98304
    INV_51454068      RCPT2018012600351 4.47 RCPT2018012600351 262144 163840
    INV_51454068      RCPT2018012600351 -2.44 RCPT2018012600351 344064 180224
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 212992 131072
    INV_51454068      RCPT2018012600351 0 RCPT2018012600351 147456 114688
    INV_51454068      RCPT2018012500273 3.5 RCPT2018012500273 131072 32768
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 147456 49152
    INV_51454068      RCPT2018012500273 0 RCPT2018012500273 196608 65536
    INV_51454068      RCPT2018012500273 8.6 RCPT2018012500273 229376 81920
    INV_51454068      RCPT2018012600351 64.8 RCPT2018012600351 114688 81920
  • Dan Peltier Profile Picture
    on at

    Hi ssytyler,

    This gives us a good picture of what's in the tables, but I'm not enough of a wizard to know what I'm looking at just by seeing the tables. This answers the question of what your tables look like at the time eConnect is running, but what this doesn't tell us is how that data got there in the first place. That's really going to be the key information here, because correct me if I'm wrong, but this issue isn't occurring for all documents, right? It's just occurring for specific ones?

    If these documents are being hand keyed then touched with eConnect later, then I suppose I can try entering a document myself and seeing if my records show up like yours are, but since the data condition here is very specific, I would need to set up the Inventory item to mimic yours, as well as everything else. Do you have any of that information for me?

    If these documents are being entered with eConnect, do you just have the XML or SQL code that this document is being created with?

  • MG-16101311-0 Profile Picture
    26,225 on at

    Dan Peltier, you're one of the good guys, can't help but calling you out on that :-)

  • Community Member Profile Picture
    on at

    sorry about that.

    The invoices come thru biztalk edi, which puts it on an econnect message queue

    No... it doesn't seem to be happening to all of them.  Specifically happens on invoices that need to adjust the cost of the items.  In fact... if they go into great plains, and remove the distributions, it calcuates them ok within the system.

    Here's an example of one of the xml files, that was sent thru to econnect

    The CreateDist flag is set, to automatically create the distributions.  The only distribution that is off is type 1

    We don't have multi-currency set, which is what microsoft was wanting us to do.  But, we don't have a need for multi-currency.

    Our exchange rate is zero, which would cause it to drop into the 3 when condition of the case statement, in the insert I've been looking at.   (in my first posting)

    further info

    a. We don’t use discounts on any POP invoices.

    b. We don’t use MDA.

    c. These are all inventory items.

    d. We don’t use project accounting.

    e. We don’t use discounts on any POP invoices.

    f. Sometimes there is a freight amount on the POP invoice, and likewise a FREIGHT distribution.  But not often.  And I have not seen any case where the FREIGHT distribution is incorrect (i.e. doesn’t match the Freight field on the invoice).

    I don't believe we use Landed cost.   Is there a way to check?

    <?xml version="1.0" encoding="UTF-8"?>

    -<eConnect>

    -<POPEnterMatchInvoiceType>

    -<taPopEnterMatchInvLine_Items>

    -<taPopEnterMatchInvLine>

    <POPRCTNM>INV_32356332</POPRCTNM>

    <PONUMBER>WD987999</PONUMBER>

    <QTYINVCD>1</QTYINVCD>

    <ITEMNMBR>000009780691168821BN</ITEMNMBR>

    <VENDORID>IV26521</VENDORID>

    <VNDITNUM>000009780691168821BN</VNDITNUM>

    <UNITCOST>29.95</UNITCOST>

    <EXTDCOST>29.95</EXTDCOST>

    <NONINVEN>0</NONINVEN>

    <AUTOCOST>0</AUTOCOST>

    <POLNENUM>32768</POLNENUM>

    <CURNCYID>Z-US$</CURNCYID>

    </taPopEnterMatchInvLine>

    -<taPopEnterMatchInvLine>

    <POPRCTNM>INV_32356332</POPRCTNM>

    <PONUMBER>WD987999</PONUMBER>

    <QTYINVCD>3</QTYINVCD>

    <ITEMNMBR>000009780691141039BN</ITEMNMBR>

    <VENDORID>IV26521</VENDORID>

    <VNDITNUM>000009780691141039BN</VNDITNUM>

    <UNITCOST>28.00</UNITCOST>

    <EXTDCOST>84.00</EXTDCOST>

    <NONINVEN>0</NONINVEN>

    <AUTOCOST>0</AUTOCOST>

    <POLNENUM>16384</POLNENUM>

    <CURNCYID>Z-US$</CURNCYID>

    </taPopEnterMatchInvLine>

    -<taPopEnterMatchInvLine>

    <POPRCTNM>INV_32356332</POPRCTNM>

    <PONUMBER>WD987999</PONUMBER>

    <QTYINVCD>6</QTYINVCD>

    <ITEMNMBR>000009781441317445BN</ITEMNMBR>

    <VENDORID>IV26521</VENDORID>

    <VNDITNUM>000009781441317445BN</VNDITNUM>

    <UNITCOST>4.63</UNITCOST>

    <EXTDCOST>27.78</EXTDCOST>

    <NONINVEN>0</NONINVEN>

    <AUTOCOST>0</AUTOCOST>

    <POLNENUM>131072</POLNENUM>

    <CURNCYID>Z-US$</CURNCYID>

    </taPopEnterMatchInvLine>

    -<taPopEnterMatchInvLine>

    <POPRCTNM>INV_32356332</POPRCTNM>

    <PONUMBER>WD987999</PONUMBER>

    <QTYINVCD>8</QTYINVCD>

    <ITEMNMBR>000009780873518611BN</ITEMNMBR>

    <VENDORID>IV26521</VENDORID>

    <VNDITNUM>000009780873518611BN</VNDITNUM>

    <UNITCOST>10.41</UNITCOST>

    <EXTDCOST>83.28</EXTDCOST>

    <NONINVEN>0</NONINVEN>

    <AUTOCOST>0</AUTOCOST>

    <POLNENUM>98304</POLNENUM>

    <CURNCYID>Z-US$</CURNCYID>

    </taPopEnterMatchInvLine>

    -<taPopEnterMatchInvLine>

    <POPRCTNM>INV_32356332</POPRCTNM>

    <PONUMBER>WD987999</PONUMBER>

    <QTYINVCD>8</QTYINVCD>

    <ITEMNMBR>000009781595586834BN</ITEMNMBR>

    <VENDORID>IV26521</VENDORID>

    <VNDITNUM>000009781595586834BN</VNDITNUM>

    <UNITCOST>14.47</UNITCOST>

    <EXTDCOST>115.76</EXTDCOST>

    <NONINVEN>0</NONINVEN>

    <AUTOCOST>0</AUTOCOST>

    <POLNENUM>163840</POLNENUM>

    <CURNCYID>Z-US$</CURNCYID>

    </taPopEnterMatchInvLine>

    </taPopEnterMatchInvLine_Items>

    -<taPopEnterMatchInvHdr>

    <POPRCTNM>INV_32356332</POPRCTNM>

    <VNDDOCNM>32356332</VNDDOCNM>

    <receiptdate>12-28-2017</receiptdate>

    <BACHNUMB>IV26521_14</BACHNUMB>

    <VENDORID>IV26521</VENDORID>

    <SUBTOTAL>340.77</SUBTOTAL>

    <FRTAMNT>1.50</FRTAMNT>

    <MISCAMNT>0.00</MISCAMNT>

    <PYMTRMID>NET 30</PYMTRMID>

    <AUTOCOST>0</AUTOCOST>

    <CURNCYID>Z-US$</CURNCYID>

    <CREATEDIST>1</CREATEDIST>

    </taPopEnterMatchInvHdr>

    </POPEnterMatchInvoiceType>

    </eConnect>

  • Dan Peltier Profile Picture
    on at

    Thanks, that definitely helps. I was thinking this issue looked familiar, I was actually the original case owner. I deferred troubleshooting to our Application Support team, since this issue isn't happening for all documents and it's a specific data condition that's triggering the error. I was also who suggested enabling Multicurrency. That's still going to be our best bet. Many of eConnect's distribution calculations happen by selecting POP/INV tables based on currency, so if any extra records come back, that can instantly create extra distributions even if you're not actually using MC. eConnect really doesn't care whether or not you have it activated, but if it finds records with a currency on them in any of those tables, it assumes Multicurrency is in place and there's no way to change that behavior. MC simply has to be enabled. That's going to be the #1 recommendation still.

    I executed the document you provided against a PO I hand keyed, but I didn't receive any distribution errors. Everything calculated properly for me. Can you provide a screenshot of exactly what the distributions look like for the document you provided me? I want to compare to see what the discrepancy is.

    Additionally, I stepped through the entire procedure execution and watched the distributions being created. There's a dozen or so different statements that can run to calculate distributions based on whether or not certain SELECT statements return specific values. Long story short, if I can't reproduce the issue internally, I can't make a judgement call on whether or not changing s.POLNENUM to s.RCPTLNNM is a supported resolution. We really have to step through a document that's having the issue, debug the proc execution, and watch the process run through and calculate the distributions based on your environmental variables. If you have a document that can reproduce the issue every time you run it, circle back with Ron and Adam to schedule a stream session to debug that document. I'd be happy to join the call as well, but Adam is going to be the best resource to continue troubleshooting, since again the issue is only triggering under specific document conditions.

    Thanks,

  • Community Member Profile Picture
    on at

    Hi all,

    not to try and raise the dead, what with this thread being over a year old, however we've run into this issue where the Distribution amount ends up being incorrect when a change is made on the Cost.

    In short, it comes down to how the calculation is being made in the proc taPopCreateDistributions.

    This has been tested and confirmed as incorrect, according to performing the same steps within GP via going through eConnect, for our GP 2018 RTM system, GP 2018 R2 system. Furthermore, reviewing a GP 2016 R2 system it seems the proc change, in the statement as mentioned in the original post, took place around then, because testing in our GP 2015 system, there is no issue and all totals line up.

    They're really, two further points to this post; is there anywhere that offers visibility into open issues of this nature, that an individual can go check in on (unless this forum is that place, I was curious what the whole internal bug reference to "70845" was about), and it seems the this was left unanswered and floating out there because of a potential lack of ability to replicate, if that is the case and we can try to provide additional info, please let me know and we'll do what we can.

    It is worth pointing out, to see a discrepancy, it's best to have more than one document in the system where the Cost has been altered, in our case, we performed testing by reducing said unit cost during the invoicing stage of a PO . Not that it probably matters, but again if we can supply any detail please let us know.

    Disclaimer: I'm no GP or eConnect expert, or even novice, but we'd like to see if we can resolve this as it's got the potential to affect end users.

    Edit: a link to a video captured by someone replicating the issue in our internal QA, using Fabrikam, Inc.: https://www.dropbox.com/s/9t4j787s3eojdvs/2019-06-12%2013.28%20Meet%20Now.mp4?dl=0
    Please note at the end it is mentioned it is a PPV account but actually it is a credit back to inventory. (000-1300-01)

    Cheers,

    MP

  • Lucas Miller Profile Picture
    on at

    Hello MP,

    The community forums aren't really conducive to troubleshooting something complex like eConnect.  If you believe you are running into an issue you can open a support case with the sample call you're making to eConnect to procedure the issue and we can debug the call and submit a problem report if necessary.  If it is a product issue it would end up as a non-chargeable incident.

    Let me know if you have any questions.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans