30 pts.
 How do you write to a source file .TXT in rpg?
I am using a .TXT file in QCLSRC for FTP input. Instead of having the 4 records sitting there all the time. I want to be able to write to the .TXT file when a program is called.

Software/Hardware used:
AS/400
ASKED: January 22, 2011  7:19 PM
UPDATED: February 1, 2011  1:30 AM

Answer Wiki:
Try this. Create an RPG that writes to an acutal physical file. Then over ride the FTP input file to the physical file you created. I did this once, a long time ago. Let me know if you need an example and I will see if I can find it.
Last Wiki Answer Submitted:  January 25, 2011  9:12 pm  by  Teandy   5,830 pts.
All Answer Wiki Contributors:  Teandy   5,830 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I am using a .TXT file in QCLSRC for FTP input.

Usually “.TXT” is contradictory to “QCLSRC”. A “.TXT” file would be a streamfile in the /root file system while “QCLSRC” would be a physical source file (i.e., a database file) in the /QSYS.LIB file system.

You might have a “.TXT” streamfile that is copied into a QCLSRC source member, and the resulting source member is then used as the input script for FTP. Or you might simply be using terms that aren’t appropriate because you aren’t familiar with what is happening.

ILE RPG can read/write .TXT streamfiles, and it can also read/write physical source file members — but the two methods are very different. Streamfiles are handled with the common Unix APIs for open(), read(), write(), close(), etc., while physical files are accessed with RPG instruction codes for database I/O.

Can you clarify what you need to do? Do you know if you really have a “.TXT” file?

Tom

 108,115 pts.

 

I created a source physical file named FTPSRC for my FTP input.

I add or clear the relevant member, write the FTP script to the member, then override to that member when running the FTP.

 5,670 pts.

 

In your RPG program, use an output file – you might want to call it “SOURCE”. In the RPG program you can write to the file from, for instance, a table.

Outside the program, override the file “SOURCE” to the actual physical file member and compile the program interactively instead of compiling in batch. When calling the program, call a CL program that does the file override and calls the RPG program.

 1,410 pts.