TechTalk: Determining the Number of Records

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Determining the Number of Records

From: Mark Wheeler To: All

I need a program to provide a record count of a physical file member in batch. I have several that will throw a fancy interactive screen up with the record count, but I need one that will use the Send Program Message (SNDPGMMSG) command or write to a data area. I don't feel qualified to write this myself.

From: Ernie Malaga To: Mark Wheeler

Let's suppose your file is named ABC and it contains only one member (as all physical files typically do). Code your CL program as shown in 5.

Let's suppose your file is named ABC and it contains only one member (as all physical files typically do). Code your CL program as shown in Figure 5.

The Retrieve Member Description (RTVMBRD) command can retrieve a lot of information from a database file member into CL variables. Since it returns the number of records into a decimal variable, you must convert it to character before sending its value in a message; that's what the Change Variables (CHGVAR) command does. The two SNDPGMMSG commands I've listed are mutually exclusive. The first one sends the number of records (such as 0000078219) as the entire text of the message. The second SNDPGM-MSG sends a more explicit message, which may be more to your liking. Choose one.


TechTalk: Determining the Number of Records

Figure 5 How to Find Out the Number of Records

 DCL VAR(&NBRRCD) TYPE(*DEC) LEN(10 0) DCL VAR(&RECORDS) TYPE(*CHAR) LEN(10) RTVMBRD FILE(ABC) NBRCURRCD(&NBRRCD) CHGVAR VAR(&RECORDS) VALUE(&NBRRCD) SNDPGMMSG MSG(&RECORDS) / or SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('File ABC + contains' *BCAT &RECORDS *BCAT 'records') MSGTYPE(*INFO) 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$