Posts

options(*CONVERT) in RPGfree

The *CONVERT option in RPG is specified to tell the compiler to automatically convert a value passed as a parameter to the correct type if it differs from the type defined in the procedure.   How OPTIONS(*CONVERT) Works OPTIONS(*CONVERT) allows for automatic data conversion between compatible types when a procedure or function is called with a parameter of a different type than expected. For example, if a procedure is defined with a numeric parameter and a different type, such as a decimal, is passed to it, the compiler will automatically handle the conversion so that the value matches the declared type. For example: **free //      ******************************************************* //      * convert to char                                     * //      ******************************************************* ctl-opt main(main) dftactgrp(*no);   //      ******************************************************* //      * PGM start                                           * //

Retrieving Files Used in Programs, SQL packages, Service programs, Modules, Query definitions in an IBM i Library

Image
In this post, we’ll explore how to efficiently retrieve program files used in queries within an IBM i library using the DPR  command, along with its associated CLP ( DPRCL ) and SQL RPGLE program ( DPRRPG ). This combination allows users to dynamically fetch program file references based on various filters, enhancing the management of programs in the IBM i environment. Overview of Components 1. The DPR Command The DPR command serves as the entry point for retrieving program files. It accepts two parameters: the library name and the object type. Below is the source code for the DPR  command:                CMD        PROMPT('Show Pgm Files via DSPPGMREF')  /* COMMAND PROCESSING PROGRAM IS: DPRCL */                PARM       KWD(LIBRARY) TYPE(*CHAR) LEN(10) MIN(1) +                           PROMPT('Library or *ALL')              PARM       KWD(OBJTYPE) TYPE(*CHAR) LEN(07) RSTD(*YES) +                           VALUES(*PGM *SQLPKG *SRVPGM *MODULE

IBMi (AS400) fans only ' Retrieving Files Used in Queries of an IBM i Library

Image
A colleague of mine left me a real treasure trove of queries, accumulated over many years of work. It’s an endless list: over 1000 queries, all well cataloged and described. Recently, I needed to find a query related to customer orders. Knowing that the order file is called OTORD, the customer file CLCLI, and the sample file CMCMP, I started opening the most likely queries. The process was long and frustrating: Open Query > Specify file selections > View the files used > Close Query. Stressful, right?   So, I thought I’d let our trusty IBM i do some work for me. I created a procedure to retrieve the list of files used by all the queries in a specific library, with the ability to add some filters to answer more specific questions. For example:   Which queries use the files OTORD00F, CLCLI00F, and CMCMP00F?   The result? A clean and well-organized subfile: Don't forget to set the screen to 132 columns! The source code follows: FQRCL       CLP /***********************

IBMi (AS400) fans only ' Each IBMi User Knows They Run the Most Efficient System. All Others Just Have Too Much Money

Image
Each IBMi User Knows They Run the Most Efficient System. All Others Just Have Too Much Money. Let's take a moment to ponder this thought-provoking and slightly provocative motto: Each IBMi user knows they run the most efficient system. All others just have too much money. I can't take credit for this line—I read it somewhere a while ago, and unfortunately, I don’t know who the original author is. Nonetheless, it's a statement that resonates with many of us in the IBM i community.  But is this motto still relevant today? With advancements in technology and the rise of various competing platforms, some might argue that the landscape has changed. Others might say that IBM i remains unparalleled in terms of reliability, efficiency, and total cost of ownership. So, why not take a 5-minute break, grab a coffee, and let's discuss this! Why IBM i Users Swear by It IBM i has long been known for its rock-solid stability, security, and seamless integration capabilities. Many busin

IBMi (AS400) fans only - Discover the power of the %SPLIT BIF in RPG

In RPG, we often need to manage strings, split them into substrings, and manipulate them efficiently. The %SPLIT BIF is a powerful and useful tool to handle this task.   But what exactly is %SPLIT? 🤔   %SPLIT divides a string into multiple parts using a specified delimiter. It can return an array of values based on the delimiter you choose, making it easier to handle complex data or composite strings.   Here’s a practical code example to understand it better:     **FREE Dcl-s stringa    Varchar(100) Inz('apple,banana,orange'); Dcl-s array      Varchar(20) Dim(10); Dcl-s delimiter Varchar(1) Inz(','); Dcl-s i          Int(10); // Index for the loop // ***************************************************** // PGM start // ***************************************************** array = %Split(stringa : delimiter); *inlr = *on; For i = 1 to %Elem(array);    Dsply array(i); EndFor;   In this example, the string 'apple,bana