You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

Updating a file using a Peoplecode in Application Engine

14 replies [Last post]
ashok_star2004's picture
User offline. Last seen 33 weeks 6 days ago. Offline
Joined: 02/13/2009
Posts: 45

Hi All,
Is there anyway to update a file text using an appengine.In the attachment text file,i need to erase the lines starting with "N1" and "PER" and update the number count in the line starting with "SE"(the number between the stars) and update the file.Im getting error while using Get Position and SetPosition. Any Help Appreciated..

Thanks,
Ashok K.

AttachmentSize
test1.txt896 bytes
rahulkhandelw's picture
User offline. Last seen 9 years 28 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: Updating a file using a Peoplecode in Application Engine

To my knowledge , set position works only when file is opened in update mode. Are you opening the file in update mode.

Lepa's picture
User offline. Last seen 2 years 6 weeks ago. Offline
Joined: 06/23/2008
Posts: 591
Re: Updating a file using a Peoplecode in Application Engine

Quote:
Im getting error while using Get Position and SetPosition.

Also, what is the error you are getting. rahulkhandelw is right, the file needs to be opened in a update mode.

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

ashok_star2004's picture
User offline. Last seen 33 weeks 6 days ago. Offline
Joined: 02/13/2009
Posts: 45
Re: Updating a file using a Peoplecode in Application Engine

Hi Lepa and Rahul,
Thank you.. Yes now i opened it in Update Mode and now the file text is not updating properly and im getting only the latest text line read from the source file.Lastly, Thank you for your quick response..

Thanks,
Ashok K.

rahulkhandelw's picture
User offline. Last seen 9 years 28 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: Updating a file using a Peoplecode in Application Engine

Hi Ashok,

I will try to write the program for u . It might take some time.

ashok_star2004's picture
User offline. Last seen 33 weeks 6 days ago. Offline
Joined: 02/13/2009
Posts: 45
Re: Updating a file using a Peoplecode in Application Engine

Hi Rahul,
Thank you so much..Meanwhile i will fight my best to make it.

rahulkhandelw's picture
User offline. Last seen 9 years 28 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: Updating a file using a Peoplecode in Application Engine

Hey Ashok,
One quick question, Won't it would be a good idea to create a new file??

ashok_star2004's picture
User offline. Last seen 33 weeks 6 days ago. Offline
Joined: 02/13/2009
Posts: 45
Re: Updating a file using a Peoplecode in Application Engine

Hi Rahul,
Yes..You are right..Im making a copy of the source file.Sorry for the delay..

Thanks,
Ashok K.

rahulkhandelw's picture
User offline. Last seen 9 years 28 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: Updating a file using a Peoplecode in Application Engine

One more thing make sure while opening the file charset is Non-Unicode.
&TestFile = GetFile("C:\Documents and Settings\rkhandelwal\Desktop\test.txt", "R", "A", %FilePath_Absolute);

Here parameter A specifies that file is being opened in Non-unicode char set. I used getposition method and I didn't encounter any error.

Please let me know if you face any problem.

ashok_star2004's picture
User offline. Last seen 33 weeks 6 days ago. Offline
Joined: 02/13/2009
Posts: 45
Re: Updating a file using a Peoplecode in Application Engine

Yes.Im near to the task.Now im succeeding when i have only one file to update.Suppose if i have 3 copies of source file each one with a difference in count of lines ,im able to get theoutput file with the result equal to that of the last file as
Foreg;
File name:1.txt
Count:2
Filename:2.txt
Count:2
Filename:3.txt
Count:2

Here the count of thelines starting with N,PER in all the 3 files are different.But im getting the result same for all the 3 files.

Thanks,
Ashok K.

rahulkhandelw's picture
User offline. Last seen 9 years 28 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: Updating a file using a Peoplecode in Application Engine

I m confused now.. Are you creating only one file for all 3 files.. i hope No. Process all files in a serial way and make sure variables used are properly reassigned.

ashok_star2004's picture
User offline. Last seen 33 weeks 6 days ago. Offline
Joined: 02/13/2009
Posts: 45
Re: Updating a file using a Peoplecode in Application Engine

Hi Rahul,
Im just copying the source file to 3 files and making differences in 3 copied files each manually(like extra added line,number of line count starting with N,PER,etc)just to test it.Then run the appengine to erase those lines starting with N,PER and update the files.

Thanks,
Ashok K.

rahulkhandelw's picture
User offline. Last seen 9 years 28 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: Updating a file using a Peoplecode in Application Engine

How are you erasing a line in file?

ashok_star2004's picture
User offline. Last seen 33 weeks 6 days ago. Offline
Joined: 02/13/2009
Posts: 45
Re: Updating a file using a Peoplecode in Application Engine

Hi Rahul,
Now,im taking these 3 filenames in an array, then using IF LOOP in FOR LOOP writing those files ommitting those lines(N,PER).
Thanks,
Ashok K.

rahulkhandelw's picture
User offline. Last seen 9 years 28 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: Updating a file using a Peoplecode in Application Engine

ok.. got it , I thought you are using some method i m not aware of..

Thanks,

Rahul Khandelwal