Skip to main content

Posts

Showing posts from August, 2020

Message Subfile

Message Subfile: Message Subfiles (or Subfile Messages) are very useful for screens where it needs to display multiple messages to the user giving the flexibility to the user to view all the messages by taking PAGE DOWN/PAGE UP.  These messages can be sent using SNDPGMMSG in CL Program. And, RMVMSG can be used to clear these messages from the Message Queue.  Message Subfile would then load the messages from the Specified Program Message Queue and display them on the screen.  However, When we use RPG, it require writing CL Program to execute SNDPGMMSG & RMVMSG to Send or Remove Messages to/from the queue.  Below APIs become very useful to do the same from RPG program rather than having to create another program to do this.  QMHSNDPM - Send Program Message API. QMHRMVPM - Remove Program Message API. We will see how to create Message Subfile before going on to using these APIs to send the messages to Queue. When adding new Record Format in DSPF, Select the type as 'SFLMSG' (Su

How to run CL commands in RPGLE (Using QCMDEXC)?

QCMDEXC: CL (Control Language) has always been (and continue to be) the best choice for the programs which require more interaction with the Operating System.  However, We do see many cases where there is a need to run these commands from other HLL programs (like. RPGLE). And, it's not always best to write a CL Program to serve this purpose.  QCMDEXC (Execute Command) API becomes very useful in this case.  This API Requires two Input parameters. Command String - Character field with Variable length (maximum length of 32,702 characters). Length Of Command String - Decimal field with 15 digits (5 decimal places).  Here is a sample code with a simple 'DSPMSG' command.  **Free   Dcl-PR ExecuteCommand ExtPgm ( 'QCMDEXC' ) ;     Command Char ( 128 ) ;     Length Packed ( 15 : 5 ) ;   End-PR ;   Dcl-S Command Char ( 128 ) ; //Maximum length allowed is 32,702   Dcl-S Length Packed ( 15 : 5 ) ;   Command = 'DSPMSG' ;   Length = %Len ( %Trim ( Command )

Expandable Subfile - Example Program

Subfile: Subfiles are one of the most used concepts on IBM i.  There are three different types of Subfiles.  Load All Subfile ( Click Here to see more about Load All Subfile with an example). Expandable Subfile Single Page Subfile Message Subfile is used to display messages on the screen. Click Here to see more about Message Subfiles.  We will see more about Expandable Subfile in this article with an example. Variable has been used to display message on the screen in this example. Message subfile can be used instead. Expandable Subfile: As the name suggests Subfile is expanded (loaded) as we press the 'PAGE DOWN' Button.  Only one page (equal to the number of records mentioned against SFLPAG in DSPF) is loaded on the initial load and the next page is loaded when we press 'PAGE DOWN'.  Logic for PAGE DOWN needs to be handled in the Program and PAGE UP is taken care by the system (using the records already loaded from Subfile buffer).  However, Maximum number of records