I try to build a dataport to import salesorders (sales header with one sales line).
The import and validate on Sell-to Customer No. after import record of the sales header is no problem.
But the import and validation of the sales line gives me trouble.
I have to make two validations after import, so that the calculation of the line is done right:
“Sales Line”.VALIDATE(“No.”);
“Sales Line”.VALIDATE(Quantity);
The fields I import are:
“Document Type”
“Document No.”
“Line No.”
Type
“No.”
Quantity
“Unit of Measure”
“Unit Price”
The two validations work separatly.
But when I first validate on “No.”, the imported data “Unit of Measure” and “Unit Price” are deleted, so the system cannot calculate the line.
When I first validate on Quantity, the second validation won’t be done, so the system still cannot calculate the line.
You need to create some variables and put the values you wish to add that disappear on validation into these variables instead of the fields. View → C/AL Globals
After the validation, put these values in the fields e.g.
“Unit of Measure” := UnitofMeasureCode;
but it might be wise to validate the fields you mention instead:
“Sales Line”.VALIDATE(“Unit of Measure”,UnitofMeasureCode);
It is good practice to empty the variables afterwards.