Options

Importing orders from XML (exercise)

Hi all, I'm doing a practical exercise for my enterprise where i'm making my stages for my software programming studies and I have to import from an XML sales orders with their headers and lines. The XML only passes me the Customer No, the Order Date for the header and the sales line type, the item no and the quantity for lines. I have to pass them to a table i've created of "Auxiliar Orders". I make this on the prexmlport trigger:

trigger OnPreXmlPort()
begin
CabeceraPedido.Init();
CabeceraPedido."Document Type" := CabeceraPedido."Document Type"::Order;
CabeceraPedido.Insert(true);

Lineas.Init();
Lineas."Document No." := CabeceraPedido."Order No.";
Lineas."Document Type" := Lineas."Document Type"::Order;
Lineas."Line No." += 10000;
Lineas.Insert();
end;

Because some fields that are in the PK are not in the xml.

And I have this error.

"The record in table Aux. Sales Line already exists. Identification fields and values: Document Type='Order',Document No.='NS00032',Line No.='10000'"

I use a NS for the Order No and Document No fields. How can I solve this?

Answers

Sign In or Register to comment.