Latest entries:

ILE RPG Google Chart encoders

Encoding number series for Google Chart APIs.

Read more…

Using custom brushes with SyntaxHighlighter Evolved

How to integrate custom SyntaxHighlighter brush files found on this site with the WordPress plugin SyntaxHighlighter Evolved.

Read more…

Three ways I called an RPGLE program from Java

Calling an IBM RPGLE program from Java using ProgramCall(), PCML, and JDBC.

Read more…

Calling RPGLE programs with Java and PCML

Admins: consider attaching an excerpt.

Demonstrating how to call an RPGLE program from Java using PCML.

The important options are PGMINFO and INFOSTMF. When compiled, a PCML interface file looks like this.

The PCML document serves for Java and ProgramCallDocument() the same function as the RPGLE prototype for other program calls: it is the “contract” between the caller and callee, specifying the number, kind, and use of parameters. This is also the same jump from using RPG’s *ENTRY PLIST going to prototyped calls, allowing for better enforcement of parameters in the call.

Used with the ProgramCallDocument method in jt400.jar or jtopen.jar, this allows Java programs to call RPGLE programs with little fuss. In the next code examples I focus on the program call process and not the setup, such as connecting to the IBM i, setting the library list, etc.

The Java code samples pass INLOCATION using string variable vanguardLocation, and receive OUTUSESEQ into integer variable nextSequence.

Notice we must create a parameter list, convert incoming parameters to IBM i types, and convert outgoing parameters back to Java types. We are also exposed to the full path to the called program. The PCML document already specified the data types required by the program and hides the full path to the called program. The ProgramCallDocument class handles type conversions for us. All of this results in less code.

In line 2 above we reference the PCML file, incgljseq.pcml, which is in the same place as the class file. Notice we do not specify the extension .pcml. The reason for this is we can also serialize the PCML file. The PCML loader first looks for the serializaed version (for example, incgljseq.pcml.ser), then for the normal PCML file (incgljseq.pcml).

Coding Java programs for EBI external API actions

Admins: consider attaching an excerpt.

In Extol Business Integrator (EBI), coding requirements for External API Actions (implemented via Java programs) are different from a Business Process task Run Java Program. The Run Java Program task can execute any method from a class or JAR file with any parameter combination. In contrast, External API Actions have specific parameter requirements.

The two import com.extol.… lines are required for communications between EBI and the Java program when used as an External API Action.

The class definition should implement Serializable.

Extol discourages the use of the main() method. Other coding examples I’ve seen use execute() as the method name. Obviously, if you have multiple methods in your class/JAR file, they will have different names.

When defining the External API Action in EBI, your mapped parameters correspond to the Object[] parms parameter. By Extol convention, if there is a (single) return value, it is passed in parms0.

I use the main() method to call from Eclipse or the command line for testing, and set up the parameters the same way as they are expected to be used in EBI.

It is recommended (at least for EBI 2.4, as of this writing) that return values be type String. When used in an EBI transformation ruleset, output type of Integer cannot be mapped to a corresponding middle tree variable, resulting in a type mismatch error message.

Update 5 Nov 2009: If an External API Action definition is changed, any rule sets referencing it must be updated. Open the ruleset and select Tools, Refresh Action Lists. Then validate, compile, and save the rule set. The reason for this is because the ruleset is compiled into a Java class, and any external API actions are integrated at compile-time.

This article was originally published on 2 Nov 2009.

ILE RPG brush file for SyntaxHighlighter

Admins: consider attaching an excerpt.

Below is a reasonably complete custom brush file for ILE RPG, for use with SyntaxHighlighter. It is current through i5/OS ILE RPG version V6R1 (aka 6.1).

Normally SyntaxHighlighter only highlights words, and not any special symbols around them. ILE RPG prefixes built-in functions with a percent sign (such as %abs), and some key words are prefixed with an asterisk (such as *inlr or **CTDATA). The function getFunctions allows the special symbols to be highlighted with the associated key word. Many thanks to user helen at the alexgorbatchev.com forums for providing it.

The brush language is rpgle (same as the source member type) or rpg4 (the informal RPG language version).

Download the file and place it in SyntaxHighlighter’s script directory. Add a reference to shBrushRpgle.js on the pages requiring it.

Download: shBrushRpgle.js

Watch this space for updates and refinements!

Update 21 Jan 2011: Updated for SyntaxHighlighter v3 and Textpattern.
Update 13 May 2009: Added more figurative constants and fixed-format comments.

This article was originally published on 9 May 2009.

UIM brush file for SyntaxHighlighter

Admins: consider attaching an excerpt.

User Interface Manager (or UIM) is an IBM tag language primarily used to define help text, menus, and display panels. It can be thought of as a markup language similar to HTML. Download: shBrushUim.js

One note about the brush file. UIM defines figurative symbol names such as &colon. Because ampersands are typically escaped by content management systems, what is presented to SyntaxHighter is &colon. The symbols regex takes this into account.

As an example of User Interface Manager, here is a help definition for the Display Record Format command. This is a third-party tool, search Google for DSPRCDFMT for more details.

ILE RPG epoch functions

Admins: consider attaching an excerpt.

When working with the Integrated File System (IFS), it is often useful to convert file dates into real timestamp values. IFS file date/time attributes are stored in *NIX epoch format. The *NIX epoch is the number of seconds since midnight, 1 January 1970. I had some projects working with Scott Klement’s FTPAPI, where I need to do date comparisons based on a file’s modified date. Here are the Wikipedia entries for epoch and UNIX time.

ILE RPG UUID functions

Admins: consider attaching an excerpt.

A UUID is a unique identifier which has an extremely low collision rate. This article explains some real-world uses for UUIDs. Here is the Wikipedia entry.

The first procedure simply retrieves the UUID itself. A UUID is nothing more than 16 hex bytes. Many applications, however, expect to see the “human respresentation” of the bytes in a standard format. A wrapper procedure will convert the UUID from hex to readable format.

The only downside to the i5/OS UUID (as of V5R4, I do not have access to a 6.1 machine to test) is it is a DCE version 1 UUID. The lastest version as of this writing is version 5 with SHA-1 hashing.

As mentioned above, many times it is more useful to get the UUID in a human readable format. With that in mind, here is a getUUIDString() procedure. It takes an optional parameter, a hex UUID (perhaps previous retrieved from getUUID). If a UUID is not passed, one will be retrieved automatically. The procedure also converts the text representation to lower case.

A few things going on in getUUIDString. It uses IBM QlgConvertCase API to convert the text to lower case (it can also do upper case), no %xlate() functions here. This is the “correct” way to convert case to respect CCSID. Also uses the cvthc API to convert the hex values to text representation. Personally I have not needed the function in normal programming, but it is also used to generate a human readable MD5 hash. Converting hex to character just doesn’t come up often in business programming. Lastly, it shows proper use of the error code parameter. All too often, developers leave the “bytes provided” parameter uninitialized. This translates to x’404040′ or a very large number. Just as often, it will be set to zero, which prevents the error structure from being populated.

You can download the entire text file with prototypes and procedures. The program demonstrates both using the getUUID and getUUIDString procedures. Run the program in debug mode, usually with command line option DBGVIEW, to see that variables myuuid and myuuidstring are updated properly. Text file (source type RPGLE): uuidrpgle.txt.

ILE RPG ceiling()

Admins: consider attaching an excerpt.

This subprocedure implements a ceiling function: the smallest integer greater than or equal to value, given a scaling factor. It is implemented to mimic Excel’s ceiling, in that the returned value is farthest from zero.

Looking for older articles? View the archives for a full listing.

RSS: site-wide, code only

Favorite links:

stuff goes here