TechTalk: New: Named Constants in RPG

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

Notice the peculiar input specification in the RPG program RECCNT in the TechTalk technique "File Size Retriever". As of Release 2.0, you can now create named constants in this manner. What is a named constant? The result is similar to the FICA field in this example:

 Z-ADD7.51 FICA 32 

This statement assigns the value 7.51 to a field called FICA. The resulting difference between this field and a named constant is that you cannot change the assigned value of a named constant in the program. Other than that, you can use it just like any other field.

One of the biggest advantages of a named constant is that you can easily assign constant values larger than eight characters or ten digits (the limit of factor two in the calc spec). Without named constants, you would probably use the technique of defining the constant in a compile-time array and then moving that into the field. Now, you can define alphanumeric constants up to 256 characters and numeric constants up to 30 digits, right in the input specifications.

1 shows three examples of named constants. You can find all the coding rules in the RPG Reference Manual, pages 8-27 and 8-28, and the RPG User's Guide, page 9-26.

Figure 1 shows three examples of named constants. You can find all the coding rules in the RPG Reference Manual, pages 8-27 and 8-28, and the RPG User's Guide, page 9-26.

Midrange Computing


TechTalk: New: Named Constants in RPG

Figure 1 Examples of defining named constants

 Figure 1: Examples of Defining Named Constants in RPG Input Specifications Here are some examples: 6..10....+...20....+...30....+...40....+...50....+...60....+...70 I* Single Line character constant I 'Y' C ACTIVE I* Continued character constant I 'Midrange - C TITLE I 'Computing' I* Continued numeric constant I 1234567- C NUMBER I 8.9999 
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: