
This post is in answer to a question I was asked:
We have compiled an RPG program from an IFS location but we are unable to determine the source of the compilation. We attempted the DSPPGM command and APIs, but they only show the member location when the program is compiled from a library, not for the IFS.
All modern RPG programs contain modules, even if I used the CRTBDNRPG command to create the program object. In this example I have a program TESTRPG, that is in the library MYLIB, that I created using CRTBDNRPG.
The first way to find where the source was is to use the Display Program command, DSPPGM. The command string I would use is:
DSPPGM PGM(TESTRPG) DETAIL(*MODULE) |
The Display Program Information screen is shown, which lists all the modules in the program. I used CRTBDNRPG and not bound in any other modules, therefore, the program only contains one module:
Display Program Information Display 1 of 1 Program . . . . . . . : TESTRPG Library . . . . . . . : MYLIB Owner . . . . . . . . : SIMON Program attribute . . : RPGLE Detail . . . . . . . . : *MODULE Type options, press Enter. 5=Display description 6=Print description Creation Optimization Debug Opt Module Library Attribute Date Level Data 5 TESTRPG QTEMP RPGLE 03/12/25 *NONE *YES |
I put a "5" next to the module, and press Enter. The following screen is shown:
Display Program Information Program . . . . . . . : TESTRPG Library . . . . . . . : MYLIB Module attributes: Module . . . . . . . . . . . . . . . . . . . . : TESTRPG Library . . . . . . . . . . . . . . . . . . : QTEMP Source file . . . . . . . . . . . . . . . . . : Library . . . . . . . . . . . . . . . . . . : Source member . . . . . . . . . . . . . . . . : Source stream file . . . . . . . . . . . . . . : /home/MyDir/testrpg.rpgle |
On the above screen the source of the source is displayed, whether it was created from a source member or a file in the IFS.
For a "one-off" using the method described above is practical. If I wanted to check a number of program objects it is not, as I would have to check each program one at a time.
Here SQL comes to the rescue. I can retrieve the same information using the BOUND_MODULE_INFO SQL View.
In the example below I want to check the location of the source for all the programs in my library that start with "TESTRPG". I used the following statement:
01 SELECT PROGRAM_LIBRARY,PROGRAM_NAME,OBJECT_TYPE, 02 BOUND_MODULE_LIBRARY,BOUND_MODULE, 03 SOURCE_FILE_LIBRARY,SOURCE_FILE,SOURCE_FILE_MEMBER, 04 SOURCE_STREAM_FILE_PATH 05 FROM QSYS2.BOUND_MODULE_INFO 06 WHERE PROGRAM_LIBRARY = 'MYLIB' 07 AND PROGRAM_NAME LIKE 'TESTRPG%' |
Lines 1 – 4: These are the columns I selected:
- PROGRAM_LIBRARY: Library that contains the program
- PROGRAM_NAME: Name of the program (or service program)
- OBJECT_TYPE: Object type
- BOUND_MODULE_LIBRARY: Library containing the bound module
- BOUND_MODULE: Name of the bound module
- SOURCE_FILE_LIBRARY: Library the source file is found in that was used to create the module
- SOURCE_FILE: Name of source file
- SOURCE_FILE_MEMBER: Name of the member in the source file
- SOURCE_STREAM_FILE_PATH: If the module's source is in the IFS this is the path and file name that was used
I am going to state the obvious here: If a source file and member was used to create the module then the column SOURCE_STREAM_FILE_PATH is null. If the module was created from a file in the IFS then SOURCE_FILE_LIBRARY, SOURCE_FILE, and SOURCE_FILE_MEMBER will all be null.
Line 6: I am only interested in program objects in my library.
Line 7: I am using the LIKE and wildcard as I want the results to include all program objects that start with "TESTRPG".
The results were:
BOUND_ SOURCE SOURCE PROGRAM_ PROGRAM OBJECT MODULE_ BOUND_ _FILE_ SOURCE _FILE_ SOURCE_ LIBRARY _NAME _TYPE LIBRARY MODULE LIBRARY _FILE MEMBER STREAM_FILE_PATH -------- -------- ------ ------- -------- ------- ------ -------- ------------------------- MYLIB TESTRPG *PGM QTEMP TESTRPG <NULL> <NULL> <NULL> /home/MyDir/testrpg.rpgle MYLIB TESTRPG1 *PGM QTEMP TESTRPG1 MYLIB DEVSRC TESTRPG1 <NULL> MYLIB TESTRPG2 *PGM QTEMP TESTRPG2 MYLIB DEVSRC TESTRPG2 <NULL> |
The first program, TESTRPGM, was create using a file in the IFS. The others from source members.
Taking this one step further, if I wanted to list all the programs in my library that were created using a file in the IFS my statement would be:
01 SELECT PROGRAM_LIBRARY,PROGRAM_NAME,OBJECT_TYPE, 02 BOUND_MODULE_LIBRARY,BOUND_MODULE, 03 SOURCE_STREAM_FILE_PATH 04 FROM QSYS2.BOUND_MODULE_INFO 05 WHERE PROGRAM_LIBRARY = 'MYLIB' 06 AND SOURCE_STREAM_FILE_PATH IS NOT NULL |
Line 6: By checking if the IFS path name is not null will include all the programs compiled from source in the IFS.
My results are:
BOUND_ PROGRAM_ PROGRAM OBJECT MODULE_ BOUND_ SOURCE_ LIBRARY _NAME _TYPE LIBRARY MODULE STREAM_FILE_PATH -------- --------- ------ ------- -------- ------------------------- MYLIB TESTRPG *PGM QTEMP TESTRPG /home/MyDir/testrpg.rpgle |
This shows that TESTRPG is the only program in my library that was created from an IFS file.
This article was written for IBM i 7.5, and should work for some earlier releases too.
No comments:
Post a Comment
To prevent "comment spam" all comments are moderated.
Learn about this website's comments policy here.
Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.