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
1
vote
1 answer

Significance of SHARE (* YES) in OVRDBF command when used with OPNQRYF

When we do a OPNQRYF in CL we tend to do a OVRDBF with a SHARE (* YES) before that. Can someone tell me the significance of SHARE (* YES) in this regard.
Kunal Roy
  • 729
  • 3
  • 11
1
vote
1 answer

Query on a display file declaration in RPGLE

Recently I have come across as display file declaration as F dspfile CF E WORKSTN maxdev(*file) usropn I have never encountered any declaration like this before. Firstly there is no actual file called dspfile, so I assume this is getting file…
Kunal Roy
  • 729
  • 3
  • 11
1
vote
2 answers

How to call external stored procedure from SQL stored procedure and handle commitment control

I am trying to call a external stored procedure from Sql stored procedure by passing two parameters. one of the parameters is expected to return back with a string value, which when arrives I need to stop the data to be committed in any file. To…
mrsorrted
  • 141
  • 1
  • 8
1
vote
2 answers

Query regarding Expandable subfile against load all subfile

The expandable subfile is pretty much same as the loadall subfile, both having a buffer limit of 9999. The only difference being in case of expandable we have to take care of the page down. My query is if both of them are nearly same then what is…
Kunal Roy
  • 729
  • 3
  • 11
1
vote
3 answers

IBMi STRSEU - Possible to edit stream files (IFS) directly?

On an IBMi system, STRSEU can only work with source members, right? No ability to interact with stream files directly. Just thinking in the context of tracking RPG/CL/DDS source behind Git as stream files. Assuming one wanted to use STRSEU, I can…
d.lanza38
  • 2,525
  • 7
  • 30
  • 52
1
vote
1 answer

Cannot call .Jar file from RPGLE

I've created an RPGLE program and I'm trying to execute a java .jar file from within. I've been able to get it to run from the QSH so I know it compiled and runs fine, but I need to run it from the program not QSH. Here is the code I have…
wendy
  • 21
  • 1
1
vote
1 answer

SQLSTATE and SQLCODE usage in SQLRPGLE

In SQLRPGLE programming I have seen that the SQLSTATE and SQLCODE being used in several areas in order to catch an error in the sql statement. My query is what is the difference between SQLSTATE and SQLCODE because I see them to be used for similar…
Kunal Roy
  • 729
  • 3
  • 11
1
vote
1 answer

The modulo in RPG 4?

Anyone know how I could do a modulo, please in RPG IV? I tried %2 = 0 but it's not exact! If you have a solution, I'm interested. dcl-s slash varchar(20); dcl-s antiSlash varchar(20); dcl-s i packed(3:0); dcl-s j …
solange
  • 103
  • 1
  • 1
  • 6
1
vote
1 answer

How to process a SUBFILE using For Loop with a CHAIN rather than using READC and SFLNXTCHG

How to process a SUBFILE using For Loop with a CHAIN rather than using READC and SFLNXTCHG. Readc along with the Sflnxtchg option sometimes becomes a bit complex to understand , I have heard that instead of that a forloop and chain combination can…
Kunal Roy
  • 729
  • 3
  • 11
1
vote
1 answer

Parsing XML response of SOAP web service with RPG and HTTPLIB

I want to parse this xml response with ILE RPG (Fully-Free RPG) in a data structure with a field for currency and a field for the value. Thats my response from soap webservice:
nicowi
  • 470
  • 2
  • 4
  • 15
1
vote
1 answer

Dynamic record duplication in IBM DB2 SQL

I need to duplicate one line of a specific table, but in same duplicated line I have to change the primary key. In my case the primary key is a three digit year. Example: this year would be 221, next year 222. I'm using a record with a primary key…
Zlimca
  • 23
  • 5
1
vote
1 answer

What is the best practice for retrieving DB2 records in an RPGLE program that originally used a multiple-format logical file?

I will be rewriting an old Inventory Transaction program written in RPGLE. It's a really old program that doesn't use subfile capabilities, but writes the data to an array and has output specs specified within the program. It is all GOTO logic. In…
Michael G
  • 11
  • 1
1
vote
1 answer

RPGLE prepare statement throwing SQLSTATE=42601

I'm trying to use prepared statements in SQLRPGLE but it's not working. Here's my RPGLE program. * TR * 01/10/21 - CREATION ************************************************************************** * Extraction RCPENT dans Excel …
1
vote
1 answer

-7008 error in sqlrpgle even though commitment control is set to *NONE

I have an SQLRPGLE program that performs a delete operation using exec sql. The problem is I get an sqlcod of -7008 even though I have compiled the program with commit set to *NONE and also, I tried adding "with none" at end of the statement but…
theju112t
  • 37
  • 9
1
vote
1 answer

How to add prefix to MQ RFH2 Property Name using MQSETMP API form RPGLE?

Faced a problem. I need to place an RFH2 message into MQ with Properties in the header. If using the MQ API: MQCRTMH MQSETMP MQPUT then everything works as long as the name Property does not contain a prefix (for example, 'Property1') - WRKMQMQ…