Hello all,
I’m building a XMLport that sends some information to our internal sofwtare, such as name of contact, address , post code etc…im getting difficulties on the post code.
The logic is, if the the contact is customer, then it returns by default the customer post code. If that customer has more than shipping address than it returns the customer post code and those shipping post codes.
If the contact is not customer it returns the contact post code.
Node Name | Prefix | Node Type | Source Type | Data Source |
---|---|---|---|---|
XMLPesquisaContacto | Element | Text | ||
ContactoNo | Element | Text | ||
Contacto | Element | Table | (Contact) | |
No | Element | Field | Contact::No. | |
CodPostal | Element | Field | Contact::Post Code | |
CodPais | Element | Text | ||
PaymtTerms | Element | Table | (Payment Terms) | |
CodTerms | Element | Field | Payment Terms::Code | |
Descricao | Element | Field | Payment Terms::Description | |
Ship-toAddress | Element | Table | (Ship-to Address) | |
CodPostalEndEnv | Element | Text |
This is for now the code i have
//{código original
CLEARALL();
CodPais:='';
ltBusRel.RESET;
ltBusRel.SETRANGE("Contact No.",ContactoNo);
ltBusRel.SETRANGE("Business Relation Code",'CLI');
IF ltBusRel.FINDFIRST THEN BEGIN
Contact.RESET;
Contact.SETRANGE("No.",ltBusRel."Contact No.");
IF Contact.FIND('-') THEN
IF Contact."Country/Region Code"<> '' THEN BEGIN
CodPais:=Contact."Country/Region Code";
CodPostalEndEnv:=Contact."Post Code";
pesquisacontacto.SETTABLEVIEW(Contact);
END
ELSE BEGIN
CodPais:='PT';
pesquisacontacto.SETTABLEVIEW(Contact);
END;
END;
//}
This is the code i’m trying to implement
{
CLEARALL();
CodPostalEndEnv:=Contact."Post Code";
ltBusRel.RESET;
ltBusRel.SETRANGE("Contact No.",ContactoNo);
ltBusRel.SETRANGE("Business Relation Code",'CLI');
IF ltBusRel.FINDFIRST THEN
BEGIN
ltcustomer.RESET;
ltcustomer.SETRANGE("No.",ltBusRel."No.");
IF ltcustomer.FIND('-') THEN
BEGIN
"Ship-to Address".RESET;
"Ship-to Address".SETRANGE("Customer No.",ltBusRel."No.");
IF "Ship-to Address".FIND('-') THEN
BEGIN
REPEAT
CodPostalEndEnv:="Ship-to Address"."Post Code";
pesquisacontacto.SETTABLEVIEW("Ship-to Address");
UNTIL "Ship-to Address".NEXT=0;
END
ELSE BEGIN
CodPostalEndEnv:=Contact."Post Code";
pesquisacontacto.SETTABLEVIEW(Contact);
END;
END;
END
ELSE
BEGIN
ltBusRel.RESET;
ltBusRel.SETRANGE("Contact No.",ContactoNo);
IF ltBusRel.FINDFIRST THEN
BEGIN
CodPostalEndEnv:=Contact."Post Code";
pesquisacontacto.SETTABLEVIEW(Contact);
END;
END;
But 'ive got errors if customer has only post code. If customer has shipping addresses then it return the first post code only repeatd n times.
I’ve managed to got working to payment terms.
Payment Terms - Export::OnPreXMLItem()
CLEARALL();
CodPais:='';
ltBusRel.RESET;
ltBusRel.SETRANGE("Contact No.",ContactoNo);
ltBusRel.SETRANGE("Business Relation Code",'CLI');
IF ltBusRel.FINDFIRST THEN BEGIN
Contact.RESET;
Contact.SETRANGE("No.",ltBusRel."Contact No.");
IF Contact.FIND('-') THEN
IF Contact."Country/Region Code"<> '' THEN
CodPais:=Contact."Country/Region Code"
ELSE BEGIN
CodPais:='PT';
pesquisacontacto.SETTABLEVIEW(Contact);
END;
ltcustomer.RESET;
ltcustomer.SETRANGE("No.",ltBusRel."No.");
IF ltcustomer.FIND('-') THEN BEGIN
"Payment Terms".RESET;
"Payment Terms".SETCURRENTKEY(Code);
"Payment Terms".ASCENDING(FALSE);
"Payment Terms".SETFILTER(Code,'%1|%2',ltcustomer."Payment Terms Code",'A');
IF "Payment Terms".FIND('-') THEN BEGIN
pesquisacontacto.SETTABLEVIEW("Payment Terms");
END;
END
ELSE
BEGIN
CodPais:='PT';
"Payment Terms".RESET;
"Payment Terms".SETFILTER(Code,'%1','A');
pesquisacontacto.SETTABLEVIEW("Payment Terms");
END;
END;
Any help would be appreciated .