Home > AS/400 Tips > iSeries programmer tips > Documenting nested program structures on the AS/400
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Documenting nested program structures on the AS/400


Benito Abraham, Contributor
11.24.2008
Rating: -2.21- (out of 5)


iSeries news and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Often, it's a big task to keep track of and document nested program structures on the AS/400 -- (DOW/ENDDO, DOU/ENDDO, IF/ELSE/ENDIF, CASE/ENDCS, SELEC/ENDSL, BEGSR/ENDSR). If we don't do it, it's really hard to follow the sequence within a program, and on the other hand when we do it, it's difficult to update and usually this documentation ends up being obsolete and unreliable. So, in order to solve this problem we created the XPGMSTR command to document these structures in a standard and automatic way, so no matter what you do or how you edit your source code you can always keep it up to date just by calling the command as many times as it takes.

The command can be invoked in any way you wish (e.g., directly from the command line, through PDM or in my personal favorite way via the exit point of the STRSEU command so that when you edit an RPG source code you will have its structures documented).

Here, we'll cover the first two ways, leaving the third option as an extra homework task for those who were interested in it.

Example: The command looks like the one shown in the following screenshot and you need to write the information regarding the source you want to document (library/file/member)


Click on image for larger version

If you want to use it from PDM you can add the command to the PDM's user-defined options as in the following screenshot


Click on image for larger version

Now, let's see an example using PDM. In the "Work with Members Using PDM" screen we choose an RPG member, e.g., P0305OLD, and then type 5


Click on image for larger version

We see in the source code that there are no comments or references regarding the RPG structures in the program.


Click on image for larger version

Then we go back to the "Work with Members Using PDM" panel and type "XP" next to the source member that we want to document.


Click on image for larger version

After we run the command when we go back to the source code we see at the right of the panel (in the comments are) the nested RPG structures (in this example the BEGSR and IFEQ RPG commands).

>
Click on image for larger version

And we also are able to see every nested structure (IF, ELSE, ENDIF) at the comments column all of them with a four digits number telling us its nested level (from 0010 the outermost to 9990 the innermost).

>
Click on image for larger version

All RPG structures are well documented here and clear to follow.

Source code
A PDF of the RPG program code is provided.

A PDF of the CLP program code is provided.

Command

0001.00              CMD        PROMPT('Documenting RPG structure')            

0001.01 PARM KWD(BIBLIO) TYPE(*CHAR) LEN(10) MIN(1) +
0001.02 PROMPT('Library name')
0001.03 PARM KWD(ARCHIVO) TYPE(*CHAR) LEN(10) MIN(1) +
0001.04 PROMPT('Source file')
0002.00 PARM KWD(MEMBER) TYPE(*CHAR) LEN(10) MIN(1) +
0003.00 PROMPT('RPG member name')

Compiling the programs and command

  1. Create a dummy file:
    CRTSRCPF FILE(QTEMP/FSOURCE) TEXT('Dummy file')
  2. Compile RPG program:
    CRTRPGPGM PGM("your_library"/P55ARA02) SRCFILE("your_source_file")
  3. Compile CLP program:
    CRTCLPGM PGM("your_library"/J55ARA02) SRCFILE("your_souce_file")
  4. Create Command: (make sure that "your_library" is in your current library list
    CRTCMD CMD("your_library"/XRPGSTR) PGM(J545ARA02)

ABOUT THE AUTHOR: Benito Abraham is an analyst programmer at Pride International. He has over 15 years experience on AS/400, including iSeries security and RPG.

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.


Submit a Tip




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



RELATED CONTENT
iSeries programmer tips
Enhancing RPG with external SQL stored procedures
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
Implementing a browser interface in COBOL: Displaying database fields
Taking advantage of CL advancements, starting with V5R3
TAATOOL: Useful tools for programmers on IBM i
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Making the most of RPG data handling on IBM i
Groovy programming on IBM i

RPG iSeries programming
Enhancing RPG with external SQL stored procedures
Introduction to SQLRPGLE on IBM i: Making a report
Making the most of RPG data handling on IBM i
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
How to: Sort arrays using RPGIV

iSeries application development tools
TAATOOL: Useful tools for programmers on IBM i
Migrating from RPG to EGL on IBM i
EGL Rich UI on IBM i: Do you Dojo?
Running PHP open source applications: NOBODY needs authority
Zend Web software teams up with IBM System i
The best technologies and tools for System i programmers in 2009
AS/400 lessons from the past, present, and future: A holiday tale
Learn the i: iSeries DevCon coming up in Orlando
Application modernization in the i world
System i virtualization prevents T-Mobile busy signal
iSeries application development tools Research

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

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