How to get number of members in two PF in single CL program

210 pts.
Tags:
AS/400
CL Program
DSPFFD
I want to get no of members in two multi member physical files in a one CL program using outfiles. Please give a pseudo code for this. How should I use DCLF, DSPFFD, RCVF in my CL program for getting no of members in 2 physical files, say my physical files are file1 and file 2. Please help. Thanks in advance!
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 1  Reply

 
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.
  • TheRealRaven
    If all you is the count of members, you simply run DSPFD TYPE(*ATR) twice to the same *OUTFILE. Use OUTMBR( *n  *ADD ) on the second DSPFD command.

    The first DSPFD command sets up the *OUTFILE with a record for the first file. Every DSPFD after that will *ADD a record. After all files are displayed, run RCVF in a loop to add the member counts together.

    pgm
    
       dcl   &mbrCnt      *int           value( 0 )
       dcl   &inEOF       *lgl           value( '0' )
    
       dclf  QAFDPHY
    
    
       dspfd       QGPL/QLBLSRC  type( *ATR ) +
                     output( *OUTFILE ) fileatr( *PF ) +
                     outfile( QTEMP/MYMBRCNT )
    
       dspfd       QGPL/QDDSSRC  type( *ATR ) +
                     output( *OUTFILE ) fileatr( *PF ) +
                     outfile( QTEMP/MYMBRCNT ) +
                     outmbr( *n  *ADD )
    
       ovrdbf      QAFDPHY   tofile( QTEMP/MYMBRCNT )
    
    
       rcvf
       monmsg   ( cpf0864 ) exec( chgvar &inEOF '1' )
    
       doWhile     ( *not &inEOF )
    
          chgvar   &mbrCnt         ( &mbrCnt + &PHNOMB )
    
          rcvf
          monmsg   ( cpf0864 ) exec( chgvar &inEOF '1' )
    
       endDo
    
    dmpclpgm
    
    
       dltovr      QAFDPHY
    
       dltf        QTEMP/MYMBRCNT
    
       return
    
    endpgm


    You could use a variable for the OUTMBR() value that is initialized to '*REPLACE', and change it to '*ADD' after displaying the first one. That could help if you run DSPFD in a loop and want to process a variable number of files.

    The sample code should compile and run on most systems at V5R3 and above. Most systems will have the two example files in QGPL, You can check source files in QGPL to find a couple that have sample members and use whichever file names are available.

    The total count of members should show up in the dump in variable &MBRCNT.
    35,920 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.

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

Following

Share this item with your network: