IF ShowError THEN BEGIN
PurchLine2.RESET;
PurchLine2.SETRANGE("Document Type","Document Type"::Order);
PurchLine2.SETRANGE("Document No.","No.");
IF NOT PurchLine2.ISEMPTY THEN BEGIN
IF "Ship-to Name" <> SalesHeader."Ship-to Name" THEN
ERROR(Text051,FIELDCAPTION("Ship-to Name"),"No.",SalesHeader."No.");
IF "Ship-to Name 2" <> SalesHeader."Ship-to Name 2" THEN
ERROR(Text051,FIELDCAPTION("Ship-to Name 2"),"No.",SalesHeader."No.");
IF ("Ship-to Address" <> SalesHeader."Ship-to Address") THEN
ERROR(Text051,FIELDCAPTION("Ship-to Address"),"No.",SalesHeader."No.");
IF ("Ship-to Address 2" <> SalesHeader."Ship-to Address 2") THEN
ERROR(Text051,FIELDCAPTION("Ship-to Address 2"),"No.",SalesHeader."No.");
IF ("Ship-to Post Code" <> SalesHeader."Ship-to Post Code") THEN
ERROR(Text051,FIELDCAPTION("Ship-to Post Code"),"No.",SalesHeader."No.");
IF ("Ship-to City" <> SalesHeader."Ship-to City") THEN
ERROR(Text051,FIELDCAPTION("Ship-to City"),"No.",SalesHeader."No.");
IF ("Ship-to Contact" <> SalesHeader."Ship-to Contact") THEN
ERROR(Text051,FIELDCAPTION("Ship-to Contact"),"No.",SalesHeader."No.");
END ELSE BEGIN
// no purchase line exists
"Ship-to Name" := SalesHeader."Ship-to Name";
"Ship-to Name 2" := SalesHeader."Ship-to Name 2";
"Ship-to Address" := SalesHeader."Ship-to Address";
"Ship-to Address 2" := SalesHeader."Ship-to Address 2";
"Ship-to Post Code" := SalesHeader."Ship-to Post Code";
"Ship-to City" := SalesHeader."Ship-to City";
"Ship-to Contact" := SalesHeader."Ship-to Contact";
END;
END ELSE BEGIN
NameAddressDetails :=
SalesHeader."Ship-to Name" + SalesHeader."Ship-to Name 2" +
SalesHeader."Ship-to Address" + SalesHeader."Ship-to Address 2" +
SalesHeader."Ship-to Post Code" + SalesHeader."Ship-to City" +
SalesHeader."Ship-to Contact";
IF NameAddressDetails2 = '' THEN
NameAddressDetails2 := NameAddressDetails;
EXIT(NameAddressDetails2 = NameAddressDetails);
END;