Q

RPG IV program for cover letters

I need to write a RPG IV program that will generate not only a cover letter for specific customers but also list their orders that will not be filled due to lack of product based on specific tables in the system. Should I create the cover letter in QTXTSRC, or Output spec's in QRPGLESRC? What are some of the newest things? We are on iSeries V5R2.
What you do depends on how often the text will change, and whether you want your users to be able to change the text easily. The most flexible method would be to allow the users who need to be able to change this text to maintain a text file in a folder in QDLS in the IFS -- you can then use CPYFRMPCD to refresh a PF that your program will use as the source text for the letter.

A member or members in QTXTSRC (or create a source file called QLETTERS, maybe?) is also fine, and is easy to maintain. Just override to the right member and open it in your program like a normal database file.

And a normal database file is also OK, if you create a maintenance program to go with it. This has the advantage that it would just be another table for authorized users to maintain, and they do not need to know how to use SEU. Plus, you can add fields to each text line (record) to provide header records, group data, boilerplate flags and authority control -- whatever your imagination and the user's requirements will support.

O-specs would be my last choice. I assume you mean that the text is stored as constants in the program. This means that changes require programmer intervention.

Now to the printing. Your new program must do two things -- print a letter, and print a list from a database. You can create two programs, one for each task -- that's a better methodology. You can use the same printfile between the two program by overriding the file (OVRPRTF) with SHARE(*YES), then using USROPN in the two programs. Call one program from the other. The called program must close the printer file before returning, but the calling program will still have the printer file open. When the calling program ends, it must close the printer file, and then the printout becomes ready to print.

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was first published in November 2004

Dig deeper on RPG iSeries programming

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

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

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close