Solved

SaveAsFormattedText()  NOT WORKING  POWERBUILDER 10

Posted on 2008-10-23
1
830 Views
Last Modified: 2013-12-26
First I am retrieving rows in a script and then I am using  dw_1.SaveAsFormattedText(ls_client_path,EncodingANSI!,",","'")  to write a text file.
This text file is read by a batch prog every hour. The file has to be comma separated. the problem is I have to use this function b/c the rows may contain non alphabet charac like &,*,% etc due to bad data input The batch prog rejects the whole file even if one rec or line  contains these special charac. so I have to wrap each value in Quotes. The function works OK except for the fact that it adds comma at the end of each line for some reason and that's why the file gets rejected. I am attaching the file.
One more problem is even if we remove the comma at the end of each line some fields like name contain comma inside due to bad data input again the file gets rejected. Please this is urgent

string ls_Emp_Input
lds_client.dataobject = 'ds_dnd_client'
lds_client.SetTransObject(SQLCA)
ll_rowcount = lds_client.Retrieve()
 
lb_exists = FileExists(ls_emp_path)
IF lb_exists THEN
	FileDelete(ls_emp_path)
END IF
//Hrehman 10/22/2008 
if lds_client.SaveAsFormattedText(ls_emp_path,EncodingANSI!,",","'")= -1 then
	MessageBox("ARCS Error","Error occurred saving the Employee file.")
end if
 
ll_FLength = FileLength64(ls_emp_path)
 
li_FileNum = FileOpen(ls_emp_path,textmode!)
 
ll_fileread =  FileReadEx(li_FileNum, ls_Emp_Input)
ls_Emp_Input = "F1,F2,F3,F4,F5~r~n" + ls_Emp_Input
 
FileClose(li_FileNum)
 
li_FileNum = FileOpen(ls_emp_path, textmode!, Write!, LockWrite!, replace!)
ll_filewrite = FileWriteEx(li_FileNum, ls_Emp_Input)
FileClose(li_FileNum)

Open in new window

clients.txt
0
Comment
Question by:HARLIBRA
1 Comment
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 500 total points
ID: 22799544
are you using the same code whatever is pasted here? Your output file has all values enclosed in quote and are comma separated. while your arguments are not matching with it..

Also you can not avoid comma (separater character) at the end of line while using this function. However you can remove that using file read and file write function.

Read file in linemode and write the line to new filed except last character.

OR
modify batch job which should not reject the file if last character in line is comma.

And if you don't have control over the data input you can't include any character as separater character and some day it will be rejected. OR Your batch job should be smart to understand that if there is comma between quotes then it's a valid data.

Regards,
Sandeep
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question