Review C/AL code in Dataport

jadetunjijadetunji Member Posts: 26
Hi All,

Attached dataport parameters requires some fine tuning and I'll be grateful for any assistance - pls see attached definition and output tabs

It is attempting to extract g/l entry data for AR inv/cr memo. However the following anomalies have been identified on the output.

- the Amount (LCY) is returning the wrong data
- the Source Type field is returning 'Customer' values for the last 3 rows instead of just the last one

Thanks for your assistance

C/AL Editor
AB April 2012: Created for NAV3.7 sales data export

G/L Entry - OnPreDataItem()
GLSetup.GET;

G/L Entry - OnBeforeExportRecord()
CLEAR(GLDimValue);
LedgEntryDim.SETRANGE("Table ID",DATABASE::"G/L Entry");
LedgEntryDim.SETRANGE("Entry No.","Entry No.");
IF LedgEntryDim.FIND('-') THEN REPEAT
CASE LedgEntryDim."Dimension Code" OF
GLSetup."Global Dimension 1 Code" :
GLDimValue[1] := LedgEntryDim."Dimension Value Code";
GLSetup."Global Dimension 2 Code" :
GLDimValue[2] := LedgEntryDim."Dimension Value Code";
GLSetup."Shortcut Dimension 3 Code" :
GLDimValue[3] := LedgEntryDim."Dimension Value Code";
GLSetup."Shortcut Dimension 4 Code" :
GLDimValue[4] := LedgEntryDim."Dimension Value Code";
GLSetup."Shortcut Dimension 5 Code" :
GLDimValue[5] := LedgEntryDim."Dimension Value Code";
GLSetup."Shortcut Dimension 6 Code" :
GLDimValue[6] := LedgEntryDim."Dimension Value Code";
GLSetup."Shortcut Dimension 7 Code" :
GLDimValue[7] := LedgEntryDim."Dimension Value Code";
GLSetup."Shortcut Dimension 8 Code" :
GLDimValue[8] := LedgEntryDim."Dimension Value Code";

END;
UNTIL LedgEntryDim.NEXT = 0;

DetailCustLedgerEntry.SETRANGE("Posting Date", "Posting Date");
DetailCustLedgerEntry.SETRANGE("Document No.", "Document No.");
IF NOT DetailCustLedgerEntry.FIND('-') THEN
CLEAR(DetailCustLedgerEntry);

G/L Entry - OnAfterExportRecord()

G/L Entry - OnBeforeImportRecord()

G/L Entry - OnAfterImportRecord()

G/L Entry - OnPostDataItem()


+++++++++++++++++++++++++++++
Dataport Fields


Enabled SourceExpr StartPos Width
Yes Posting Date 0 0
Yes Document No. 0 0
Yes External Document No. 0 0
Yes Description 0 0
Yes Source Type 0 0
Yes G/L Account No. 0 0
Yes Source No. 0 0
Yes DetailCustLedgerEntry."Currency Code" 0 0
Yes Amount 0 0
Yes DetailCustLedgerEntry."Amount (LCY)" 0 0
Yes GLDimValue[8] 0 0
Yes GLDimValue[1] 0 0
Yes GLDimValue[2] 0 0
Yes GLDimValue[7] 0 0
Yes GLDimValue[3] 0 0
Yes GLDimValue[4] 0 0


Output

FIELD FIELD FIELD FIELD FIELD FIELD FIELD FIELD FIELD Field DIMENSION DIMENSION DIMENSION DIMENSION DIMENSION DIMENSION
Posting Date Document No. External Document No. Description Source Type G/L Account No. Source No. Currency Code Amount Amount (LCY) BRANCH DEPARTMENT SEGMENT RPODUCT PROJECT CUSTOMER
18/06/2012 CN-S1018 GC10262012 Initial invoice for contract GC10262012 Customer 2401010202 CN-C1013 -489,461.54 572,670 CN-SALES-PLANT PLANTD CN-C1013
18/06/2012 CN-S1018 GC10262012 Initial invoice for contract GC10262012 Customer 2221010202 CN-C1013 -83,208.46 572,670 CN-SALES-PLANT PLANTD CN-C1013
18/06/2012 CN-S1018 GC10262012 Initial invoice for contract GC10262012 Customer 1122020000 CN-C1013 572,670 572,670 CN-SALES-PLANT CN-C1013

Comments

  • ufukufuk Member Posts: 514
    Why do you use Detailed Cust. Ledger Entry? I recommend using Cust. Ledger Entry instead of DCLE. DCLE may have many lines and in your example it will always find the first line. If you do not filter entry type this can cause problems.

    For the source type: I didn't understand exactly. Won't you expect NAV to have customer as source type in all lines of the corresponding document? If not, you have to distinguish cust line using opposite amount or highest amount or last line etc...
    Ufuk Asci
    Pargesoft
Sign In or Register to comment.