Questions tagged [rpgle]

RPGLE is a high-level programming language (HLL) for business applications for programs running in the Integrated Language Environment (ILE). IBM is the creator of RPGLE. Use this tag for all questions about RPG IV and free format RPG. Use the RPG tag for questions about older versions of RPG and non-IBM variants of the language.

The latest version of RPG is RPG IV (aka ILE RPG) on IBM's Power i servers; it inherits the System i Integrated Language Environment’s features such as prototyped functions and procedures, static and dynamic binding, access to C routine libraries, dynamic link libraries, and fully recursive and re-entrant modular code.

RPG (also called RPG IV and RPGLE) is a popular programming language of the IBM Power i platform. Originally created as a report writer tool to replicate card processing on the IBM System/3 in the early 1960s, RPG has since evolved into an HLL equivalent to COBOL and PL/I.

An RPG program typically starts off with File Specifications, listing all files being written to, read from or updated, followed by Data Definition Specifications containing program elements such as Data Structures and dimensional arrays, much like a "Working-Storage" section of a COBOL program or var statements in a Pascal program. This is followed by Calculation Specifications, which contain the actual meat of the code. Output Specifications can follow which can be used to determine the layout of other files or reports. Alternatively files, some data structures and reports can be defined externally, mostly eliminating the need to hand code input and output specifications.

In the early days of RPG, its major strength was known as the program cycle: every RPG program executes within an implied loop, which can apply the program to every record of a file. At that time each record (individual punched card) would be compared to each line in the program, which would act upon the record, or not, based upon whether that line had an "indicator" turned "on" or "off" — from a set of logical variables numbered 01–99 for user-defined purposes, or other smaller sets based upon record, field, or report processing functions.

Alternatively, the cycle can make an interactive program continue to run until explicitly stopped.

Today, most RPG programmers avoid using the cycle in favor of controlling the flow of the program with standard looping constructs. The concept of level breaks and matching records is unique to the RPG language. It was originally developed with card readers in mind.

686 questions
2
votes
2 answers

How can I control multiple subfiles on the same screen?

I am having issues with multiple subfiles on the same screen. I display two subfiles horizontally and I am only able to use page up and page down on the one that is loaded in second. I read somewhere that you can change the "active" subfile but…
Nate Huff
  • 55
  • 1
  • 6
2
votes
2 answers

Risk of SQL injection when connection to AS/400 using JTOpen

We are using JTOpen to connect to our AS/400 machine, and I'm trying to work out the risks of having SQL injection vulnearbility when using this type of integration. Note that we are only using the call program part of the API - not the jdbc…
Ståle
  • 21
  • 2
2
votes
1 answer

How to display messages from a message file on a display screen using RPGLE?

I have designed a screen using SDA in AS/400 that takes an ID number as input and searches in two PFs for that ID and displays corresponding values fetched from those PFs in the respective fields on screen. Below is the DSPF code: A*%%TS SD …
Rahul
  • 143
  • 1
  • 17
2
votes
1 answer

ILE RPG Static SQL Fetch first row of a cursor

My Code: EXEC SQL DECLARE C1 CURSOR FOR SELECT * FROM a WHERE :field LIKE CONCAT(TRIM(a.number), '%') ORDER BY a.number DESC; EXEC SQL OPEN C1; EXEC SQL FETCH C1 INTO :a; I need only the highest number…
nicowi
  • 470
  • 2
  • 4
  • 15
2
votes
1 answer

AS400 File Format Level Identifiers keep changing

I have this strange issue where I get a level check error when running a program. And I rectify the issue by recompiling the file and program. I use DSPFD to check the format level identifier for the file and DSPPGMREF to check the format level…
Javed Ali
  • 1,510
  • 2
  • 12
  • 18
2
votes
1 answer

AS400 Physical File Record Last Updated Timestamp

I am trying to add a last updated timestamp to an old physical file on an AS400. This physical file is written in DDS. I have added in the timestamp field but I cannot get it to automatically update to the current timestamp when the record gets…
jallen3095
  • 65
  • 1
  • 7
2
votes
2 answers

Ordering by sub string of a field with OPNQRYF

I have a requirement where I need to change the order in which records are printed in a Report. I need to order the records by a substring of a field of the records. There is an OPNQRYF as below before the call to the report RPG is made: OVRDBF …
theju112
  • 91
  • 1
  • 10
2
votes
2 answers

How to create a multiple record format DDS

Can anyone tell me how to create a PF with more than 1 record? I tried the following: A************************************************************************** A* Physical File …
Radinator
  • 1,048
  • 18
  • 58
2
votes
2 answers

Encode characters into character entities for XML

I have a variable defined as: D content 1280A CONST I need to find the ", &, ', <, > characters and replace them with: ", &, ', <, and > respectively. I've seen some XML functions in the language but these…
Quaternion
  • 10,380
  • 6
  • 51
  • 102
2
votes
4 answers

Remove the unused indexes from RPGLE Array

I have a RPGLE subprocedure that returns an array of dim(100) as output. When the array is not filled completely, I am seeing the blanks in unused indexes. I need to get rid off those trailing blanks and return only the array indexes with values.…
Sadam Husain
  • 41
  • 1
  • 8
2
votes
1 answer

What is the easy way to parse an XML In a stored Proc/SQLRPGLE ? Can I use XSLT in Iseries ?

I have a Stored procedure which receives input as XML. What I need to do it to create the XML into another form which is Suitable for Another system(with the data from the input XML) I figured out 2 options to do this but both are laborious. 1.…
AS400 User
  • 187
  • 2
  • 14
2
votes
3 answers

Does seting *inlr in non-cycle programs has any effect?

I have recently stumbled on a service program in which *inlr = *on is used after explicit close of a file (code below). It feels rather excessive for me. From what I have found it is rpg cycle that handles releasing of resources. So if there is no…
ime
  • 23
  • 2
2
votes
5 answers

Have SQL UPDATE throw error message on record lock like native IO does

I'm somewhat new to the IBM i and I come from a Java / C# background. So if I use the wrong jargon please correct me. We are currently on IBM i 7.1 and will be shifting to 7.3 within the next year. I've been tasked with updating records in a file.…
MetaWood
  • 21
  • 2
2
votes
2 answers

Punctuation in Java source changed to accented letters when copied to IFS

I am trying to run a RPGLE program which use java methods. I am transfering the java code (xxxx.java file) from my system(Windows XP) to the AS/400 IFS directory through FTP. After transfering it to IFS, the file CCSID is shown as 819. I am…
Nirmal
  • 115
  • 1
  • 1
  • 6
2
votes
3 answers

How do CL commands build their exact parameter lists?

I have a CMD command object that drives an RPGLE program. Because the command may be called with several different parameters, some of which are mutually exclusive, I parse the parameter passed by using a data structure in the RPGLE so I can handle…
Mike
  • 1,274
  • 10
  • 24