Please be informed, I am new to Navision. Please bear with me if I ask any stupid questions or if I wrote wrong code.
I am trying to generate report from “G/L Entry” table for total material cost and sub contract cost.
In G/L Entry table “Document No.” is the key field and “P-Order No.” is the FlowField.
GL_ENTRY_MatC_Revenue and GL_ENTRY_SubC_Revenue are the C/AL Globals “G/L Entry” Record variables
Material cost works fine (Please find below the code). But I am not able to generate sub contract cost. It keeps running, no stopping, without luck. Can anyone HELP me!!!
//***** Material cost calcuation - Begins ****** //
G/L Entry - OnAfterGetRecord()
CLEAR(GL_ENTRY_MatC_Revenue);
CLEAR(mat_Total_cost);
GL_ENTRY_MatC_Revenue.RESET;
GL_ENTRY_MatC_Revenue.SETCURRENTKEY(“Document No.”);
GL_ENTRY_MatC_Revenue.SETRANGE(“Document No.”,“G/L Entry”.“P-Order No.”);
GL_ENTRY_MatC_Revenue.SETFILTER(GL_ENTRY_MatC_Revenue.Amount,’>=0’);
IF GL_ENTRY_MatC_Revenue.FIND(’-’) THEN REPEAT
mat_Total_cost += GL_ENTRY_MatC_Revenue.Amount;
jobno := GL_ENTRY_MatC_Revenue.“Document No.”
UNTIL GL_ENTRY_MatC_Revenue.NEXT=0;
//***** Material cost calcuation - Ends ****** //
//***** Sub Contract cost calcuation - Begins ****** //
CLEAR(GL_ENTRY_SubC_Revenue);
CLEAR(sub_Total_cost);
GL_ENTRY_SubC_Revenue.RESET;
GL_ENTRY_SubC_Revenue.SETCURRENTKEY(“Document No.”);
GL_ENTRY_SubC_Revenue.SETRANGE(“P-Order No.”,jobno); // since “P-Order No.” is the flowfield, I stuck with it.
GL_ENTRY_SubC_Revenue.SETFILTER(GL_ENTRY_SubC_Revenue.Amount,’>=0’);
IF GL_ENTRY_SubC_Revenue.FIND(’-’) THEN REPEAT
sub_Total_cost += GL_ENTRY_SubC_Revenue.Amount;
UNTIL GL_ENTRY_SubC_Revenue.NEXT=0;
//***** Sub Contract cost calcuation - Ends ****** //