Real usage of RPG is in AS/400. In RPG you can embed SQL statements. Handling strings possible with VARCHAR data type.
What is RPG
RPG is another programming language. Always you need to write naming conventions in Upper case. An example is /INCLUDE
Sample Code of RPG
Read(E) TransFile; // Read file to prime do loop
DoW not %EOF(TransFile); // Continue until all processed
Dsply 'The read failed';
Chain(N) CustNo CustMast CustData;
CustName = %Xlate(Upper : Lower : CustName);
TotalSales = %XFoot(MthSales);
Eval(H) Dividend = TotalSales / 100 * DivPerc;
dcl-Ds APIError lqualified; bytesprovided int(10) inz(%size(APIError)); bytesavail int(10) inz(0); msgid char(7); *N char(1); msgdata char(240); end-Ds;
Sub-routine Vs Sub-procedure
Subroutines are different from sub-procedures, but in a conceptual way they are often interchanged because they provide the same basic function in basic structured programming methodologies. Both provide a way to wrap re-usable code within a container.
- Parameters you can pass in Sub Procedures
- Returned value you can be used in somewhere else in a program
- Sub-procedures act as functions
- IMPORT and EXPORT are two key words you can use a Global variable across sub modules
Use of Sub-routines
- Use of Sub-routines is very less in RPG. Mostly developers use Sub-procedures.
- You can convert your sub-routines into Sub-procedures
- You can access database objects in RPG
- You can embed SQL
- Easy to call Stored procedures
- Apply Triggers
You must be logged in to post a comment.