Which is better, a return code or an exception?
When writing a procedure that might want to indicate an error condition, you have three choices: You can use the return value to indicate success or failure, you can have a separate "return code" parameter, or you can send an exception to indicate failure. Using exceptions rather than return codes leads to the most robust applications, and an exception based application can also give the cleanest code, since return codes... [Continue Reading]
Tags:  rpg_cafe |
Coming soon to your 7.1 system: An entire program in free-form RPG!
Yes, I really mean that you will be able to write an entire program in free-form RPG! Yes, I really mean that it is coming soon! Yes, I really mean that it is for 7.1! As part of Technology Refresh 7, the ILE RPG compiler will be updated with support for free-form H, F, D, and P specs. Read more about this enhancement here, in the RPG Cafe wiki:... [Continue Reading]
Tags:  rpgcafe rpg_cafe rpgfree rpg |
Open Access to be available to all RPG programmers!
This is a very exciting day for me. Today, IBM announced that PTFs will soon be available to make the function of Open Access available without needing a license for product 5733-OAR. Â For those of you who have not tried Open Access yet, I hope you will try it when the PTFs become available, and that you have as much fun as I have had exploring what you can do with it. Open Access is intended to be used for much more than modernize your WORKSTN... [Continue Reading]
Tags:  rpg open_access oar |
Negative variable names
I don't know whether it's my own mental defect, or if it's more universal, but I find it awkward to understand code using variables that mean something negative. I find I have to exercise my brain more to understand the first "IF" than the second in the following two snippets of code. My brain freezes up just a little bit when it tries to understand setting notValid to off. But it has no trouble understanding setting isValid... [Continue Reading]
Tags:  rpgcafe |
Upcoming RPG enhancements timed with the 7.2 and 7.3 TRs for spring 2017
The IBM i announcements for the 7.2 and 7.3 TRs don't mention the three upcoming RPG enhancements that will be available through PTFs at the same time as the TRs. The PTFs will be available individually, and they will also be part of the upcoming 7.2 and 7.3 DB2 group PTFs . More information about the PTFs will be available in the RPG Cafe wiki when the PTFs are available. Short URL for this blog entry:... [Continue Reading]
Tags:  rpg rpgfree |
Are you using OPTION(*NOUNREF)? If so, good! If not, read on.
If you're not already using OPTION(*NOUNREF), I recommend that you consider doing so. OPTION(*NOUNREF) was introduced in 6.1. It tells the compiler not to generate unused fields into the module. By default, with OPTION(*UNREF), the ILE RPG compiler generates unused fields into the module. Prior to 6.1, you had no control over this. The default *UNREF has some negative effects. Too much storage for the module The most common ways for a module... [Continue Reading]
|
Why use the TEMPLATE keyword?
The TEMPLATE keyword was added to RPG in 6.1. When you use the TEMPLATE keyword on a standalone field or data structure, the compiler will only allow you to use that definition for other LIKE or LIKEDS definitions, and for a couple of built-in functions, %SIZE and %ELEM. Â Prior to 6.1, when people wanted to define a field or data structure to
be used as a template, they often defined it as BASED on a pointer,
where the pointer would never be... [Continue Reading]
Tags:  rpg_cafe |
New site for Rational Developer for Power demos, cool Screen and Report Designer vide
 Great news everybody, The development team for Rational
