Why do I need numeric constant?

45 views Asked by At

I'm extremely new to RPGLE and I'm getting some errors like:

The length parameter must be a numeric constant between 1 and the maximum for the type. (20).

on all of my zoned variables. And I'm getting

The Factor 2 operand is not valid for the specified operation. (30).

On my Write ClassAverage; What is factor 2 operand?

**FREE

dcl-f wuexampl1 Disk Usage(*Input) ;
dcl-f ch6print printer Usage(*output);

dcl-s Totalscore zoned(3,0);
dcl-s FIN char(1);
dcl-s RecordCount zoned(2,0);
dcl-s AverageScore zoned(3,0);
dcl-s ClassAverage zoned(3,0);



Write HEADER;
Read EXAMREC;
DOW Not %eof(wuexampl1);
    AverageScore = (Exam1 + Exam2 + Exam3 + Exam4 + Exam5) / 5;
    Totalscore += AverageScore;
    FIN = SFNAME;
    RecordCount += 1;
    Write DETAIL;
    Read EXAMREC;
enddo;
    ClassAverage = Totalscore / RecordCount;
    Write ClassAverage;

*inlr = *on;
return;
1

There are 1 answers

2
Charles On

The length parameter must be a numeric constant between 1 and the maximum for the type. (20).

RPG uses : not , as parameter separators, try

dcl-s RecordCount zoned(2:0);
dcl-s AverageScore zoned(3:0);
dcl-s ClassAverage zoned(3:0);

The Factor 2 operand is not valid for the specified operation. (30).

In RPG, you write Record Formats (if multiple formats in a file, ie. Printer files) or Files (if a single format DB file), not individual fields.

Instead of

Write ClassAverage;

You need to write the appropriate record in the ch6print file. You're successfully writing HEADER, DETAIL, there's probably a TOTALS or AVERAGE record.