Regarding - Clarification on Xml Port

Hi Everyone

Hope all are fine…!

I just want to use xml port to create a new purchase order and in that the header table is working fine but there line table is not getting updated.

I here by write the following code , can anyone please let me know if there is any changes to be followed.

xmlport 50120 importpo
{
Caption = ‘importpo’;
Direction = Import;
Format = VariableText;
Permissions = TableData “Purchase Header” = rimd;
TextEncoding = UTF8;
UseRequestPage = false;
TransactionType = UpdateNoLocks;
FileName = ‘doc.csv’;

schema
{
textelement(Root)
{
tableelement(PurchaseHeader; “Purchase Header”)
{
SourceTableView = where(“Document Type” = const(Order));
// MinOccurs = Zero;
// MaxOccurs = Once;

fieldelement(DocumentType; PurchaseHeader.“Document Type”)
{
}
fieldelement(No; PurchaseHeader.“No.”)
{

}
fieldelement(BuyfromVendorNo; PurchaseHeader.“Buy-from Vendor No.”)
{
}
tableelement(PurchaseLine; “Purchase Line”)
{
AutoSave = true;

LinkTable = “PurchaseHeader”;
LinkFields = “Document Type” = field(“Document Type”), “Buy-from Vendor No.” = field(“Buy-from Vendor No.”), “Document No.” = field(“No.”);
SourceTableView = where(“Document Type” = const(Order), Type = const(item));
LinkTableForceInsert = true;
MinOccurs = Zero;
MaxOccurs = Once;

fieldelement(No; PurchaseLine.“No.”)
{
trigger OnAfterAssignField()
var
myInt: Integer;
begin
lineNo += 10000;
PurchaseLine.Validate(“Line No.”, lineno);
end;
}
fieldelement(quantity; PurchaseLine.Quantity)
{
}
trigger OnPreXmlItem()
var
myInt: Integer;
begin
PurchaseLine.SetRange(“Document Type”, PurchaseHeader.“Document Type”);
PurchaseLine.SetRange(“Document No.”, PurchaseHeader.“No.”);
end;

}

}
}
}
requestpage
{
layout
{
area(content)
{
group(GroupName)
{
}
}
}
actions
{
area(processing)
{
}
}
}
var
LineNo: Integer;

}

Thanks & Regards ,

Karthikeyani C

1 Like

Based on the provided code, it seems like you have defined the PurchaseLine table element and its fields in the XMLPort schema, but you have not specified any data to be imported into those fields.

You need to ensure that your input file contains data for the PurchaseLine table and its fields. You can also add debug statements or break points in your code to check if data is being properly read from the input file.

Additionally, you may want to consider adding error handling code to catch any exceptions or errors that may occur during the import process.

Overall, the code you have provided looks like it should work, but without more context or information about any errors you are encountering, it’s difficult to provide a more specific solution.