Home > AS/400 Tips > iSeries programmer tips > Automate programming tasks
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Automate programming tasks


Andrew Borts
11.17.2004
Rating: -3.29- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


One thing I do to make my job easier is create programming tools that I can use to create sections of code for me.

How this works is I have a specific pattern in mind that I need -- say Move's into fields, clearing ALL the fields in a file via Move's or Eval's, or simply inserting a key structure so I can chain to a file. Whatever the mundane programming task, if I can read a file and create the structures or the code automatically, I do it. And that's because, as you know by now, I'm LAZY. But also the results are fantastic. And for files with a large number of fields in them, where you NEED to move data into the fields, this is necessary to get your job done.

I always add to my collection of these tools. In ALL instances, I give my tool the name of the file, and the program responds by writing code that I would use for that particular file. I've been adding to this program for years, so I have sections of this tool that write chunks of Web sites now. But it all started when someone simply said, "Hey, I can't find the source for these files!" So I created the beginnings of my toolbox.

Writing to a Source Physical File
Let's go over the basics of this first. We're writing into a source physical file with the following configuration;

Looking at the above, we have a sequence, which because SEU is SUCH a forgiving program, can be filled in with ONE number for all your lines, or add 10 for each sequence in the file you're writing -- It's your choice. You have a date for EACH line number and the code, which will become your new RPG program. One thing I REALLY like doing is creating a list of ALL the KEYS from a file that are available for me. Let's focus on this tool, but you can do MANY variations on this theme. Then I use the following to access the source physical file I'm writing to.

The following CL program is the bread and butter of my program tool. I like calling CR8CSPEC -- or Create C-Specs -- but you ca


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
RPG iSeries programming
IBM i shop boosts online sales with RPG-based Web platform
Migrating from RPG to EGL on IBM i
Allow access to data from a stored procedure result set using COBOL or RPG
EGL Rich UI on IBM i: Do you Dojo?
Programming for the Web on the IBM i, what is possible
A taste of COMMON: ILE, IBM releases, Web applications and new products
Documenting nested program structures on the AS/400
How to: Sort arrays using RPGIV
How to: Create an RPGLE array
How to use an embedded SQL statement and display the result in a subfile

iSeries programmer tips
Groovy programming on IBM i
EGL Rich UI on IBM i: Do you Dojo?
Running PHP open source applications: NOBODY needs authority
Programming for the Web on the IBM i, what is possible
Using geocoding on AS/400 to enhance your Web presence
The best technologies and tools for System i programmers in 2009
Seven IBM i project lessons learned in 2008
Documenting nested program structures on the AS/400
What is an integrated database?
An automated CL method of moving a query from AS/400 to Excel

iSeries CL programming
Checking in on your IBM i authorization lists
Running PHP open source applications: NOBODY needs authority
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
CL program for daily backups
An automated CL method of moving a query from AS/400 to Excel
Changing user password expiration
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date
Advanced Job Scheduler help
How do I retrieve the source for an output queue description to put in to a CL program?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Report Program Generator  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


n TRULY create ANYTHING you'd like.

Source for CR8CSPEC CL program

What the program does is create the "juice" that my RPG program creation tools will use to output code. Now there's NOTHING sophisticated about this from this point onwards; this is a typical "read a file, and output another file" type of program.

Here's MY program HASTILY WRITTEN to output the C specs for the K lists I have had to cut and paste into thousands of programs over the years.

COMPLETE Source for CR8CSP3

There's NOTHING sophisticated about this program. It's READING the output from the following command from the calling CL program:

This will create the file QAFDACCP. "Hey, where did I figure THAT information out?" Well, I'll SHOW you! On the iSeries, since the V4 days, ALL the hard-to-find reference material -- such as the names of the file names created by CL commands or the CPF error messages that a command may produce -- are built into the help text. So hitting help in SEU, then asking for extended help produces the following text produced for the DSPFFD command:

[TABLE]

Clicking fast forward to the File information:

[TABLE]

Here's the line I NEEDED blown up:

[TABLE]

Here's the Access Path File name -- QAFDACCP. Why do I need that? TO COMPILE IN BATCH!

This is needed for the following line of the RPG program:

To ACCESS the file created, I overrode to see the file I created in the CL portion:

Clear?

Here's a sample of the output from the example program:

So I have everything I need in my program for the KLIST portion -- or wherever I place the KLIST to see what this file is all about -- including if the field is ascending or descending.

Other examples I've written over the years can be found here. These read the DSPFFD output into the file named QADSPFFD:

Again these are examples of what I needed over the years -- I've added tools to this to complete my cache.

Here's something else you might want to play with. Give it a try, and if you have any questions or comments or are confused, e-mail the editor and I'll get right back to you.

-----------------------------------------
About the author: Andrew Borts is webmaster at United Auto Insurance Group in North Miami, Fla. He is often a frequent speaker at COMMON and is past president of The Southern National Users Group, an iSeries-AS/400 user group based in Deerfield Beach, Fla.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts