Category: RPG

%ScanR() – Scan Reverse for Characters

%SCANR returns the last position of the search argument in the source string, or 0 if it was not found. Syntax: %SCANR(search argument : source string { : start { : length } } ) %SCANR is similar to %SCAN. They differ only in the direction of the search • The “start position” represents the […]

%Max() and %Min() Built-in Functions

%Max() returns the maximum value of its operands: %Min() returns the minimum value of its operands. Example : Dcl-s Price1 Packed(7 : 2); Dcl-s Price2 Packed(7 : 2); Dcl-s Price3 Packed(7 : 2); Dcl-s Costliest Packed(7 : 2); Dcl-s Cheapest Packed(7 : 2); Costliest = %Max(Price1 : Price2 : Price3); Cheapest = %Min(Price1 : Price2 […]

What does On-Exit Opcode do?

If you want to run some cleanup code when a procedure ends like • Deallocating the allocated storage. • You want to delete a temporary file You can put that code into the ON-EXIT section of your procedure, and the code will run no matter how your procedure ends Example : dcl-proc Sampleproc; dcl-s p […]

Creating JSON with YAJL

http://ibmsystemsmag.com/ibmi/developer/rpg/first-steps-json/?page=1

Consuming JSON with YAJL

http://ibmsystemsmag.com/ibmi/developer/rpg/json-data-with-yajl/