Developer for Power have been very busy producing videos and demos to
illustrate how to install configure, use projects, edit, navigate
source, validate, build, debug on our supported languages on IBM i, AIX,
and Linux. The IBM i demos are just getting started, but check out the very slick demos of Screen and Report Designer. You will learn trick and techniques in becoming even... [Continue Reading]
Tags:  videos rational-ac-em rational-ac rdpower ibmi enablement rational-ac-power-app-mod... rational-ac-power-dev demos dds resource em |
PTFs to make it easier to use data structures for subfile I/O
During testing for Open Access, we were reminded of how awkward it is to use a data structure for I/O to subfiles. Subfiles always use the WRITE operation and at least one of either the CHAIN or READC operations, and possibly the UPDATE operation. This requires a *INPUT data structure and a *OUTPUT data structure. This isn't unique to subfiles; it's a problem for any record that is used for both input and output. But it's always a problem for... [Continue Reading]
Tags:  subfile rpgcafe |
Is debug active? Here's a procedure that tells you
Do you ever want some code to run only when the debugger is active? Here's a procedure you can call to find out: Test program /copy indebug
/free
if inDebug();
dsply ('The debugger is active');
else;
dsply ('The debugger is not active');
endif;
return;
Member INDEBUG_PR containing the prototype /if not defined INDEBUG_INCLUDED
D inDebug pr n extproc('inDebug')
/define... [Continue Reading]
Tags:  rpgcafe debug |
From ENDDO to LIKEFILE - my 20th RPG anniversary
Today is the 20th anniversary of my arrival at IBM and also my arrival in the AS/400 RPG Compiler Development department. The day I arrived, almost everyone was on vacation - there were only 3 other people working. It was near the end of development for V1R3. My first couple of days were spent on an off-site RPG II self-study course, with no actual computer but only coding sheets to work with. Much of my time was spent scratching my head... [Continue Reading]
Tags:  rpg rpgcafe |
ALIGN(*FULL), the forgotten 3rd child of the spring 2017 RPG enhancements
I have read several articles about nested data structures, and a few about %MAX and %MIN. I understand why these are more attractive than an enhancement that just changes how ALIGN works. I really do understand. We put "nested data structures" first in the lists of these enhancements because we know that's the most attractive one. But don't ignore ALIGN(*FULL). It can be very important. With just ALIGN, %SIZE(ds_array) might not... [Continue Reading]
|
Enhancement for 7.2 and 7.3: ON-EXIT section to be run whenever a procedure ends
7.2 and 7.3 PTFs are available today with an enhancement for the ILE RPG compiler that will make it much easier to ensure that your cleanup code runs every time your procedure ends, either normally or abnormally. For more information, see http://ibm.biz/RPG_ON_EXIT_Section.
Tags:  rpgcafe rpg_cafe rpg |
Have you heard of the /SET and /RESTORE directives?
In 7.2, two new directives were added for ILE RPG. /SET temporarily changes the defaults for some D spec keywords from the defaults set by the H spec. /RESTORE undoes the effects of the active /SET directive. http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzasd/cdset.htm http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzasd/cdrestore.htm If you code /SET in a /COPY file, there is an implicit /RESTORE at the end of the copy... [Continue Reading]
|
Two new file-related enhancements for RPG available through PTFs for 7.1 and 7.2
There are two new enhancements for RPG, available through PTFs. These enhancements are timed to coincide with 7.2 TR1 and 7.1 TR9. First, the ALIAS support that was new in 7.1 is now extended to support all externally-described files. Second, the rules for using result data structures for I/O have been relaxed, allowing you to use the same data structure for both input and output operations. Read here,... [Continue Reading]
Tags:  rpgcafe ibmi |
New version of the wiki article on converting C prototypes to RPG
The article on converting C prototypes to RPG has had a major overhaul. https://ibm.biz/BdxQbC The old version was written from a pre-V5R1 perspective, with some remarks about post V5R1 or 6.1 coding. The new version is written from a 6.1 perspective, using QUALIFIED and TEMPLATE as a matter of course, with some side remarks about how to handle TEMPLATE in pre-6.1 coding. All the discussion about pre-V5R1 coding has been removed. Also, the... [Continue Reading]
|
RPG tutorial for experienced programmers new to RPG |
New H spec keyword CCSIDCVT
A new H spec keyword, CCSIDCVT, is added through PTFs for 6.1 and 7.1. For full details, see http://ibm.biz/BdxXWJ . Â The main reason for this keyword is so that RPG programmers can be aware of data loss due to CCSID conversions. Data loss occurs when a character in the source data doesn't have a matching character in the target character set. This happens most commonly when converting from UCS-2 to alphanumeric or DBCS. Â You can use... [Continue Reading]
Tags:  ccsidcvt rpgcafe ccsid |
A couple of articles about using Open Access with database IO
I'm always pleased to see articles about Open Access, and especially articles that show how Open Access can be used for more than modernizing a user interface (WORKSTN files). Here are a couple of articles about Open Access being used for SQL database access (DISK files). Â Here's an article by Daniel Cruikshank of IBM about using Open Access to take advantage of programming techniques only available via SQL programming, using RPG I/O opcodes.... [Continue Reading]
Tags:  openaccess rpgcafe |
V1R1M1 of Open Access allows try and buy
I was on vacation when IBM announced the V1R1M1 of the Open Access product 5733-OAR, so I'm a bit late mentioning it here in the Cafe. Â This is exciting for me because it allows try-and-buy, so RPG programmers will be able to try Open Access for up to 70 days without having to actually purchase the product. Other than the licensing change, there's nothing new in V1R1M1. Open Access behaves the same at compile-time and runtime whether you have... [Continue Reading]
Tags:  openaccess rpgcafe |
An H spec keyword that you might be missing
CCSID(*CHAR : *JOBRUN) Do you have this keyword in your H spec copy file that gets copied into all your source? Or if you don't use a copy file, do you have this option in all your source? You should almost certainly have this keyword. It was introduced officially in V5R3, and through PTFs in V5R1 and V5R2. Why do you need this keyword? RPG has a very strange default way of dealing with the CCSID of alphanumeric data. It should be assuming that... [Continue Reading]
Tags:  rpgcafe rpg |
Everyone knows what X'7D' means ... unfortunately
cmd = 'ADDPFM LIB/FILE MBR(' + mbr + ') ' + 'TEXT(' + X'7D' + text + X'7D' + ')'; Unfortunately, I think too many RPG programmers know what X'7D' means. I don't know how it happened that it's considered normal to code X'7D' when a single quote is wanted in an RPG program, but it's a very common coding technique. RPG already has syntax for a single quote character. Similar to 'A' being a single A character, you code '''' for a single quote... [Continue Reading]
Tags:  rpgcafe rpg quote |
Performance tip
Here is the tip: Beware of performance tips For me, the performance rule that never changes is this one: Always question any rule you hear about X performing badly, or Y performing better than Z. Was it ever true? Is it still true? Might it change in the future? Can I measure the difference? Does it apply to my current situation? Does the difference matter enough to code in a more complex or error-prone way? The trouble with performance rules is... [Continue Reading]
Tags:  rpgcafe |
DATA-INTO is here! PTFs for 7.2 and 7.2 will be available by March 19, 2018
DATA-INTO reads the data from a structured document, such as a JSON document, into a data structure. It's like XML-INTO, except that it handles any type of structured document, not just XML. The reason it can handle any type of document is that you have to supply the parser for the document. See this wiki page, http://ibm.biz/data-into-rpg-opcode-ptfs , in the RPG Cafe for information about The PTFs you need A sample JSON parser... [Continue Reading]
Tags:  rpgcafe rpg |
More 7.2 and 7.3 enhancements for 2017
RPG compiler enhancements for 7.2 and 7.3 are now available through PTFs. The enhancements New built-in function %PROC returns the external name of the current procedure (RFE 93086) Complex qualified names can be used in more places
%ELEM %SIZE DEALLOC (RFE 102087) RESET Support for PCML version 7.0 which allows varying-length subfields and arrays. See the wiki page (link below) for current restrictions as to where you can actually use this... [Continue Reading]
Tags:  rpg |
7.2 and 7.3 enhancements for nested data structures, %MAX & %MIN, ALIGN(*FULL)
The following RPG compiler enhancements for 7.2 and 7.3 are now available through PTFs. The enhancements Nested data structures ( RFE 87967 ) (in free-form declarations only) %MAX and %MIN built-in functions ( RFE 93114 ) ALIGN(*FULL) to cause the size of a data structure to be a multiple of it's alignment. ( RFE 94630 ). This will be of special interest to anyone who uses the regex functions, who may have their regex_t... [Continue Reading]
|
How to compile an RPG module or program with PCML included in the object
To get PCML embedded in your module or program, add the following keyword to your H spec: PGMINFO(*PCML : *MODULE) If you are on 7.1 or later, and have the required PTFs described in this RPG Cafe wiki page, https://ibm.biz/rpgCafe_PCML_enhancements , you can get "nicer" PCML, with mixed-case names, by coding PGMINFO(*PCML : *MODULE : *DCLCASE) What is PCML? If you're wondering what "PCML" is, it stands for "Program... [Continue Reading]
Tags:  rpg pcml rpgcafe iws |
Compile RPG from Unicode source - new TGTCCSID parameter in 7.1, 7.2, 7.3
RPG has delivered its first RFE! https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=92809 Without the PTF that provides the new TGTCCSID parameter for the CRTBNDRPG and CRTRPGMOD commands, it was impossible to compile if the primary source file was a Unicode IFS file. Now, with a PTF for 7.1, 7.2, or 7.3, if you specify TGTCCSID(*JOB) or a specific EBCDIC CCSID such as TGTCCSID(37), you can compile from Unicode source. For... [Continue Reading]
|
What's Brand New in 7.3 for RPG?
Many of the features listed in the What's New section of the 7.3 RPG reference are not actually new in 7.3. Several features are already available through PTFs for 7.1 and 7.2 (see the " What's new since 7.2 " page in the 7.2 reference. Here are the features that are brand new in 7.3 (These are not planned to be made available for earlier releases through PTFs) %SCANR (scan... [Continue Reading]
|
RPG is even freer than before
7.1 and 7.2 PTFs are available today for the ILE RPG compiler that provide support for coding free-form RPG from column 1 to the end of the line. No more wasting the first 7 characters of the line. or the last 20 characters if you create your RPG source files with the recommended length of 112. To use this enhancement, you code **FREE in line 1 of any source that is to be fully free. When the source contains **FREE in line 1, that source can only... [Continue Reading]
|