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
4
votes
2 answers

How to move a DB2 SQL result table into a physical file?

I would like to get the result table from a SELECT statement, and then move it into a physical file. I was hoping to use (per W3Schools): SELECT column_name(s) INTO new_table_name [IN externaldatabase] FROM old_tablename Unfortunately per the IBM…
Christoff Erasmus
  • 925
  • 1
  • 10
  • 26
4
votes
2 answers

How to get the length of character type variable in RPGLE?

Is there any easy way to directly return the length of character and type variable in RPGLE? The length I am talking about here is not the length specified in the D-spec. I am talking about the actual number of meaningful characters in a string.…
God_of_Thunder
  • 753
  • 3
  • 20
  • 46
4
votes
1 answer

Is there way to trap QCMDEXC error in an RPG program other than using MONITOR

I have issued a CL command in a RPGLE program using the QCMDEXC api. Suppose the CL command throws an error. Is there any way of capturing the error without using the MONITOR.
Kunal Roy
  • 729
  • 3
  • 11
4
votes
2 answers

Converting C prototype to RPG

I am trying to use QsyFindFirstValidationLstEntry in RPG, however despite being sure of the existence of the validation list I am getting error 3025, which according to documentation means "The validation list object was not found." The only thing…
Peter
  • 400
  • 1
  • 13
4
votes
1 answer

Problems with SQLRPGLE and CCSID in JSON_TABLE

I have a problem with one program, and it is related with the Source File CCSID. I need to generate a JSON field. In the original program, it was an INSERT from a common table (with diferent columns) into a column in a table, defined as CLOB to…
Íñigo
  • 63
  • 3
4
votes
1 answer

How to decrypt zip file programmatically in as 400 using RPG/RPGLE?

Is is possible to decrypt a zip file in AS 400 with password using RPG/RPGLE? Which library I should use? Is there any example?
4
votes
0 answers

ANTLR4 getCharPositionInLine() not working as intended in LEXER rule

ANTLR Grammer: grammar Test; /* * Parser Rules */ rpg_file : f_section EOF? ; f_section : f_line* ; f_line : f_start f_content f_end ; f_start …
ealagic
  • 51
  • 1
4
votes
3 answers

Getting a return value from a called program back to main routine in rpgle

I'm trying to get experience in RPGLE and IBM i stuff and constantly learning. Since most code in the wild seems to be classic positional, I'll stick with this to get used to it. So I would rather not use /free — /end-free stuff. Incidentally, I'm…
PoC
  • 521
  • 3
  • 13
4
votes
2 answers

passing optional parm between programs in AS400

I have a PGMA(RPGLE) which is called from PGMB(CL) and PGMC(CL). PGMB calls PGMA with 2 parms while PGMC calls PGMA with 3 parms. How do I deal with this in PGMA. I tried options(*Nopass) for the third parm(which is optional) but that is only for…
AS400 User
  • 187
  • 2
  • 14
4
votes
2 answers

How to Call RPGIV program from java that returns more than one record

I am calling a RPGIV program from java, the rpgiv program returnes multi record as an output parameter. I tried the following to return all the rows returned from rpgiv. // Define Output Data Structure AS400DataType[] outputData = { …
Renier
  • 1,738
  • 3
  • 24
  • 51
4
votes
4 answers

What is IBM i (AS400) record format

I've started to do some programming in ILE RPG and I'm curious about one thing - what exactly is the record format? I know that it has to be defined in physical/logical/display files but what exactly it does? In an old RPG book from 97 I've found…
h00jraq
  • 85
  • 1
  • 8
4
votes
4 answers

Data structure definitions / templates in RPG(LE)

Say I have a data structure, such as d dog DS qualified d name 20 d breed 20 d birthdate 8 0 I can then define d poochie …
nearly_lunchtime
4
votes
6 answers

Accessing RPG on iSeries from Java

Has anyone had good experiences of talking direct to RPG programs running on a V5R4 iSeries machine from Java? If so, what are the recommendations of the community, and what pitfalls should I try to avoid? From the various pieces of literature and…
lawsonj2019
  • 163
  • 2
  • 6
4
votes
2 answers

RPGLE Print to command window

hope someone can help me. I cannot see the DSPLY 'some text' output from my RPGLE program in the command window. I am using IBM Websphere development studio client for iseries to create a simple RPGLE program. I can compile the program with no…
Derick
  • 43
  • 3
4
votes
2 answers

CPF4131 appeared during OPEN for a file

What are the possible reasons for CPF4131 to be appearing on a file in a program. And how do we go about resolving this? Message . . . . : Error message CPF4131 appeared during OPEN for file TEST (C S D F). Cause . . . . . : RPG procedure…
learning_fly
  • 382
  • 1
  • 2
  • 11
1
2
3
45 46