Even if the entire application is eventually rewritten in C/C++, I think that converting to free-form ILE RPG is a necessary first step. The converted code would be much easier to understand and modify. Also, I think it would be easier to change monolothic RPG programs into more modular function-based RPG code than to go straight to a modularized C/C++ application. Moving RPG code out of a program into a function is a relatively simple thing to do, and any problems discovered in testing can be blamed on the change to use a function. If the change also involved writing that function in C/C++, it would be much more difficult to determine why the testcase had failed.
That said, I don't think there is anything that can be done in RPG that can't be done in C/C++, but some things that are easy in RPG are more difficult in C/C++. For example, #pragma mapinc must be used to get the layout of the records for externally-described files, but that is practically automatic in RPG: it is the default behaviour for a free-form file deifnition, and it only needs one byte ('E' = Externally-described) in the fixed-form file file definition.
There are some things that almost seem like magic to people who are not familiar with RPG, such as the way all the fields in a file are automatically available as program variables, which are automatically set from the I/O buffer during a READ operation, and automatically copied into the I/O buffer during a WRITE or UPDATE operation.
For example, this program reads the records from an imaginary database file, puts up a screen showing the current values of the fields, and then updates the database record with the changes from the user.
Rewriting this program in C/C++ would require many more lines of code.
dcl-f dbfile usage(*update); // Database file opened for update
// All the record formats are available (DBFMT)
// All the field names are available as program variables
// (FIRSTNAME, LASTNAME, ADDRESS, CITY, COUNTRY)
dcl-f screens workstn; // Display file opened for input/output
// All the record formats are available (SCREEN, ...)
// All the field names are available as program variables
// (FULLNAME, ADDRESS, CITY, COUNTRY)
read dbfmt; // Read the first database record
dow not %eof; // Do while not end-of file
fullname = %trim(lastname) + ' ' + %trim(firstname);
exfmt screen; // Interact with the user (WRITE + READ)
update dbfmt; // Update the database record with the values
read dbfmt; // Read the next record
enddo;
*inlr = *on; // For a "cycle-main" procedure,
// this causes files to be closed, set things up so everthing
// gets re-initialized for the next call, and returns from
// the program
------------------------------
Barbara Morris
------------------------------