Problem while writing data in a text file

420 pts.
Tags:
AS/400
AS/400 Text File
I am trying to write data from one stream file to a text file. Stream file is a big file of 5000 pages and i am generating 5 text files with 1000 pages . Now when i write first 1000 pages to file1.txt it writes perfectly well . Now when 1000 pages are reached i close that file and open a new file file2.txt and start writing to file file2.txt from page 1001 to 1002 and so on. Now from file2.txt onwords my data is not getting aligned correctly.It is writing data with prior 5-6 spaces .I am not sure why this is happening . Is it due to some buffer problem or some junk data ? Do i have to clear buffer before writing data as when i am generating one complete text file of 5000 all the data is getting aligned perfectly well. code : InFileHandle = ifsOpen(%str(inFilePtr):'rb'); Open input file. OutFileHandle = ifsOpen(%str(outPathName):'w,o_ccsid=819'); IFSClose(OutFileHandle); make ccsid 819 to make it windows compatible OutFileHandle = ifsOpen(%str(outPathName):'w'); Now everytime when i am generating new files i am closing first and opening new with the same input and output handles. Please suggest ! Help will be highly appreciated.

Software/Hardware used:
as400
ASKED: November 3, 2012  3:58 PM
UPDATED: November 5, 2012  1:34 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    The opens and closes aren't useful by themselves. We need to see the reads and writes and the logic that controls them. We don't know if buffers need to be cleared nor anything else until we see how they are defined and used. Can you show more code? -- Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    strange .. how did you create the "text" files? 
    48,565 pointsBadges:
    report
  • philpl1jb
    no, forget that question.
    48,565 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following