04
Mon, Nov
6 New Articles

Memo to Self: Organize Your Data Values

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

One of the greatest inventions of the 20th century is the sticky note. It allows you to jot something down, tear it off, and stick it on or near the object it’s referring to. In the AS/400 world, data areas are kind of like sticky notes. If you need a place to store a single value, such as a counter or account number, you can create a data area. And that’s often what happens, resulting in applications ending up with a lot of data areas scattered around. Unfortunately, also like sticky notes, these data areas can be difficult to manage and organize.

The AS/400 operating system uses a different approach to organize values like this. These values are called system values, and the AS/400 organizes them more like a looseleaf binder with index tabs, providing commands such as Work with System Value (WRKSYSVAL), Change System Value (CHGSYSVAL), Display System Value (DSPSYSVAL), and Retrieve System Value (RTVSYSVAL) to manage them. This method works so well that I’ve decided to emulate this process to create what I call user values. User values are like system values in that they are miscellaneous data that can be accessed globally through standard interfaces.

To manage user values, I have created utilities in the form of commands and APIs. You can find these utilities on the MC Web site at www.midrangecomputing.com/ mc/99/07. The commands are the preferred method for accessing user values from a command line or CL program. The APIs are the better choice for accessing user values from RPG programs. Figure 1 shows a list of the commands and APIs that access user values.

The first step is to create a user value infrastructure by calling the Create User Value (CRTUSRVAL) program. This program creates a physical file named USRVAL, which I prefer to place in library QUSRSYS, in which user values are stored. CRTUSRVAL also creates the necessary display files, programs, and commands.

SLTCMD *USRVAL

To create a new user value, use the Add User Value (ADDUSRVAL) command. In the command parameters, specify the user value name (up to 10 characters), a description (the default is the name), the size of the user value, and the initial value. Maximum size for a user value is 64 bytes; I felt this was large enough to accommodate most user values. In

fact, most user values are probably much smaller, so I use any unused space in the field that holds the value to store additional text, which you can specify when creating the user value. If the user value already exists, you must specify REPLACE (*YES), or else ADDUSRVAL issues escape message CPF9898.

After you have created the user value, it can then be used, either interactively or by a program. To change the user value, use the Change User Value (CHGUSRVAL) command. Specify the user value name, the new value, and the number of seconds to wait if the user value is locked. (The following paragraph discusses locked user values.) If the user value doesn’t exist, error CPF9897 is generated. If another job is using the user value and the wait time you specify expires, CPF9898 is generated. Otherwise, the user value is changed to the new value. The date and time of the last change are also updated, as well as the job name, user ID, and job number performing the update. This function is useful when debugging or tracking problems.

If you have a program that needs access to a user value, Retrieve User Value (RTVUSRVAL) is the command for you. Pass to it the user value name and a variable, and it returns the current value. Because your program may need to change the user value (incrementing a counter, for example) after it has been retrieved, RTVUSRVAL allows you to specify a number of seconds to lock the user value. When the user value is locked, no other job can retrieve or change it until the job that locked it either updates it or unlocks it by executing another RTVUSRVAL, this time specifying *UNLOCK. However, as soon as the number of seconds specified expires, the user value is fair game again. This prevents permanent locks from occurring when a job is caught in a loop or blows up.

To display the value and status of a user value, use the Display User Value (DSPUSRVAL) command. Figure 2 shows a sample display. From this screen, you can also change the user value by pressing F7.

Putting it all together is the Work with User Value (WRKUSRVAL) command, shown in Figure 3. This command lists all defined user values and allows you to display, change, or delete them. You can also add new user values by pressing F6.

Replace Those Data Areas!

Instead of cluttering up your libraries with myriad data areas, consider collecting all these miscellaneous bits and pieces of information into one file. User value utilities are a good way to organize your “sticky notes” on the AS/400. Put them to work today.

Command API Description

ADDUSRVAL UV0001 Add a new user value CHGUSRVAL UV0002 Change a user value DLTUSRVAL UV0002 Delete a user value DSPUSRVAL UV0003 Display the value of a user value RTVUSRVAL UV0002 Retrieve a user value into a CL variable WRKUSRVAL UV0005 Work with user values

Figure 1: Use these commands and programs to access user values.




Figure 2: DSPUSRVAL shows all information about a user value.



Memo_to_Self-_Organize_Your_Data_Values03-00.png 897x672




Figure 3: WRKUSRVAL allows you to add, change, and delete user values.



Memo_to_Self-_Organize_Your_Data_Values04-00.png 897x672
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: