In this tutorial we focuses on compiler errors in RPGLE, how to find compiler errors using spooled files and correct them.
This is the second tutorial of the set of RPGLE Free format Tutorial. If you have not completed first tutorial of Hello World RPGLE Tutorial, I strongly suggest you to go through it because this part is linked with it.
Lets edit our source again, and change it as follows instead of displaying ‘Hello World’, it tries to display a variable called “name“. This is an undefined variable and generates a compiler error.
Delete the old version of the program by using the DLTPGM command
Make sure to put your library to library list or set it as current library. otherwise you have to specify which library your program is in. Learn more about library list >> Library List
Compile the program again. It fails with a severity 30 compiler error.
If you are using IBM RDi, for edit RPGLE click the RNF7030 error in the Error List Window. It highlights the line that tried to display the “name” variable.
If you are using SEU, use the WRKSPLF command to see the list of spooled files. use F18 (SHIFT + F6) to go to the bottom of the list.
If you are not familiar with spooled files, go through WRKSPLF – Work with Spooled Files. It explains all about spooled files with examples.
Find Compiler errors in Spooled Files
Use option 5 on the HELLO spooled file and use the B command to go to the end of the listing.
Page up a bit until you find the list of the compiler errors , then take note of the error message id with the highest severity. In this example it’s RNF7030
Return to the beginning (command T on control) of the file and enter RNF7030 on the search line, then hit F16 (SHIFT + F4) to locate the compiler errors in the listing.
The compiler error message has a statement number (statement 2) and the error message is “The name or indicator NAME is not defined“.
Page back in the listing to find statement 2 (on the left side of the listing). It is the line that tried to display the “name” variable.
The compiler error message indicates that NAME is not defined. To correct it, you have to add a definition for a variable called NAME. RPG IV is not case-sensitive for variable names, so variable “name” is the same as variable “NAME“. The uppercase form of the name appears in the listing in error messages and the cross-reference.
Correct compiler errors and compile program
Move back to Program Development Manager (PDM) pressing F12 twice or using WRKMBRPDM command.
If you want to learn most useful AS400 commands, you can follow this article which list 23 most useful AS400 commands.
Open program in SEU using option 2 and add the following dcl-s statement to the beginning of your program to define variable “name“. Remember to code only between columns 8 – 80.
dcl-s name char(10) inz('Corona');
Warning: SEU gives errors for every free-form H, F, D, or P statement Therefore RPG syntax checker used by SEU was last updated in 6.1, so it does not understand the new syntax. If you still want to use SEU, you have to exit with errors after you save your source.
If you got an error like “An assignment operator is expected with the EVAL operation“ that because SEU does not understand the new syntax of RPGLE free format. you have to exit with errors after you save your source. anyway the compiler will not give any errors and it will run without errors.
Recompile the program and call it again. It puts up a message saying “DSPLY Corona“.
That is the end of compiler errors – RPGLE tutorial. In next chapter we can focus on debugging RPGLE programs.
Source : IBM Developer Portal