TechTalk: How to Display an Empty Subfile on the

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

I've recently discovered a solution to the problem of not being able to display an empty subfile. For the most part, you usually would not want to display a subfile without records. However, there are occasions when this concept would be very useful. For example, suppose you are displaying a search screen that contains a subfile. Then a user enters a value that is past the end of the file you are reading. It would be nice to display an empty subfile and a message specifying that the parameters entered are out of the limits of the file. However, if you try this, you receive the IBM message "Session or Device Error Occurred" stating that it cannot process the subfile request.

All that is needed to correct this problem on the AS/400 is to successfully load the subfile one time in the program. After that, it can be displayed even when it is empty. I achieve this by adding a few lines of code in my "INIT" subroutine (see 1) which is only executed once during the program.

All that is needed to correct this problem on the AS/400 is to successfully load the subfile one time in the program. After that, it can be displayed even when it is empty. I achieve this by adding a few lines of code in my "INIT" subroutine (see Figure 1) which is only executed once during the program.

First, I clear the subfile to activate it; then, I write just one record to it. After that, I clear the subfile again and the system still thinks it is successfully loaded. When this routine is complete, the subfile can be displayed at any point in the program - even when it is empty.

Donald McGrath Cincinnati, Ohio


TechTalk: How to Display an Empty Subfile on the

Figure 1 RPG code for dummy write to a subfile

 Figure 1: Partial RPG Code to Perform a Single Dummy Write to a Subfile ...1.... ....2.... ....3.... ....4.... ....5.... ....6.... ....7.... ....8 ***************************************************************** * INIT - Housekeeping subroutine only executed once ***************************************************************** INIT BEGSR * Clear and activate subfile MOVEA'01' *IN,95 WRITESFLCTL MOVEA'00' *IN,95 * Write one record to subfile ADD 1 SFLRRN WRITESFLREC * Clear subfile again MOVEA'01' *IN,95 WRITECTL MOVEA'00' *IN,95 * ENDSR *IN95 - SFLDSPCTL *IN95 - SFLDSP *IN96 - SFLCLR ...1.... ....2.... ....3.... ....4.... ....5.... ....6.... ....7.... ....8 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: