Solved

SaveAsFormattedText()  NOT WORKING  POWERBUILDER 10

Posted on 2008-10-23
1
843 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

756 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