Question

I want to learn some RPGIV. I do not have much understand of the language. I am looking for a free online resource, so far I have just found sites where I have to pay.

Reason why I would like to learn, is we are using a RPG function that calls a web service. It is giving a general Internal Server Error 500. So I want to learn RPGIV so I can ask the right questions, and resolve this.

Was it helpful?

Solution

This is a very broad question. The usefulness of the answer will increase if you could explain a little bit about why RPG IV and what you will use it for.

Unlike Java or C++, there aren't any PC-based compilers for RPG IV. RPG IV runs only on the IBM midrange series of computers, so it would be necessary to have access to one in order to try out any code. Holger Scherer has a public machine available; there may be others but it's a thin market.

Generally speaking, it isn't enough to learn RPG IV. In order to be able to be useful on a midrange computer you'll also need to understand DDS and CL at the barest minimum. Along with those, you should learn some rudimentary work management concepts like finding which output queue your compiler listings went into, how to submit a job to batch (and what 'a job' is!) and how to use the library list. I'd also strongly suggest learning about ILE as well. The built-in database is a DB2 variant; a beginning programmer won't be concerned with creating a database so much as understanding how it is already built, how the various tables relate to each other. This is strictly dependent on the database, on the business which designed it. As a programmer, you'll be using embedded SQL, so look at that manual as well as the SQL programming and SQL Reference manuals.

EDIT:

RPG IV is not that difficult to understand if you're reading it. Writing it is a bit more work :-) Plus, it sounds as if you have a local source who can walk you through some of the parts that might seem strange. My immediate advice is to put the RPG IV program into debug and watch what goes back and forth. (STRDBG) Compare that against whatever example the web service author provides (in Java, maybe?) and see if the HTTP request is somehow malformed.

Since this question is about learning RPG and not debugging a 500 error, I'll stay focused on the learning aspect. If you want help with the debugging, start a different question and post the relevant code. The way to get to the code is to DSPPGM on the RPG IV program and look for the module(s) that comprise it. Display the details of the module (option 5) and keep track of the source file, library and member names. Then, WRKMBRPDM on the source file and library and out the source member name in the 'Position to' field in the upper right. Press Enter and that source member will be at the top of the list. Use option 5 to Browse the source member.

Very briefly, F-specifications describe the tables the program will use. RPG uses files with operation codes like READ, WRITE, EXCEPT, UPDATE. If the program uses embedded SQL, there may be tables that SQL uses in addition to the ones RPG uses. You'll see those specified on an EXEC SQL statement.

D-specifications describe all the working variables, including individual variables, arrays and data structures.

C-specifications are where the actual calculations take place. These are considered deprecated by those who use /free form calculations but you may encounter them. Fixed form C-specs are columnnar; specific columns mean very specific things. The most important columns are Factor 1, Opcode, Factor 2 and Result. A typical calculation in this style might be BUFFERLEN ADD 1 BUFFERLEN which increments the variable BUFFERLEN by 1.

A variant of fixed format C-specs is extended Factor 2. The same calculation would look like this (empty factor 1) EVAL BUFFERLEN = BUFFERLEN + 1. This will make more sense when you see it in the code.

Free-format calculations don't care about columns at all. The above calculation would look like BUFFERLEN += 1; or BUFFERLEN = BUFFERLEN + 1;

O-specifications describe how internally described output is produced. This is typically for printed reports, but you might encounter a case where the actual file output is described here.

Subroutines are self-explanatory. Sub-procedures might require a bit of explanation. These are basically function calls. PR specs describe the prototype so the compiler will be able to type check the variables, and PI specs describe the actual procedure. Variables declared within a procedure (on D-specs) are local to that procedure. You might encounter procedures that are not contained within the RPG program source, but instead are bound into a service program. You will be able to see those in the DSPPGM.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top