Hi,
There is a requirement to create a dataport to import the item tracking lines at the sales order lines → Item Tracking Lines screen.
In an attempt to import the item tracking numbers (at the SO screen) using a dataport, I did the following:
At the ‘Item Tracking Lines’ (Form 6510), I created a menu item ‘Import Tracking Lines’ under the ‘function’ menu button with the following code:
TempItemTrackingLine := Rec; //TempItemTrackingLine is a global var on this form
WITH TempItemTrackingLine DO BEGIN
IF ZeroLineExists THEN
DELETE;
TESTFIELD(“Quantity Handled (Base)”,0);
TESTFIELD(“Quantity Invoiced (Base)”,0);
END;
CLEAR(ImportTrackingSpec); //global var for the tracking spec import dataport
ImportTrackingSpec.SetFields(LastEntryNo,TempItemTrackingLine); //passing the last entry no
and the temp table to the dataport
ImportTrackingSpec.RUNMODAL;
Rec := TempItemTrackingLine;
CalculateSums;
What I understand is that the form 6510 is based on the temporary table
‘TempItemTrackingLine’. So I am trying to have the dataport import the item tracking lines on to this temp table.
The dataport ‘ImportTrackingSpec’ is based on the Integer table. Here, there is a global temporary var called ‘TempTrackingSpecification’ which refers to the tracking specification table.
The SetFields function in this dataport is as follows:
SetFields(LFirstEntryNo : Integer;VAR LTempTrackingSpecification : TEMPORARY Record “Tracking Specification”) : In
FirstEntryNo := LFirstEntryNo;
LTempTrackingSpecification.RESET;
IF LTempTrackingSpecification.FIND(’-’) THEN
REPEAT
TempTrackingSpecification := LTempTrackingSpecification;
TempTrackingSpecification.INSERT(FALSE);
UNTIL LTempTrackingSpecification.NEXT = 0;
At the OnAfterImportRecord() of the dataport:
TempTrackingSpecification.TESTFIELD(“Source ID”);
TempTrackingSpecification.TESTFIELD(“Item No.”);
TempTrackingSpecification.TESTFIELD(“Quantity (Base)”);
SalesLine.RESET;
SalesLine.SETRANGE(“Document Type”,SalesLine.“Document Type”::Order);
SalesLine.SETRANGE(“Document No.”,TempTrackingSpecification.“Source ID”);
SalesLine.SETRANGE(Type,SalesLine.Type::Item);
SalesLine.SETRANGE(“No.”,TempTrackingSpecification.“Item No.”);
IF SalesLine.FIND(’-’) THEN BEGIN
TempTrackingSpecification.“Source Type” := DATABASE::“Sales Line”;
TempTrackingSpecification.“Source Subtype” := SalesLine.“Document Type”;
TempTrackingSpecification.“Source Ref. No.” := SalesLine.“Line No.”;
TempTrackingSpecification.“Entry No.” := FirstEntryNo + 1;
TempTrackingSpecification.INSERT;
END;
ItemTrackingLinesForm.ReturnTempTrakingLine(TempTrackingSpecification);
‘ItemTrackingLinesForm’ is a var referring to form 6510(‘Item Tracking Lines’). The ‘ReturnTempTrakingLine’ function on this form has the following code:
ReturnTempTrakingLine(VAR TempTrackingSpec : TEMPORARY Record “Tracking Specification”)
TempItemTrackingLine.RESET;
TempItemTrackingLine.DELETEALL;
TempTrackingSpec.RESET;
IF TempTrackingSpec.FIND(’-’) THEN
REPEAT
TempItemTrackingLine := TempTrackingSpec;
TempItemTrackingLine.INSERT;
UNTIL TempTrackingSpec.NEXT = 0;
TempItemTrackingLine.RESET;
All this works fine. But after the import, the imported records cannot be seen on the ‘item tracking lines’ form. I found that the imported records are not copied onto the temporary table ‘TempItemTrackingLine’.
Any clue as to why this is happening?
Regards,
Anse