AS/400 Record Count

39,815 pts.
Tags:
AS/400
AS/400 Records
CL Program
MBR
V5R4
I need a command to use in a CL program that will give me the record count for all records in a file. RTVMBRD will do it for a single member, but I need it for MBR(*ALL).

I know I can dump a *MBRLIST to a file and tally it up form there, but if someone already has this, why reinvent the wheel.



Software/Hardware used:
AS400 V5R4
ASKED: February 28, 2011  7:07 PM
UPDATED: March 1, 2011  2:07 AM

Answer Wiki

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

Thanks Tom
I got impatient and whipped up something myself.
*
<pre>
PGM PARM(&pLib &pFile &pRcdCnt)

DCL VAR(&pLib) TYPE(*CHAR) LEN(10)
DCL VAR(&pFile) TYPE(*CHAR) LEN(10)
DCL VAR(&pRcdCnt) TYPE(*CHAR) LEN(10)
DCL VAR(&vADD) TYPE(*Dec ) LEN(9 0)
/*——————————————————————-*/
/* Build file in QTEMP with Member List */
/*——————————————————————-*/
DltF Qtemp/QAFDMBR
MonMsg CPF0000
DSPFD &pLib/&pFile *MBR OUTPUT(*OUTFILE) +
OUTFILE(Qtemp/QAFDMBR)
/*——————————————————————-*/
/* Call RPGSQLI program to sum(NMBRCD) */
/*——————————————————————-*/
Call GetRcdCntR &pRcdCnt
/*——————————————————————-*/
/* Cleanup after yourself */
/*——————————————————————-*/
DltF Qtemp/QAFDMBR
MonMsg CPF0000
END: ENDPGM

D DS
D vRecCount 1 10S 0
D pCount# 1 10
* Entry Parm list
c *entry plist
c parm pCount 10
*===================================================================
*= Program Logic
*===================================================================
/free
exsr getCounts;
pCount = pCount#;
*inlr = *on;

// ================================================================
// GetCounts
// ================================================================
begsr GetCounts;
/end-free
c/exec sql
c+ select Sum(MBNRCD) into :vRecCount
c+ from QTEMP/QAFDMBR
c/end-exec

/free
endsr;</pre>

Discuss This Question: 2  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
  • TomLiotta
    Maybe you do something like this:
    pgm
    
       dcl   &int         *int           value( 0 )
       dcl   &rtnmbr      *char   10
       dcl   &eom         *lgl           value( '0' )
       dcl   &nbrrcd      *dec (  10 0 ) value( 0 )
    
       rtvmbrd     toml/qclsrc +
                     mbr( *FIRSTMBR *SAME ) +
                     rtnmbr( &rtnmbr ) +
                     nbrcurrcd( &nbrrcd )
    
       dowhile ( *not &eom )
    
          sndpgmmsg msg( 'Counting' *bcat &rtnmbr )
    
          chgvar         &int                    ( &int + &nbrrcd )
    
          rtvmbrd  mylib/qclsrc +
                     mbr( &rtnmbr *NEXT ) +
                     rtnmbr( &rtnmbr ) +
                     nbrcurrcd( &nbrrcd )
          monmsg ( CPF3049 )  exec( chgvar  &eom  '1' )
    
       enddo
    
       return
    
    endpgm
    Does that make sense? Test the logic on something like MYLIB/QCLSRC. It seems to work, but I haven't seriously tested it. Tom
    125,585 pointsBadges:
    report
  • CharlieBrowne
    [...] CharlieBrowne was on other side of the forums with his question on AS/400 record counts, and TomLiotta helped him out with some sample [...]
    0 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