Solved

SaveAsFormattedText()  NOT WORKING  POWERBUILDER 10

Posted on 2008-10-23
1
848 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse find/step into stored procedure 3 213
Eclipse and java version isssue 2 54
Delphi : could not find program, '...exe' 2 244
PHPStorm debugging issues 1 96
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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

752 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