670 pts.
 Getting the number of records from CL
I want to get the number of records from the CL program.I used the following code however I am getting the error. Please suggest the solution PGM DCL VAR(&RCDCOUNT) TYPE(*CHAR) LEN(10) VALUE('0') RTVMBRD FILE(ATANEJA/SAME1) NBRCURRCD(&RCDCOUNT) SNDMSG MSG(&RCDCOUNT) TOUSR(ATANEJA) ENDPGM Error code is : CPD0783

Software/Hardware used:
AS400
ASKED: November 2, 2012  7:06 AM

Answer Wiki:
Now convert &RCDCOUNT to *Char and use that in the MSG parm
Last Wiki Answer Submitted:  November 2, 2012  12:27 pm  by  CharlieBrowne   32,905 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,905 pts. , ankit2002   670 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

The solution is to follow the instructions from the CPD0783 message. What happens when you do what the message says? — Tom

 108,240 pts.

 

@Tom:

CPD0783 30  Variable &RCDCOUNT for parameter NBRCURRCD must be TYPE(*DEC), LEN(10,0).
 
After getting the above error I changed the code to
 
DCL VAR(&RCDCOUNT) TYPE(*DEC) LENGTH(10 0) VALUE(0)
 
However after changing the type of variable i got the following error:
 
* CPD0776 30  Variable &RCDCOUNT for parameter MSG must be *CHAR.

 670 pts.

 

You’ll pobably need two variables, one *DEC 10 0, the second *CHAR 10
three commands
1.  Get the number of records into the *DEC 10 0
2.  Change the value of the character field to the value in the *DEC field
3.  Send the message
Phil

 44,190 pts.

 

The error messages include the source line numbers where the errors are found. You should be able to see that the two errors are on two different lines. They happen at different times depending on how you define &RCDCOUNT.
 
The RTVMBRD command can only place its numeric results into numeric variables. But SNDMSG can only use character variables for its message text variables.
 
The solution is to have two variables, one for each command. Convert the value in the numeric variable into a character value in a second variable. That will satisfy both commands.
 
Phil gave the basic sequence. BTW, every one of us ran into the same problem when we were learning.
 
Tom

 108,240 pts.

 

PGM                                                       DCL        VAR(&RCDCNT1) TYPE(*DEC) LEN(10 0)             DCL        VAR(&RCDCNT) TYPE(*CHAR) LEN(10) VALUE(’0′)    RTVMBRD    FILE(ARCPGM/BATCHPF) NBRCURRCD(&RCDCNT1)       CHGVAR     VAR(&RCDCNT) VALUE(&RCDCNT1)                   SNDMSG     MSG(&RCDCNT) TOUSR(ARCUSER)                    ENDPGM                                                    Please try this code

 335 pts.