Solved

SaveAsFormattedText()  NOT WORKING  POWERBUILDER 10

Posted on 2008-10-23
1
818 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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now