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

as400 RPGLE get UTC time in UNIX epoch format

Still learning RPG/as400. I need to get the current date and time in UTC in UNIX epoch format. I havent had much luck searching on how to covert a standard dd/mm/yyyy hh:mm:ss into unix format either. Is it possible to pull UNIX time stamps from the…
Dominick
  • 23
  • 3
1
vote
3 answers

SQLRPGLE cursor returns properly when sorting by ASC order but returns nothing when ordered by DESC, Why?

I am coding in IBM RDI and running the program on the 5250 emulator. I am writing a simple program reading from a single SQL table and the outputting results to a printer file. The code works basically as expected but I encountered something…
d0rf47
  • 409
  • 8
  • 20
1
vote
0 answers

CGIDEV2 & Public Webpage (IBM Iseries / AS400)

Good Afternoon, Perhaps this is a silly question, but I'm wondering if someone could help to point me in the right direction as I'm not even sure where to start. I am starting to become adept at using CGIDEV2 tool to create a webpage using RPGLE.…
1
vote
2 answers

RPGLE embedded SQL 'select from final table...' throwing SQL0029 at compile time

What looks like a simple SQL statement is throwing error SQL0029... 'Position 14 INTO clause missing from embedded statement.'. The first obvious point is that the 'INTO' is not missing from my statement but the SQL pre-compiler sometimes provides…
Brenski
  • 13
  • 4
1
vote
3 answers

Can anyone explain why decimal data error is happening with %char()?

To begin with, I am not looking for just a solution to fix this error message. I would be far more appreciative of being directed to documentation explaining this error than a solution to the code problem. I need to understand WHY this is…
CoMo G-Dawg
  • 401
  • 1
  • 3
  • 18
1
vote
0 answers

I added java class to debug ( STRDBG ) but source code is not available

I am trying to debug java program that I call from RPGILE program on our iSeries machine (V7R2M0 with java 1.7.0) with its good old debugger (STRDBG). Following this manual it should be possible and I was able to add class I want to debug to modules…
Piro
  • 1,367
  • 2
  • 19
  • 40
1
vote
1 answer

How to define a data-area data-structure that is dim()?

I would like to add the DIM() keyword to this - but the compiler complains? $ConfEmlDS UDS qualified DTAARA(TSACONFEML)
SalBonello
  • 11
  • 2
1
vote
0 answers

Lose Vim Color with ftp

Recently I've been creating my custom color scheme on VIM for RPGLE language and it works fine when I open files from my computer, but when I try to edit a file via FTP it doesn't work anymore. Do I need some special config to achieve this?
Mariela
  • 134
  • 2
  • 13
1
vote
1 answer

SQLRPGLE Cannot insert record - Cast error trying to insert packed decimal into integer field

I'm having an issue with an SQLRPGLE program which must insert records in a table. I've been debugging my program with strdbg command and I found out that the problem was caused by a packed decimal field called Mes in my data structure, when trying…
Mariela
  • 134
  • 2
  • 13
1
vote
2 answers

RPGLE: Does a non-successful READ unlock a previously-locked record?

Here is my problem: I have a READE in a loop In this loop, I can update the record or not, depending on a condition. In this situation: I've red the last record of the sequence, it's locked It doesn't satisfy the condition, so it isn't updated, so…
FredericP
  • 1,119
  • 1
  • 14
  • 27
1
vote
1 answer

AS400 rpgle embedded sql using sensitive cursor with over()

Language: RPGLE exec sql declare c1_RC0113_PLP04 sensitive scroll cursor for select ROW_NUMBER() over ( order by A4KQTT ) as rownbr, A4KQTT, A4SCAC, '0', ' ' …
i03604m
  • 11
  • 3
1
vote
2 answers

DB2 SYSTOOLS.HTTPPUTCLOB ignores JSON in third parm, REQUESTMSG (body?)

I am trying to HTTP PUT to a remote API to update data. I am on an IBM i, V7R3M0, using SQL command SYSTOOLS.HTTPPUTCLOB. When I do a similar test in Postman (to the same URL, same headers, same JSON in the body), the remote data updates…
1
vote
0 answers

How to get a pretty print JSON or XML with SQL using Json_Object... etc

I am Writing below query to generate a JSON: SELECT json_object ('Product_id' value PROID,'Product_name' value PRONAME) from Product Which Actually results in JSON in a CLOB field and the Output is not Pretty. The output looks like…
AKarthik
  • 31
  • 3
1
vote
1 answer

SQLRPGLE syntax for Exec sql from a varying length variable?

On IBMi (database is DB2 for i) in SQLRPGLE I have a program that builds a large SQL statement into a variable that I would like to run. When I try to run it as a variable I receive a token error Some background Here is an example that works…
VAI Jason
  • 534
  • 4
  • 14
1
vote
1 answer

Is this the correct behavior for SQL GET DIAGNOSTICS?

The documentation for the SQL statement GET DIAGNOSTICS indicates that you can request that diagnostic data be placed in specific variables, with the relevant variable names and types listed. The articles here and here show how one can use this SQL…
Mike
  • 1,274
  • 10
  • 24