Beginner RPG IV help needed

505 views Asked by At

So I'm learning RPG IV just because I want to... and I'm having trouble finding code examples that actually make sense. Right now I'm at an exercise in the book that I have no idea how to complete.. Would anyone be able to take a look and give me some steps or advice on how to do this?

This is the exercise in the book:


Assignment


This next one is the externally described file that needs to be used in the exercise:


enter image description here


Can anyone help with this?

1

There are 1 answers

1
Bbb On

Read the book. I know the books can be difficult to follow along and never contain enough examples.

First check the data that's in the Before WUEXAMP and see data that in there. This is know if you will have to manipulate any of the data and check for verification for the data. For example you would wand grades that contain 999 and negative values.

After you know what kind of data you are working in, create pseudocode. This will help out and avoid logical errors in the future. Plus, this is a great habit to get into.

Luckily this is a mostly simple report. Declare all Variables. In your basic logical this should be in the loop While not

         WRITE HEADINGS;                       //Excepts Defualt Headings
         READ  LAB05LF;                        //Read File
         DOW NOT %EOF(WUEXAMP);                // Begin Loop  While not end of File of WUEXAMP
           If  *in10 = *on;                 // Over Flow Indicator = True
             Write  Headings;                  // Write Headings On Next Page 
             Eval   *in10 = *off;              // Overflow Indicator  turned off
           Endif;   
           EVAL AVGGRADE = (Exam1 + Exam2 + Exam3 + Exam4 + Exam5 ) /5;
           EVAL CLASSTOT += AVGGRADE;
           EVAL Count +=  1;
           Write Details;                       // Write record to output 
           READ WUEXAMP;                       //Read next Record
         ENDDO;       

After the loop:

          EVAL CLASSAVG = (CLASSTOT) / Count;  // Calculate Class Average
          Write GrandDTL;                   // GrandDTL a the record name with ClassAVG

Make sure to have the rest of the basics. Name things accordingly. Instead of Write it should be Except if your records are internally described in O(output ) specs

Common Errors:

 /FREE

and

 /FREE-END

The '/' should be placed in the 7th column. None of the code within the free should be before the 8th column.

Check Chapter 2 for a completed program example of that book. (Programming in RPG IV by Jim Buck) There aren't many examples of RPG programs out there.

Useful links for the future. http://www.jaymoseley.com/hercules/rpgtutor/rpg002.htm#FileDescription http://www.jaymoseley.com/hercules/rpgtutor/rpg011.htm

Good Luck and always comment and document your code.