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 can I get the EBCDIC value of a character in RPGLE?

I need to have some way of converting single characters in RPGLE into integers - does anyone know a good way? It has to work for all possible inputs and ideally provide a different integer for each input - at the very least it must provide a…
tarQuils
  • 41
  • 1
  • 2
4
votes
4 answers

External stored procedure on IBM i

I am trying to create an external stored procedure on an IBM i (V5R4), but I'm getting an error when I try to run it. All I want to do is call an RPG program, without passing any parameters or worrying about returning any data. Sorry, I'm not an RPG…
Eugene M
  • 1,307
  • 2
  • 15
  • 22
4
votes
5 answers

How long can memory leaks persist in RPGLE programs?

I'm putting into production some RPGLE code which uses %alloc and dealloc to allocate memory. Programmers should be able to ensure there are no resulting memory leaks but I'm worried about what happens if they don't. My question is: if programmers…
Tarquila
  • 1,167
  • 3
  • 11
  • 17
4
votes
2 answers

What should be my standard choice of integer type in RPGLE?

When I want an integer in an RPGLE program, what data type should I choose? I'm talking about an integer that doesn't correspond to any field in the database, just a normal general purpose integer - kind of the equivalent of an int in Java.
ppQuentin
3
votes
2 answers

Why the OPTIONS(*TRIM) doesn't work as IBM says, what's missing here?

**free ctl-opt main(main); dcl-pr main ExtPgm('TSTPGM'); *n char(10) const options(*trim); *n char(10) const options(*trim); end-pr; dcl-pr ExecCmd Extpgm('QCMDEXC'); Command Char(40); CmdLen Packed(15:5); end-pr; dcl-s str0 …
ojay
  • 91
  • 6
3
votes
2 answers

slow performance of fetch cursor into array in rpgle

I have this relatively simple rpg program where the line exec sql workKeySocWorkCodesCur for 500 rows into :childWorkKeyArray; is performing very slowly. It tales about 6 seconds to execute each time. What I dont understand is when I run this query…
Theju112
  • 185
  • 7
3
votes
1 answer

I have a PF , how to get the list of programs that is using that particular PF?

I have a specific physical file. How do I get a list of programs that is using that PF. Is there any command (or native utility) in AS400 which can fetch that list and give that in an outfile ?
Kunal Roy
  • 729
  • 3
  • 11
3
votes
0 answers

Program Name in audit fields

Hey hoping someone can assist or at least point me in the right direction. I'm looking to add some Generate always audit fields into some of our new tables to assist in the auditing process, from what i have found only special registers can be used…
3
votes
1 answer

Locking issue with calling programs

I have pgmA which calling by 50 programs.pgmA has detail file in input mode..some of the 50 calling programs has detail file in update mode .as per new requirement, I will get the detail file records in PGMA in XML format..that needs to be breaked…
Sam K
  • 103
  • 4
3
votes
1 answer

Using one Message Handle for several MQ message cause memory leaks?

Has anyone worked with MQ from RPG? The problem is as follows. There are several messages in the queue. All of them are with RFH2 header. Each header contains a set of NameValueData. I am creating a Message Handle and passing it to MQGET. Then I…
3
votes
1 answer

Is CALLP also a dynamic call or can be considered as static call in ILE RPG

I have a module which has main procedure and sub procedures in it, the other scripts are using EXTPGM to call modules but few scripts are not using EXTPGM they are using CALLP, can anyone help me in understanding whether CALLP is dynamic call or…
mrsorrted
  • 141
  • 1
  • 8
3
votes
2 answers

Run time screen input fields

I have a RPGLE program to display and or update a random file chosen by the user. Similar to parts of DBU. I can get all the fields for a file and their definitions when a file is selected. At run time, how do I display an input capable field on the…
Marc
  • 31
  • 2
3
votes
1 answer

How to get the list of programs and service program have binded a given RPGLE module for a specific library

Suppose i have a Rpgle modle name and a library name. How do i find out for that library list what is the list of programs and service programs that module is binded to.
Kunal Roy
  • 729
  • 3
  • 11
3
votes
1 answer

Why is *inlr (last record indicator) switched on at the end of the rpgle program

*inlr (last record indicator) switched on at the end of the rpgle program. What is the main reason for switching on last record indicator. What will happen if this indicator is not switched on.
Kunal Roy
  • 729
  • 3
  • 11
3
votes
1 answer

What is the difference between CPYF and CRTDUPOBJ in regard to a Physical/ Logical file?

What is the difference when we use CPYF on a Pf/Lf and in case when we use command CRTDUPOBJ on PF/LF.
Kunal Roy
  • 729
  • 3
  • 11
1 2
3
45 46