0 pts.
 Determining source file an RPGLE program was compiled from (created with CRTBNDRPG command).
RPG
How can I retrieve or print non-interactively what source file an RPGLE program (created with CRTBNDRPG command) was compiled from? I know how to find this information interactively using the DSPPGM command. The DSPOBJD command does not show any value for an RPGLE program.

Software/Hardware used:
ASKED: April 18, 2005  8:16 AM
UPDATED: November 1, 2010  4:02 AM

Answer Wiki:
Information regarding source for primary modules within an ILE RPG program or service program can be retrieved with API programs QBNLPGMI and QBNLSPGM. The source code below is for a utility to extract module information from all ILE RPG programs and service programs in a given library. Compile the PF and then the programs. Change the 'libname' in the CL to whatever library you want to explode. I have my CL setup with all libraries across our production library list. Just copy the two call statements and add more libraries to the CL. Hope this helps. ******************************************* *** Source for ILESOURCE physical file *** ******************************************* A R ILESOURCER A PGMTYP 10 COLHDG('Program' 'Type') A PGMNAM 10 COLHDG('Program' 'Name') A PGMLIB 10 COLHDG('Program' 'Library') A MODNAM 10 COLHDG('Module' 'Name') A MODLIB 10 COLHDG('Module' 'Library') A SRCFIL 10 COLHDG('Source' 'File') A SRCLIB 10 COLHDG('Source' 'Library') A SRCMBR 10 COLHDG('Source' 'Member') A MODATR 10 COLHDG('Module' 'Attribute') A MODDAT L COLHDG('Module' 'Date') A DATFMT(*USA) A MODTIM T COLHDG('Module' 'Time') A TIMFMT(*HMS) A SRCDAT L COLHDG('Source' 'Date') A DATFMT(*USA) A SRCTIM T COLHDG('Source' 'Time') A TIMFMT(*HMS) A DBGDTA 10 COLHDG('Debug' 'Data') A MODRLS 6 COLHDG('Module' 'Release') A ACTGRP 30 COLHDG('Activation' 'Group') A SHRGRP 1 COLHDG('Shared' 'ACTGRP') ******************************************* *** Source for ILESOURCEC program *** ******************************************* PGM CALL PGM(QUSCRTUS) PARM('ILESOURCE QTEMP ' + 'TEXT ' X'0000512C' X'00' '*ALL + ' ' ') CALL PGM(QUSCRTUS) PARM('ILESOURCESQTEMP ' + 'TEXT ' X'0000512C' X'00' '*ALL + ' ' ') CLRPFM FILE(ILESOURCE) CALL PGM(ILESOURCE) PARM('libname ') CALL PGM(ILESOURCES) PARM('libname ') ENDPGM ******************************************* *** Source for ILESOURCE program *** ******************************************* H DFTACTGRP(*NO) ACTGRP('ILESOURCE') FILESOURCE O E DISK D UsrSpc S 20 Inz('ILESOURCE QTEMP ') D Format S 8 D ILEPgmLib S 20 D ILEProgram S 10 Inz('*ALL') D ILELibrary S 10 D ErrorCode S 100 Inz D ARR S 1 Based(LstPtr) Dim(32767) D SpcPtr S * D LstPtr S * D HdrData DS 192 Based(SpcPtr) D StrPos 125 128B 0 D #Entries 133 136B 0 D DtaLen 137 140B 0 D SrcData DS 3995 Based(LstPtr) D PGMNAM 1 10 D PGMLIB 11 20 D MODNAM 21 30 D MODLIB 31 40 D SRCFIL 41 50 D SRCLIB 51 60 D SRCMBR 61 70 D MODATR 71 80 D MODDTM 81 93 D SRCDTM 94 106 D DBGDTA 145 154 D MODRLS 155 160 D RcvVar DS 536 D ActGrp 369 398 D ShrGrp 407 407 D DtaLen2 S 4B 0 Inz(536) * Load ILE programs into user space C *Entry Plist C Parm ILELibrary C Eval ILEPgmLib = ILEProgram + ILELibrary C Eval PgmTyp = '*PGM' * Load ILE programs into user space C CALL 'QBNLPGMI' C PARM UsrSpc C PARM 'PGML0100' Format C PARM ILEPgmLib C PARM ErrorCode * Get pointer for user space C CALL 'QUSPTRUS' C PARM UsrSpc C PARM SpcPtr C PARM ErrorCode * If we have entries in user space loop the number of entries and load file C If #Entries > 0 C Eval LstPtr = SpcPtr C Eval LstPtr = %Addr(Arr(StrPos + 1)) C DO #Entries C Eval ModDat = %Date(%Subst(ModDtm:1:7):*CYMD0) C Eval ModTim = %Time(%Subst(ModDtm:8:6):*HMS0) C Eval SrcDat = %Date(%Subst(SrcDtm:1:7):*CYMD0) C Eval SrcTim = %Time(%Subst(SrcDtm:8:6):*HMS0) C Eval ILEPgmLib = PGMNAM + PGMLIB C CALL 'QCLRPGMI' C PARM RcvVar C PARM DtaLen2 C PARM 'PGMI0100' Format C PARM ILEPgmLib C PARM ErrorCode C Write ILESOURCER C Eval LstPtr = %Addr(Arr(DtaLen + 1)) C Enddo C Endif C Eval *INLR = *On ******************************************* *** Source for ILESOURCE program *** ******************************************* H DFTACTGRP(*NO) ACTGRP('ILESOURCE') FILESOURCE O E DISK D UsrSpc S 20 Inz('ILESOURCESQTEMP ') D Format S 8 D ILEPgmLib S 20 D ILEProgram S 10 Inz('*ALL') D ILELibrary S 10 D ErrorCode S 100 Inz D ARR S 1 Based(LstPtr) Dim(32767) D SpcPtr S * D LstPtr S * D HdrData DS 192 Based(SpcPtr) D StrPos 125 128B 0 D #Entries 133 136B 0 D DtaLen 137 140B 0 D SrcData DS 3995 Based(LstPtr) D PGMNAM 1 10 D PGMLIB 11 20 D MODNAM 21 30 D MODLIB 31 40 D SRCFIL 41 50 D SRCLIB 51 60 D SRCMBR 61 70 D MODATR 71 80 D MODDTM 81 93 D SRCDTM 94 106 D DBGDTA 145 154 D MODRLS 155 160 D RcvVar DS 434 D ActGrp 92 121 D ShrGrp 207 207 D DtaLen2 S 4B 0 Inz(434) * Load ILE programs into user space C *Entry Plist C Parm ILELibrary C Eval ILEPgmLib = ILEProgram + ILELibrary C Eval PgmTyp = '*SRVPGM' * Load ILE programs into user space C CALL 'QBNLSPGM' C PARM UsrSpc C PARM 'SPGL0100' Format C PARM ILEPgmLib C PARM ErrorCode * Get pointer for user space C CALL 'QUSPTRUS' C PARM UsrSpc C PARM SpcPtr C PARM ErrorCode * If we have entries in user space loop the number of entries and load file C If #Entries > 0 C Eval LstPtr = SpcPtr C Eval LstPtr = %Addr(Arr(StrPos + 1)) C DO #Entries C Eval ModDat = %Date(%Subst(ModDtm:1:7):*CYMD0) C Eval ModTim = %Time(%Subst(ModDtm:8:6):*HMS0) C Eval SrcDat = %Date(%Subst(SrcDtm:1:7):*CYMD0) C Eval SrcTim = %Time(%Subst(SrcDtm:8:6):*HMS0) C Eval ILEPgmLib = PGMNAM + PGMLIB C CALL 'QBNRSPGM' C PARM RcvVar C PARM DtaLen2 C PARM 'SPGI0100' Format C PARM ILEPgmLib C PARM ErrorCode C Write ILESOURCER C Eval LstPtr = %Addr(Arr(DtaLen + 1)) C Enddo C Endif C Eval *INLR = *On 
Last Wiki Answer Submitted:  April 19, 2005  8:18 am  by  WaltZ400   645 pts.
All Answer Wiki Contributors:  WaltZ400   645 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Also the Determining Source Files for RPGLE programs discussions for an ILE CL example.

Tom

 107,845 pts.