How can I erase CRLF characters and export to .TXT

ILME
Member Posts: 23
Hello, I've been trying to export some fields through a dataport to a .TXT file.
On the OnBeforeExportRecord trigger of the Dataport I want to clean
my text fields from CR & LF characters that are attached to the end of the Code fields.
So I have tried all these:
c --> char = 13
1) "Dimension Value".Code:= DELCHR("Dimension Value".Code, '=', FORMAT(c));
2) Adding two Backspace [char=8] characters to the end of the "Dimension Value".Code
3) "Dimension Value".Code:=COPYSTR("Dimension Value".Code, 1, STRLEN("Dimension Value".Code)-2);
When I run the Dataport to export data in a .TXT file, the green processing bar gets stuck permanently and does not finally export the data.
Has anybody managed to export data cleaned from CRLF characters?
Any help would be highly appreciated.
On the OnBeforeExportRecord trigger of the Dataport I want to clean
my text fields from CR & LF characters that are attached to the end of the Code fields.
So I have tried all these:
c --> char = 13
1) "Dimension Value".Code:= DELCHR("Dimension Value".Code, '=', FORMAT(c));
2) Adding two Backspace [char=8] characters to the end of the "Dimension Value".Code
3) "Dimension Value".Code:=COPYSTR("Dimension Value".Code, 1, STRLEN("Dimension Value".Code)-2);
When I run the Dataport to export data in a .TXT file, the green processing bar gets stuck permanently and does not finally export the data.
Has anybody managed to export data cleaned from CRLF characters?
Any help would be highly appreciated.
* IF NOT done THEN REPEAT UNTIL done *
0
Answers
-
Try the OnAfterFormatField trigger (hit F9 on a dataport field in the Field designer)0
-
Following code should work:
cr := 13 ; lf := 10 ; FieldToClean := DELCHR(FieldToClean,'=',FORMAT(cr)) ; FieldToClean:= DELCHR(FieldToClean,'=',FORMAT(lf)) ;
IF not, there may be another problems and you may require debugging.Ufuk Asci
Pargesoft0 -
@BernardJ:
unfortunately, putting the altering DELCHR code in the OnAfterFormatField doesn't do the job, because it exports the data unchanged (with CRLF characters in it)
@ufuk:
Yes, that's what I was doing but it couldn't export the file.
************
Finally I solved it!
For a mysterious reason that I cannot understand,
I've put a VARIABLE instead of the field and IT WORKED!
So, I put:
variable_code:= DELCHR("Dimension Value".Code, '=', FORMAT(c));
and exported THE VARIABLE instead of the "Dimension Value".Code FIELD
If anyone has any idea why it works properly with a variable and not with the field
I'd be glad to know!
Thanx* IF NOT done THEN REPEAT UNTIL done *0 -
It also works with fields not only variables. If you want to modify a value in primary key fields you should use Rename function. This may be the reason.Ufuk Asci
Pargesoft0
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
- 320 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