Problem solve Get help with specific problems with your technologies, process and projects.

Where's the source?

Read this tip and find out how to create an outfile of all source members by using a simple command.

Here is the scenario:

You are a new programmer or consultant and you are assigned a seemingly simple change to an existing program. With your skills it will be a piece of cake. What is the first thing you do? You have to find the source.

Let's make it even more fun and say that the previous programmer(s) left two weeks before you arrived and left vague notes that seem to be printed out with a DBCS font. Apparently there are multiple versions or source in various libraries on the system. Never fear, one thing you can do is use the DSPPGM command (if it's a program). But that does not guarantee the source is there. Maybe the program was compiled on another machine and moved over, maybe the source file has moved or been deleted (in which case you are out of luck, but you would hate to go looking for something that isn't there.) And if it's a display file, forget about finding an easy way to pinpoint the source by looking at the compiled object.

At this point I could probably make a good advertisement for my favorite 'for profit' utility "Pathfinder" by Hawkeye Information Systems, but if you are a consultant you have to be a little more self-sufficient and not always count on your quality utility to be there for you. Remember, there are no answers on the certification test that you can write "just use Hawkeye".

Now what? Endless hours of hunting in each source file you happen to stumble across? Well, if you are like me you think there must be a more logical approach, and you would rather just take the time to find out where the entire source is anyway. Which is going to save you tons of time in the future, and maybe even make you a hero.

Yes, there is something you can do. I created an outfile of all source members by using a simple command and a query tool to filter just the 'source' from my initial findings.

First try "DSPPGM PROGNAME". Look for the source file parameter in the display. See if the source is really there.

If you can't find the source and it's a CL program, you can always RTVCLSRC to get the code (without those helpful comments).

Finally, here is what I did:

1. Source members actually exist in physical files, so you can list information on all physical files and the source files will be in there. Do this by executing the following command -- in batch would be a good idea.


2. Now you have an outfile named 'SOURCEMBR' with some 32 fields of information in it. One of those fields is MLSEU, which is the "Source Type" field. (There is also an MLSEU2 field for S/38 code) You can filter your selections even further by using your favorite query method of SQL, IBM Query, OPNQRYF, or even CPYF to select field MLSEU not equal to blanks:


You would want to sort by the MLNAME field which is the source member name.

Now you have a file listing of every source member name and the library it exists in. You can now pinpoint EXACTLY where the source is, and if there are multiple copies it will help you determine which is most current. There is other information in this file and I've listed the fields below. You can see how many records (MLNRCD) in the source file as well as the last change date (MLCHGD). Here is a field listing:

Field Name   Field Description        
MLRCEN       Retrieval century:  0=19x
MLRDAT       Retrieval date: year/mont
MLRTIM       Retrieval time: hour/minu
MLFILE       File                     
MLLIB        Library                  
MLFILA       File attribute: *PHY or *
MLMXD        Reserved                 
MLFATR       File attribute:  PF, LF, 
MLSYSN       System Name (Source Syste
MLASP        Auxiliary storage pool ID
MLRES        Reserved                 
MLNOMB       Number of members         
MLNAME       Member                    
MLNRCD       Current number of records 
MLNDTR       Number of deleted records 
MLSIZE       Data space and index size 
MLSEU        Source type for S/38 View 
MLCCEN       Member creation century:  
MLCDAT       Member creation date: yea 
MLCHGC       Last change century: 0=19 
MLCHGD       Last change date: year/mo 
MLCHGT       Last change time: hour/mi 
MLMTXT       Text 'description'        
MLSEU2       Source type               
MLUCEN       Last Used Century: 0=19xx 
MLUDAT       Last Used Date: year/mont 
MLUCNT       Days Used Count           
MLTCEN       Usage Data Reset Century: 
MLTDAT       Usage Data Reset Date: ye 
MLSIZ2       Data Space and Index size
MLSTFR       Member storage freed Y=Ye 

One additional tip: I had multiple iSeries' and was able to do this on each machine, then FTP'd the files to one machine where they were combined and then queried. There is another field in the SOURCEMBR file called MLSYSN, which is the system name.

Good luck! Hope this helps you all out there! - Jeff


The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

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

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.