I am using the Intercompany Posting for some of my clients.  I have extended the functionality to make it possible to sell and purchase between responsibility centers within the same company.

I am also using the job queue invoice posting and noticed that the time it took to post an invoice with intercompany posting was not as expected.  I found the code in codeunit 427 that caused the problem.

[code]
ICDocDim."Transaction No." := OutboxTransaction."Transaction No.";
ICDocDim."IC Partner Code" := OutboxTransaction."IC Partner Code";
ICDocDim."Transaction Source" := OutboxTransaction."Transaction Source";
PostedDocDim.SETFILTER("Table ID",’%1|%2′,DATABASE::"Sales Invoice Header",DATABASE::"Sales Invoice Line");
PostedDocDim.SETRANGE("Document No.",SalesInvHdr."No.");
IF PostedDocDim.FIND(‘-‘) THEN
REPEAT
IF PostedDocDim."Table ID" = DATABASE::"Sales Invoice Header" THEN
ICDocDim."Table ID" := DATABASE::"IC Outbox Sales Header"
ELSE
ICDocDim."Table ID" := DATABASE::"IC Outbox Sales Line";
ICDocDim."Line No." := PostedDocDim."Line No.";
ICDim := DimMgt.ConvertDimtoICDim(PostedDocDim."Dimension Code");
ICDimValue :=
DimMgt.ConvertDimValuetoICDimVal(PostedDocDim."Dimension Code",PostedDocDim."Dimension Value Code");
IF ICDim <> ” THEN BEGIN
ICDocDim."Dimension Code" := ICDim;
IF ICDimValue <> ” THEN BEGIN
ICDocDim."Dimension Value Code" := ICDimValue;
ICDocDim.INSERT;
END;
END;
UNTIL PostedDocDim.NEXT = 0;[/code]

I noticed the line

that was causing the problem. Add a local variable TableID and change the code as follows to improve the performance.

[code]
ICDocDim."Transaction No." := OutboxTransaction."Transaction No.";
ICDocDim."IC Partner Code" := OutboxTransaction."IC Partner Code";
ICDocDim."Transaction Source" := OutboxTransaction."Transaction Source";
FOR TableID := DATABASE::"Sales Invoice Header" TO DATABASE::"Sales Invoice Line" DO BEGIN
PostedDocDim.SETRANGE("Table ID",TableID);
PostedDocDim.SETRANGE("Document No.",SalesInvHdr."No.");
IF PostedDocDim.FIND(‘-‘) THEN
REPEAT
IF PostedDocDim."Table ID" = DATABASE::"Sales Invoice Header" THEN
ICDocDim."Table ID" := DATABASE::"IC Outbox Sales Header"
ELSE
ICDocDim."Table ID" := DATABASE::"IC Outbox Sales Line";
ICDocDim."Line No." := PostedDocDim."Line No.";
ICDim := DimMgt.ConvertDimtoICDim(PostedDocDim."Dimension Code");
ICDimValue :=
DimMgt.ConvertDimValuetoICDimVal(PostedDocDim."Dimension Code",PostedDocDim."Dimension Value Code");
IF ICDim <> ” THEN BEGIN
ICDocDim."Dimension Code" := ICDim;
IF ICDimValue <> ” THEN BEGIN
ICDocDim."Dimension Value Code" := ICDimValue;
ICDocDim.INSERT;
END;
END;
UNTIL PostedDocDim.NEXT = 0;
END;[/code]

One thought on “Change in code for Intercompany Postings

  1. Marco says:

    Hy Gunnar , I’m Marco From italy http://it.linkedin.com/pub/marco-rodriquez/23/a78/30a/
    I find the same issue in a customer where Table Posted doc dim is about 7 million records…
    First I try with table index rebuid, but after 3-4 day the performance slow down again. With you trick I solve the problem!
    Thanks!

Leave a Reply

%d bloggers like this: