Hi,
Writing Text File from AX (D365O)
Create new folder and add new runnable class in project and add below code.
class RunnableClass2
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
TextIo file;
FileName filename = @"C:\Users\Administrator\Desktop\AX Interface\Interface Sample File\SalesOrders.txt";
SalesTable salesTable;
SalesLine saleLine;
container conSalesTable,conSalesLine;
FileIoPermission permission;
#File
;
try
{
permission = new FileIoPermission(filename, #io_write);
permission.assert();
file = new TextIo(filename, #io_write);
if (!file)
throw Exception::Error;
file.outRecordDelimiter(#delimiterCRLF);
file.outFieldDelimiter("*");
while select salesTable where salesTable.SalesStatus==SalesStatus::Invoiced
{
conSalesTable = connull();
file.inFieldDelimiter("\r\n");
file.inFieldDelimiter('\r\n');
conSalesTable = conins(conSalesTable, 1, salesTable.SalesId );
conSalesTable = conins(conSalesTable, 2, salesTable.SalesType );
conSalesTable = conins(conSalesTable, 3, salesTable.CustAccount);
conSalesTable = conins(conSalesTable, 4, salesTable.SalesStatus );
conSalesTable = conins(conSalesTable, 5, salesTable.amountInvoiced());
conSalesTable = conins(conSalesTable, 6, salesTable.InventSiteId);
conSalesTable = conins(conSalesTable, 7, salesTable.InventLocationId );
file.inFieldDelimiter('\r\n');
file.inFieldDelimiter('\r\n');
file.writeExp(conSalesTable);
while select saleLine where saleLine.SalesId ==salesTable.SalesId
{
conSalesLine = connull();
file.inFieldDelimiter('\r\n');
file.inFieldDelimiter('\r\n');
conSalesLine = conins(conSalesLine, 1, saleLine.ItemId );
conSalesLine = conins(conSalesLine, 2, saleLine.itemName());
conSalesLine = conins(conSalesLine, 3, saleLine.SalesQty );
conSalesLine = conins(conSalesLine, 4, saleLine.SalesUnit );
conSalesLine = conins(conSalesLine, 5, saleLine.SalesPrice );
conSalesLine = conins(conSalesLine, 6, saleLine.SalesPrice );
file.inFieldDelimiter("\r\n");
file.inFieldDelimiter('\r\n');
file.writeExp(conSalesLine);
}
}
}
catch(Exception::Error)
{
error("You do not have access to write the file to the selected folder or Folder does not exists");
}
CodeAccessPermission::revertAssert();
}
Writing Text File from AX (D365O)
Create new folder and add new runnable class in project and add below code.
class RunnableClass2
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
TextIo file;
FileName filename = @"C:\Users\Administrator\Desktop\AX Interface\Interface Sample File\SalesOrders.txt";
SalesTable salesTable;
SalesLine saleLine;
container conSalesTable,conSalesLine;
FileIoPermission permission;
#File
;
try
{
permission = new FileIoPermission(filename, #io_write);
permission.assert();
file = new TextIo(filename, #io_write);
if (!file)
throw Exception::Error;
file.outRecordDelimiter(#delimiterCRLF);
file.outFieldDelimiter("*");
while select salesTable where salesTable.SalesStatus==SalesStatus::Invoiced
{
conSalesTable = connull();
file.inFieldDelimiter("\r\n");
file.inFieldDelimiter('\r\n');
conSalesTable = conins(conSalesTable, 1, salesTable.SalesId );
conSalesTable = conins(conSalesTable, 2, salesTable.SalesType );
conSalesTable = conins(conSalesTable, 3, salesTable.CustAccount);
conSalesTable = conins(conSalesTable, 4, salesTable.SalesStatus );
conSalesTable = conins(conSalesTable, 5, salesTable.amountInvoiced());
conSalesTable = conins(conSalesTable, 6, salesTable.InventSiteId);
conSalesTable = conins(conSalesTable, 7, salesTable.InventLocationId );
file.inFieldDelimiter('\r\n');
file.inFieldDelimiter('\r\n');
file.writeExp(conSalesTable);
while select saleLine where saleLine.SalesId ==salesTable.SalesId
{
conSalesLine = connull();
file.inFieldDelimiter('\r\n');
file.inFieldDelimiter('\r\n');
conSalesLine = conins(conSalesLine, 1, saleLine.ItemId );
conSalesLine = conins(conSalesLine, 2, saleLine.itemName());
conSalesLine = conins(conSalesLine, 3, saleLine.SalesQty );
conSalesLine = conins(conSalesLine, 4, saleLine.SalesUnit );
conSalesLine = conins(conSalesLine, 5, saleLine.SalesPrice );
conSalesLine = conins(conSalesLine, 6, saleLine.SalesPrice );
file.inFieldDelimiter("\r\n");
file.inFieldDelimiter('\r\n');
file.writeExp(conSalesLine);
}
}
}
catch(Exception::Error)
{
error("You do not have access to write the file to the selected folder or Folder does not exists");
}
CodeAccessPermission::revertAssert();
}
Mclamimpunc_e Charles Naranjo https://wakelet.com/wake/7-VlgiaCfjJ0yVIS_eO3R
ReplyDeleteruncpunccuhan
maremenc-sa Melinda Khan WonderShare Recoverit
ReplyDeleteSpeedify
CorelDRAW
pecttunavi