12
Tue, Nov
5 New Articles

User Defined Edit Codes

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

Creating Custom AS/400 Edit Codes

By Craig Pelkie

Over the past several years, many astute System/36 programmers have noticed a mysterious entry on their O-spec sheets or debugging template. That entry applies to column 38, "Edit Codes." The mystery is, what do edit codes 5 through 9, shown as "user defined," do?

User defined edit codes made their appearance with the System/38. Quite simply, you have five codes that you can define and use anywhere, in place of an edit word. Big deal!, you might say. Maybe it is, maybe not-but think of some examples. If you have employee records, you're probably using an edit word each time you print or display their Social Security Number. Or maybe you print telephone numbers, nicely formatted, with edit words. For manufacturing or distribution applications, you probably have a part number that needs editing. Applications dealing with foreign currency are another example where you now use edit words.

With a user defined edit code, you can once-and-for-all "encapsulate" the dreaded edit word into a simple edit code. You can then use your edit code like any of the other edit codes, such as "Z" (zero suppress), "Y" (date edit) or the other numeric edit codes.

Look At Them First

The first thing you should do is look at these codes, as they are currently defined. That's right, they are shipped as part of OS/400. User defined edit codes even have their own object type, *EDTD (edit description). These objects reside in library QSYS. They follow a very simple naming convention, QEDIT5 through QEDIT9. You can use the WRKOBJ command to verify their existence, and the DSPEDTD (Display Edit Description) command to look at their current (shipped) definitions. You can also review the shipped definitions in Appendix E of the Data Management Guide (SC21-9658).

When you display or look up the description, you will probably be surprised to see the number of parameters that comprise the edit description. Actually, the parameters can be used to create rather complicated edit words. The big advantage you have is that you can define these complicated edits in one place, and never have to code the edit word again on O or A specs.

At this point, you should review Appendix E in the Data Management Guide. Also, refer to the index entries for "edit code" or "edit codes" (apparently, IBM couldn't make up their minds) and read one of the sections on user-defined edit codes. Both references are the same (one is in the section for display files, the other for printer files).

How Are They Used?

I told you earlier that you can use the user defined edit codes in the same manner as any other IBM defined edit code. If you are using O-specs for either printer or display files (or disk files, I suppose, if you are storing edited values), you can simply code the number 5-9 in column 38 of the O-spec. If you are using A-specs for printer or display files, you use the keyword EDTCDE, with the edit code number enclosed within the parentheses.

Now, this is important, so be sure you understand: the effect of using a user defined edit code takes place at program compile or file create time. That is, for an RPG program, the user defined definition is retrieved at compile time and becomes part of the compiled program. If you later change the user defined edit description, the new description is not used, unless you recompile the program. The same rule applies for display or printer files that you create with user defined edit descriptions. The edit description is used at file create time. To make use of a changed description, you have to delete and recreate the file.

As far as compiling or creating a program or file that has user defined edit descriptions, you don't need to take any special steps. Because the definitions are in library QSYS, they are "always" available. Also, I assume that you can use these edit descriptions in S/36 Environment programs.

How To Create Your Own Definition

Creating your own user defined edit description is easy. You simply choose one of the existing edit codes, 5-9, delete it with the DLTEDTD (Delete Edit Description) command, then create your definition with the CRTEDTD (Create Edit Description) command.

Because there are only five codes that you can work with, you will want to have general agreement within your shop before you start creating your own. That is, you don't want to create a code, then have somebody else decide to use the same code for a different edit description, since their creation will destroy yours.

For a complete review of all of the parameters you can use, I refer you to Control Language Reference, Volume 3 (SC21-9777). Rather than go through the meaning of all of the parameters here, I will leave you with two examples that I created; you may be able to improve them.

Sample Edit Codes

The samples that I created were for a Social Security number edit and for a telephone number with preceding area code.

The command for the Social Security number is shown in 1. Please note that the lower case "b" is not part of the edit description and should not be keyed; it is shown here to represent a blank space.

The command for the Social Security number is shown in Figure 1. Please note that the lower case "b" is not part of the edit description and should not be keyed; it is shown here to represent a blank space.

The INTMASK parameter looks like an RPG edit word. The interesting part here is the FILLCHAR parameter. This is used to "refill" a zero character where zero suppression has occurred. For a Social Security number, the accepted convention is to display all nine digits of the number, even if the leading number (such as mine) is a zero. The INTMASK parameter will always suppress the leading zero; the FILLCHAR puts it back. This will also fill an all zero Social Security number with zeros, so you'll have to decide if you want that for an all-blank field.

The telephone number edit is shown in 2. Again, in the INTMASK, lower case "b" represents a blank space, which will be filled with numbers. The ")&" and "-" characters are used to format the telephone number. In this example, the LFTCNS (left constant) parameter is used to indicate that we want to have an opening (left) parenthesis. If the left parenthesis had been included in the INTMASK, it would not be printed or displayed, since the first substitution character comes after the opening parenthesis. The LFTCNS parameter is used to "force" a character string to the left of the edited field. You can specify up to 31 characters for the LFTCNS, so you might have put LFTCNS('Telephone: ('). If you do include left or right constants, you have to count the length of the constants as part of the width of the edited field, and allow enough space on your report or display for the entire field.

The telephone number edit is shown in Figure 2. Again, in the INTMASK, lower case "b" represents a blank space, which will be filled with numbers. The ")&" and "-" characters are used to format the telephone number. In this example, the LFTCNS (left constant) parameter is used to indicate that we want to have an opening (left) parenthesis. If the left parenthesis had been included in the INTMASK, it would not be printed or displayed, since the first substitution character comes after the opening parenthesis. The LFTCNS parameter is used to "force" a character string to the left of the edited field. You can specify up to 31 characters for the LFTCNS, so you might have put LFTCNS('Telephone: ('). If you do include left or right constants, you have to count the length of the constants as part of the width of the edited field, and allow enough space on your report or display for the entire field.

Give It A Try

Even if you don't want to create your own edit descriptions, you should review the supplied descriptions in Appendix E of the Data Management Guide. You might be able to use some of them in place of edit word coding that you are now using.

A final point to remember is that you should document any of the user defined edit descriptions that you change. If you install a new release of OS/400, the edit descriptions will be reset to the system supplied values, and you will have to delete and create your own definitions again.

Craig Pelkie works for Bits & Bytes in San Mateo, California. Bits and Bytes markets Facilities Scheduling software for midrange computers.


User Defined Edit Codes

Figure 1 Edit code for Social Security number

 Figure 1: Social Security Number CRTEDTD EDTD(5) + INTMASK('bbb-bb-bbbb') + FILLCHAR('0') + TEXT('SSN edit code') 
User Defined Edit Codes

Figure 2 Edit code for telephone number

 Figure 2: Telephone Number CRTEDTD EDTD(6) + INTMASK('bbb)&bbb-bbbb') + LFTCNS('(') + TEXT('Telephone edit code') 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • 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.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • 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

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • 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: