Writing line before and after the dataport exports lines
Cem_Karaer
Member Posts: 281
Hello all,
Say that you want to export purchase lines to a text file but want to write
purchase
before all of the lines and
end_purchase
after all of the lines. Then you can do something like the following code:
There are some codes which are customer specific. The point is to use
in the OnPreDataItem of the integer dataitems.
Say that you want to export purchase lines to a text file but want to write
purchase
before all of the lines and
end_purchase
after all of the lines. Then you can do something like the following code:
OBJECT Dataport 50000 Export Purch. to PORTAL
{
OBJECT-PROPERTIES
{
Date=25.11.10;
Time=16:52:20;
Modified=Yes;
Version List=Parge-PORTAL;
}
PROPERTIES
{
CaptionML=[ENU=Export Purch. to PORTAL;
TRK=Satnalma PORTAL DŸar Aktar];
Import=No;
FileName=C:\text.txt;
FieldStartDelimiter=<None>;
FieldEndDelimiter=<None>;
FieldSeparator=[;];
OnInitDataport=BEGIN
PurchSetup.GET;
PurchSetup.TESTFIELD("Purch. Order Outgoing Path");
END;
OnPreDataport=BEGIN
VendorFilter := "Purchase Line".GETFILTER("Buy-from Vendor No.");
CurrDataport.FILENAME := PurchSetup."Purch. Order Outgoing Path" +
VendorFilter + '-' + FORMAT(CURRENTDATETIME,0,'<Year4><Month,2><Day,2><Hour,2><Minute,2>') + '.csv';
END;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table2000000026;
DataItemVarName=Up;
DataItemTableView=SORTING(Number)
WHERE(Number=CONST(1));
}
FIELDS
{
{ ; ;'receipt' }
}
}
{ PROPERTIES
{
DataItemTable=Table39;
DataItemTableView=WHERE(Document Type=CONST(Order),
Type=CONST(Item),
Outstanding Quantity=FILTER(>0));
ReqFilterFields=Buy-from Vendor No.;
OnPreDataItem=BEGIN
CurrFile.OPEN(CurrFile.NAME);
CurrFile.SEEK(CurrFile.LEN - 2);
END;
OnBeforeExportRecord=BEGIN
PurchHeader.GET("Document Type","Document No.");
Item.INIT;
IF Item.GET("No.") THEN;
txtDate := FORMAT(PurchHeader."Posting Date",0,'<Day,2>/<Month,2>/<Year4>');
END;
}
FIELDS
{
{ ; ;"Buy-from Vendor No." }
{ ; ;"No." }
{ ; ;Quantity }
{ ; ;"Unit of Measure" }
{ ; ;txtDate }
{ ; ;'' }
{ ; ;txtDate }
{ ; ;CURRENTDATETIME }
{ ; ;"Line No." }
{ ; ;"Document No." }
}
}
{ PROPERTIES
{
DataItemTable=Table2000000026;
DataItemVarName=Down;
DataItemTableView=SORTING(Number)
WHERE(Number=CONST(1));
OnPreDataItem=BEGIN
CurrFile.OPEN(CurrFile.NAME);
CurrFile.SEEK(CurrFile.LEN - 2);
END;
}
FIELDS
{
{ ; ;'end_receipt' }
}
}
}
REQUESTFORM
{
PROPERTIES
{
Width=9020;
Height=3410;
}
CONTROLS
{
}
}
CODE
{
VAR
PurchHeader@1000000000 : Record 38;
Item@1000000001 : Record 27;
PurchSetup@1000000002 : Record 312;
VendorFilter@1000000003 : Code[20];
txtDate@1000000004 : Text[30];
BEGIN
END.
}
}
There are some codes which are customer specific. The point is to use
CurrFile.OPEN(CurrFile.NAME); CurrFile.SEEK(CurrFile.LEN - 2);
in the OnPreDataItem of the integer dataitems.
Cem Karaer @ Pargesoft
Dynamics NAV Developer since 2005
Dynamics NAV Developer since 2005
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions