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
3 answers

How to subdivide the contents of a string variable based on a certain symbol in the content of the variable in RPGLE

Suppose I have a string variable in RPGLE . The content of the variable is "Hi;this;is;Kunal;Roy". How do I split the contents of the string based on the symbol ; I want to have the values Hi , this, is , Kunal , Roy separated and stored in some…
Kunal Roy
  • 729
  • 3
  • 11
2
votes
2 answers

How to find the length of the content of a string variable in rpgle?

Suppose I have a variable called VAR of size 50 character. This variable stores different vales at different instance of a loop. I want to know the length of the content it stores. Suppose in one instance it stores "My name is Kunal" in this…
Kunal Roy
  • 729
  • 3
  • 11
2
votes
1 answer

How to use QDFRTVFD API in RPGLE program to fetch heading in a display file

How to use QDFRTVFD API in RPGLE program to fetch heading in a display file. Can some one provide me with RPGLE examples which uses this API to fetch heading from a display file.
Kunal Roy
  • 729
  • 3
  • 11
2
votes
2 answers

Convert to full free format Datastructure with fixed positions

i'm converting a program to full free format but don't know how to replace a data structure with fixed positions. and i cant find a good example online also. i have 2 data structures like below. i tried dcl-ds bl dim(12) bl01 char(7); bl02…
WouterV
  • 133
  • 1
  • 11
2
votes
1 answer

Edit sqlrpgle file over ftp with vim

I'm having an issue with vim while I'm trying to remotely edit a sqlrpgle file in AS/400. I'm using the next command to open the file in vim: :e ftp://myusername@mydomain/mylibrary/mymember.myfile The file opens up but is filled with @ characters…
Mariela
  • 134
  • 2
  • 13
2
votes
1 answer

Can you use RPG to append additional lines to a printer file?

Is there a way of appending additional lines to the end of a printer file? Most of the techniques that I have used to create printer files (RPG O specs, write to externally defined file) cause you to have one output file per program. I would like…
Mike
  • 1,274
  • 10
  • 24
2
votes
1 answer

DB2 SQL How to get the last executed SQL-Statement with GET DIAGNOSTICS?

I want to call a procedure in RPG on IBM i with SQLSTATE and with a variable text. getSQLMessage(SQLSTT: text) The variable text should be the last executed sql statement before the procedure call. Is there a opportunity to get it like this: EXEC…
nicowi
  • 470
  • 2
  • 4
  • 15
2
votes
3 answers

How to find sub-procedure usage in RPG on IBM i?

If I have a service program with a single module which contains three sub-procedures. Is there a way to programmatically find the usages of the individual sub-procedures within a library/file? So something like this: MYLIB/MYSRVPGM <-- My service…
d.lanza38
  • 2,525
  • 7
  • 30
  • 52
2
votes
1 answer

How to loop X amount of times in RPG free without creating variables?

I have piece of old code that I am trying to convert Very simple, just loops 10 times C DO 10 C* code C ENDDO In order to use for loop in free syntax, a variable needs to be created. For example: FOR I…
Ruslan
  • 1,919
  • 21
  • 42
2
votes
1 answer

How do I go to next element in a loop in RPGLE?

Let's say you have the following code: FOR I = 1 to 10; // some code here ENDFOR; How would you skip over an element? Currently using GOTO works, but I do not like that solution. For example: FOR I = 1 to 10; IF I = 4; C …
Ruslan
  • 1,919
  • 21
  • 42
2
votes
5 answers

How to cast hex data string to a string db2 sql

How would you decode a hex string to get the value in text format by using a select statement? For example my data in hex is:…
Renier
  • 1,738
  • 3
  • 24
  • 51
2
votes
1 answer

How to fix "dont get a clear Array after a Programm Call"

I have written a Programm to encode some Strings. I write a 2nd Programm to call this encode-Tool. Here i create a Array (A_FELDER) and fill it with some Text. In the following Point 1 you can see my encode-Tool. In Point 2 you cann see the…
Dominik
  • 62
  • 8
2
votes
1 answer

Dynamic datastructure array for storing large data

I read an article about Dynamically Sized Arrays on ITJungle and was wondering if this is not an "making easy thing much more complex" thing. So as I understand if I define an static variable, including arrays, the runtime reserves the needed space…
Radinator
  • 1,048
  • 18
  • 58
2
votes
2 answers

Reading Multiple Files from IFS

I have a IFS file location where I have multiple inbound files from external system. There are Item related files which has a naming of ITEM_DDMMYYHHMMSS and customer related files as CUST_DDMMYYHHMMSS. There would be multiple files and my Item…
AS400 User
  • 187
  • 2
  • 14
2
votes
1 answer

Unable to Update file After SQL insert SQLRPGLE

Good Day all, I am writing a program to build a report where I build the SQL statement to insert selected records into a file and after that insert I would like to do a simple update on the file to change a select fields in some records. The…
Javed Ali
  • 1,510
  • 2
  • 12
  • 18