Delete Purchase Line Quotes using webservice and xml

RikarddoRikarddo Member Posts: 80
I have a codeunit published as webservice which has two functions. One that imports purchase quotes using an xml and another that edits those same purchase quotes using another xml.
This is the structure of my lines:
Node Name NodeType Source Type Data Source
Lines Element Table <Purchase Line> (Purchase Line)
Type Element Text <Type>
CodProd Element Text <CodProd>
Desc Element Text <Desc>
Variant Element Text <Variant>
Qtd Element Text <Qtd>
PrecVend Element Text <PrecVend>
LineNo Element Text <LineNo>
Vasilham Element Text <Vasilhame>

This is my xml code Import:
<Purchase Line> - Import::OnAfterInitRecord()
"<Purchase Line>"."Document Type":="Purchase Header"."Document Type";
"<Purchase Line>"."Document No.":="Purchase Header"."No.";
//line+=10000;
"<Purchase Line>"."Line No.":=line;
"<Purchase Line>".Type:=Type;

CASE Type OF 
  2:
  BEGIN
   "<Purchase Line>".Type:="<Purchase Line>".Type::Item;
  END;
  5:
  BEGIN
   "<Purchase Line>".Type:="<Purchase Line>".Type::"Charge (Item)";
  END;
  0:
  BEGIN
    "<Purchase Line>".Type:="<Purchase Line>".Type::" ";
  END;

END;

"<Purchase Line>"."No.":=CodProd;
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>".Quantity:=Quantidade
ELSE
"<Purchase Line>".Quantity:=0;
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>"."Direct Unit Cost":=Preco;
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>".Description:=Desc
ELSE "<Purchase Line>".Description:='';
"<Purchase Line>"."Variant Code":=Variante;

<Purchase Line> - Import::OnBeforeInsertRecord()
"<Purchase Line>"."Document Type":="Purchase Header"."Document Type";
"<Purchase Line>"."Document No.":="Purchase Header"."No.";
line+=10000;
"<Purchase Line>"."Line No.":=line;
"<Purchase Line>".Type:=Type;
CASE Type OF 
  2:
  BEGIN
   "<Purchase Line>".Type:="<Purchase Line>".Type::Item;
  END;
  5:
  BEGIN
   "<Purchase Line>".Type:="<Purchase Line>".Type::"Charge (Item)";
  END;
  0:
  BEGIN
    "<Purchase Line>".Type:="<Purchase Line>".Type::" ";
  END;
END;

"<Purchase Line>"."No.":=CodProd;
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>".VALIDATE("No.");
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>".Quantity:=Quantidade
ELSE
"<Purchase Line>".Quantity:=0;
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>"."Direct Unit Cost":=Preco
ELSE
"<Purchase Line>"."Direct Unit Cost":=0;
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>"."Unit Cost":=Preco
ELSE
"<Purchase Line>"."Unit Cost":=0;
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>"."Unit Cost (LCY)":=Preco
ELSE
"<Purchase Line>"."Unit Cost (LCY)":=0;

IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>".Description:=Desc
ELSE "<Purchase Line>".Description:='';
"<Purchase Line>"."Variant Code":=Variante;


//"<Purchase Line>".VALIDATE(Amount);
IF "<Purchase Line>".Type<>"<Purchase Line>".Type::" "THEN
"<Purchase Line>".UpdateAmounts;

<Purchase Line> - Import::OnAfterInsertRecord()
IF Vas = TRUE THEN BEGIN
  line+=10000;
"<Purchase Line>".vsCreateContainerLine;
 END;

<Purchase Line> - Import::OnBeforeModifyRecord()

<Purchase Line> - Import::OnAfterModifyRecord()

<Purchase Line> - Export::OnPreXMLItem()

<Purchase Line> - Export::OnAfterGetRecord()
//line+=10000;
IF Vas = TRUE THEN BEGIN
  line+=10000;
"<Purchase Line>".vsCreateContainerLine;
 END;

It works fine for insertion. My goal here is to use the other xml to edit the quotes already inserted. But I don't know how?
I was trying to make a "fake import", first delete the lines and then insert only the lines that were remaining?

Can someone give me some tips?

Answers

Sign In or Register to comment.