Simple RPGLE Program (Hello World)
Create a member “helloworld” in your working source physical file. Give the type of this member as “RPGLE”. Now type the following code in the source member.
Now compile the module. Create the program and call it, It Will display the phrase Hello World.
That is a basic RPGLE program but you learn several things as discussed below.
- The C specs is mentioned on the 6th place. Other specifications are also specified at this place only. Other specifications are H, F,D, I and P. (Specifications O and E are RPG specifications)
- The text Hello world is written at ‘Factor one’ position. i.e at the 12th place. At this place we specify the factor one of any operation code in RPGLE. You will use this factor frequently for declaring keylists of file and defining parameter list.
- The Op codes in RPGLE. The opcodes are placed at the position starting from 26. In the example above we have used two opcodes dsply and Return.
- Dsply – This opcode is used to display any text as the output. The program does not stop execution but halts for a small time. When you press the return key. The subsequent statements are executed. This opcode can be used to display a text of maximum 52 length.
- Return – This opcode is a required keyword. When the program runs this statement, it terminates its execution and returns to the calling program immediately. In the example above the caller is the system as we have called this program from command line, hence the program will end when it executes the return statement.