Retrieving source members

pts.
Tags:
RPG
I want to retrieve all the source physical files in a particular library and then in each source physical file, I want to retrieve all the members. Any pointers to this would help. Thanks

Answer Wiki

Thanks. We'll let you know when a new response is added.

To find all source files, DSPFD FILE(mylib/*ALL) TYPE(*BASATR) OUTPUT(*OUTFILE) OUTFILE(mylib2/myfile). Then query the file where field ATDTAT=’S’ in mylib2/myfile. These are *SRC files.

You can then DSPFD FILE(mylib/srcfile) TYPE(*MBRLIST) OUTPUT(*OUTFILE) OUTFILE(mylib2/myfilesrcm). This will extract all the source members from a source file into a database file.

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Openanewdoor
    If I am understanding what you are asking for--this is what I did: To run a comparison report showing Objects vs. Source Members For each library and file you are concerned with for a source file--Do this: DSPFD (LIBRARYNAME/QRPGSRC) TYPE(*MBRLIST) OUTPUT(*OUTFILE)OUTFILE(COMPAREFILE) OUTMBR(*FIRST *ADD) For each Object that should be the primary file for your compare DSPOJD OBJ(OBJECTLIBRARY/*ALL) OBJTYPE(*FILE *MODULE *PGM) DETAIL(*BASIC) output(*outfile) OUTFILE(librayname/NAMEOFOUTFILE) NOW , MAKE A COMPARE QUERY OPT-3 AND *EQ FOR THE COMPARE FIELDS ***************************************************** Hope this helps
    0 pointsBadges:
    report
  • astradyne
    I did something similar to this a while ago where I had to find all of the physical files in a library and used embedded SQL to find the details. The following will find all source files on the system: C/Exec SQL C+ Declare csrSysTables Cursor for C+ Select Sys_Tname, Sys_Dname C+ From SysTables C+ Where Type In('P','T') and FileType = 'S' C/End-Exec C/Exec SQL C+ Open csrSysTables C/End-Exec To read through the list of source files using SQL, use the following: C/Exec SQL C+ Fetch Next from csrSysTables into :SrcFil, :SrcLib C/End-Exec Variables SrcFil and SrcLib should be defined as 10 character fields. For each record found you would need to do a DSPFD using: DSPFD FILE(srclib/srcfil) TYPE(*MBRLIST) OUTPUT(*OUTFILE) OUTFILE(QTEMP/SRCMBRS) OUTMBR(*FIRST *REPLACE) Use SQL similar to the example shown above to read through the file member list in QTEMP and then use the following to create an ALIAS to allow you to read through your source member: C Eval MySqlStmt = 'Create Alias QTEMP/' + C 'alsSRCMBR For ' + C %Trim(SrcLib) + '/' + C %Trim(SrcFil) + '(' + C %Trim(SrcMbr) + ')' C/Exec SQL C+ Prepare prpSRCMEMBER C+ From :MySqlStmt C/End-Exec C/Exec SQL C+ Execute prpSRCMEMBER C/End-Exec You need to use an Alias in order to override the member name to be read. The following can then be used to open the source member: C Eval MySqlStmt = 'Create Alias QTEMP/' + C 'alsSRCMBR For ' + C %Trim(vSrcLib) + '/' + C %Trim(vSrcFile) + '(' + C %Trim(vSrcMbr) + ')' C/Exec SQL C+ Prepare prpSRCMEMBER C+ From :MySqlStmt C/End-Exec C/Exec SQL C+ Execute prpSRCMEMBER C/End-Exec C Eval MySqlStmt = SqlStmt + 'QTEMP/alsSRCMBR' C/Exec SQL C+ Prepare prpSRCFILE C+ From :MySqlStmt C/End-Exec C/Exec SQL C+ Declare csrSRCFILE Cursor C+ For prpSRCFILE C/End-Exec C/Exec SQL C+ Open csrSRCFILE C/End-Exec And the following to read it: C/Exec SQL C+ Fetch csrSRCFILE Into :SrcRec C/End-Exec * Check for an error... C If SQLCod 0 C EndIf Before you can use the next member, you will need to close the cursor before re-opening it: * Drop the SQL alias... C/Exec SQL C+ Drop Alias alsSRCMBR C/End-Exec And close the source file cursor at the end of the program: * ...and close the cursor... C/Exec SQL C+ Close csrSRCFILE C/End-Exec Hope that helps All the best Jonathan
    370 pointsBadges:
    report
  • JPLamontre
    DSPFD FILE(*USRLIBL/*ALL) TYPE(*MBRLIST) + OUTPUT(*OUTFILE) FILEATR(*PF) or DSPFD FILE(MYLIB/*ALL) TYPE(*MBRLIST) + OUTPUT(*OUTFILE) FILEATR(*PF) is an other way of analysis
    0 pointsBadges:
    report
  • Jaicee
    if you're processing the members in a CL pgm, you also might want to check out the Retrieve Member Description (RTVMBRD) command.
    0 pointsBadges:
    report
  • TomLiotta
    What do you mean by "retrieve"? Do you want to create a list of all source members? (List into a file? Print a list?) Or do you want to copy all source members into some other file? Do you want to copy them to a PC? Do you want to read the lines from source members into a program? Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following