dataport - validation on 2 fields in one sales line

Hi!

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.

How can I solve this?
Anybody?

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.

Like this?

But still no good result.

Sales Line - OnAfterImportRecord()

“Sales Line”.VALIDATE(“No.”);

“Unit of Measure Code” := Eenheidscode;
“Unit Price” := Eenheidsprijs;

“Sales Line”.VALIDATE(“Unit of Measure Code”,Eenheidscode);
“Sales Line”.VALIDATE(“Unit Price”,Eenheidsprijs);

My variables:

Name DataType Subtype Length
Eenheidscode Code 10
Eenheidsprijs Decimal

In my opinion you should pass the values to your variables before

“Sales Line”.VALIDATE(“No.”);

Not working either, I can’t seem to put the values of the variables into place.

Somebody?

Sales Line - OnAfterImportRecord()

“Unit of Measure Code” := Eenheidscode;
“Unit Price” := Eenheidsprijs;

“Sales Line”.VALIDATE(“No.”);
“Sales Line”.VALIDATE(“Unit of Measure Code”,Eenheidscode);
“Sales Line”.VALIDATE(“Unit Price”,Eenheidsprijs);

In this way you’re evaluating “unit of Measure code” with a null variable.

When process arrives to:

Eenheidscode is null.

You should correct your first peace of code, in my opinion.

Hi

Please use “Eenheidscode” and “Eenheidsprijs” in the dataport fields rather than the field names.

Then…

“Sales Line”.VALIDATE(“No.”);

“Sales Line”.VALIDATE(“Unit of Measure Code”,Eenheidscode);

“Sales Line”.VALIDATE(“Unit Price”,Eenheidsprijs);

“Unit of Measure Code” := Eenheidscode;
“Unit Price” := Eenheidsprijs;

or better… validate these two as well instead…

Cheers

Sorry…

answered two quickly…

Please use “Eenheidscode” and “Eenheidsprijs” in the dataport fields rather than the field names.

Then…

“Sales Line”.VALIDATE(“No.”);

“Sales Line”.VALIDATE(“Unit of Measure Code”,Eenheidscode);

“Sales Line”.VALIDATE(“Unit Price”,Eenheidsprijs);

Hope this helps.

Cheers

I agree, in this way should work! [Y]

Great, tnx!!![Y]

you’re welcome!