Program to get all the member name in source physical file

145 pts.
Tags:
AS/400
Physical File
RPGLE
Hi, I need all the members list in source physical file (QRPGLESRC) to the workfile (PF). How to use the DSPFD in RPGLE program to populate all the members in the outfile. Please share some example program. And I want to override concept to read all the members. Please share any example program. I don't know how to execute in my program. I did the logic that reads only one member in the source physical file.

Answer Wiki

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

Hi

Override the file with frommbr(*all) for all the members.
Use the file information data structure to see which member is open

Just use the command to make the outfile for *MBRLIST

Good luck

Discuss This Question: 12  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
  • philpl1jb

    One way to get a list of members of a file (including a source file) would be to use the DSPFD command.  You could request the type of list *MBRLIST or *MBR and the Output as *OUTFILE

     

    50,505 pointsBadges:
    report
  • srivijay1
    Philpl1jb can you please share a example source.
    145 pointsBadges:
    report
  • philpl1jb
    Show us your source and issues.
    50,505 pointsBadges:
    report
  • philpl1jb

    If you are ". And I want to override concept to read all the members" then you don't need the list at all".

    But with your sql, I can't see how you would tell which member the source was from when useing the ". And I want to override concept to read all the members"

     

    50,505 pointsBadges:
    report
  • srivijay1
    FQRPGLESRC IF   F 1012        Disk                     
    FPF001     IF A E             Disk                     
                                                           
    DDataDs           Ds          1012                     
    D SrcSeq                         6S 2                  
                                                           
    D SrcDta                        80A                    
    D SrcDat                         6S 0        
    C                                                                  
    C                   Read      QRPGLESRC     DataDs                 
    C                   Dow       Not %Eof(QRPGLESRC)                  
    C                   If        %SubSt(SrcDta:7:74)<> *blanks        
    C*                            OR %SubSt(SrcDta:13:1) <> '*'        
    C                   If        %Subst(SrcDta:12:1) = 'C'            
    C                             OR %SubSt(SrcDta:11:2) =*blanks      
    C                   Eval      Srcdata = srcdta                     
    C*                  Eval      SrcDate = Srcdat
    C                   Write     Pf0001R                 
    C                   Endif                             
    C                   Endif                             
    C                   Read      QRPGLESRC     DataDs    
    C                   EndDo                                                            
       Here it reads only one member source but i need to read all the member sources                                                    
    145 pointsBadges:
    report
  • philpl1jb

    Yes.  One option is to issue an ovrdbf command prior to calling the rpg program.

    Something like this ... where source and lib would be variables.

    OVRDBF FILE(SOURCE) TOFILE(LIB/QRPGLESRC) SHARE(*YES)

    50,505 pointsBadges:
    report
  • srivijay1
    Hi Thanks philpl1jb for you idea. i done now its reading all the member i share my code.pls tel do i want to improve any of the steps.
    HDftActGrp(*No)                                                   
    H  BNDDIR('QC2LE')                                                
    FQRpglesrc IF   F 1012        Disk    Extmbr(MbName)              
    F                                     UsrOpn                      
    FSrcfle    IF   E             Disk                                
    FPf001     IF A E             Disk                                
                                                                      
    DDataDs           Ds          1012                                
    D SrcSeq                         6S 2                             
    D SrcDta                        80A                               
    D SrcDat                         6S 0                             
                                                                      
    DSystem           Pr                  ExtProc('system')           
    D CmdStr                          *   Value Options(*String)      
                                                                      
    DCommand          S            200a                               
    DMbname1          S                   like(Mbname)                   
    DMbrNum           S              2a                                  
    DMbrCnt           S              4s 0                                
    DLibrary          S             10A   inz('#asxc')                   
                                                                         
     /Free                                                               
        Command='DSPFD File(#ASXC/QRpglesrc) Type(*Mbr) ' +              
                'Output(*OutFile) FileAtr(*Pf) OutFile(#asxc/srcfle) '+  
                'OutMbr(*First *add)';                                   
                                                                         
      System(Command);                 
      Read Srcfle;                     
      Dow Not %Eof(Srcfle);            
      MbName1 = MbName;                
                                       
        If Not%Open(QRpglesrc);        
          Open QRpglesrc;              
        Else;                          
        Endif;                         
                                       
                                                     
      Command ='OVRDBF File(Srcfle) TOFILE('+        
                %Trim(Library) + '/QRpglesrc)';      
      System(Command);                               
                                                     
      Read QRpglesrc DataDs;                         
        Dow Not %Eof(qrpglesrc);                     
                                                     
      //If %SubSt(SrcDta:1:74) <> *blanks OR %SubSt(SrcDta:13:1) <> '*'; 
        If SrcDta <> *Blanks;                                            
        If %Subst(SrcDta:12:1) = 'C' OR %SubSt(SrcDta:11:2) =*Blanks;    
                                                                         
          SrcData = SrcDta;                                              
          //SrcDate = Srcdat;                                            
          Write     Pf0001R;                                             
          Endif;                                                         
        Endif;                                                           
      Read qrpglesrc DataDs;               
        Mbrcnt = Mbrcnt + 1;               
        Enddo;                             
         Close QRpglesrc;                  
      Read Srcfle;                         
      Enddo;                               
         Command = 'DLTOVR File(*ALL)';    
         System(Command);                  
                                           
          Close Srcfle;       
     *Inlr = *On;             
    /End-Free                 
    ***************** End of document******************************

    one douth i have in my code. The overide is get happen via Extmbr('member name field of out file) but its not getting overide via the OVrdbf .So whether i can remove the command ovrdbf command.
    145 pointsBadges:
    report
  • deepu9321
    Hi Srivijay, 

    Maybe you could try this.

    1. Use DSPFD TYPE(*MBR/*MBRLIST) & Take it to OUTFILE.
    2. Declare OUTFILE in your RPGLE Program. (If you would like to use DSPFD also inside your RPGLE Program, you should declare this file as USROPN). 
    3. Declare your Source file QRPGLESRC by using EXTMBR(VARIABLE) keyword with USROPN.
    4. Read your OUTFILE and pass member name to VARIABLE mentioned on EXTMBR keyword.
    5. OPEN SOURCEFILE. 
    6. Read data of corresponding member, Once it reaches EOF, you can CLOSE SOURCEFILE.
    Read next member details from out file and open SOURCEFILE again. 

    just go through it once, if you feel this lengthy and confusing, get back with your doubts.

    Pradeep.
    3,870 pointsBadges:
    report
  • srivijay1
    hello Deepu.,Thanks for the idea. I did the same implementation which you have mentioned.In that Code the The override is taking from the Extmbr() it not considering the OVRDBF command. The issue which i facing is when i call the program second time I am getting an error. Message : Undefined record type is found in File TESTFILE (C G D F). i dono how to resolve this. Each time i signoff the section and its works fine. 
    145 pointsBadges:
    report
  • deepu9321
    Hi Srivijay,

    I dont see any reason to have OVRDBF in this case. 

    You could either use or OVRDBF (both are not required). Also, you have used OVRDBF to SRCFLE which contains the list of members in a source file. 

    Everything else seem to be fine.

    Remove OVRDBF and try running your program again.
    3,870 pointsBadges:
    report
  • philpl1jb

    Srcfle may need to be user open ..

    Open it after you issue the command to load the data.

    50,505 pointsBadges:
    report
  • philpl1jb
    I would think that you would want the DSPFD to replace the file or your reports will pick up multiple requests.
    50,505 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