18
Sat, May
7 New Articles

TechTalk

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

MS Word Does OV/400

Did you know that Microsoft Word can read OfficeVision/400 documents directly? Just open Word and click on File/Open. If you have QDLS mapped to a drive letter, select that drive. Otherwise, look for your computer name by using the Windows Find command, which is available on the Windows Start menu. Note: You’ll need to search for Computer, not Files or Folders, on the Find command. Once you’ve located the QDLS folder, click on it to open it. Drill down until you find the document you wish to use in Word, and open it. You may get a screen asking whether you want to translate. If you do, select Rich Text Format (RTF) as the document type to convert from. That’s all there is to it! One other thing to keep in mind is that most word processors will be able to translate these documents, too. For example, Corel WordPerfect also has a translator to convert your OV/400 documents.

— David Abramowitz
This email address is being protected from spambots. You need JavaScript enabled to view it.

Editor’s Note: If you are unable to translate the document, you may need to install the Word text converter for RTF. You can find this converter on the Microsoft Web site at officeupdate.microsoft.com/downloaddetails/wdsupcnv.htm. It is not available on the Office Suite CD.

Professional Format

A problem with using numbers in messages in CL is that, when you convert them to text for displaying in the message description, you’re stuck with leading zeros. This looks pretty amateurish, but there is a better way that will give your messages a “professional” look. What you need to do is edit the numbers in the CL program before you convert them to text. Here’s how.

Define a message in a message file by using the Add Message Description (ADDMSGD) command, and specify a message variable with a type of binary and a length of 2 or 4 bytes.

In your CL program, define a 2- or 4-byte character value to contain the binary numeric value. Convert your decimal value to binary by using the %bin function, then use


the converted variable in the Send Program Message (SNDPGMMSG) command. The program in Figure 1 shows an example of how to do this.

— David Morris This email address is being protected from spambots. You need JavaScript enabled to view it.

/**************************************************************************/

/* To Create: */
/* CRTCLPGM PGM(XXXLIB/DM0001C) SRCFIL(XXXLIB/QCLSRC) */
/**************************************************************************/

PGM

DCL VAR(&BIN) TYPE(*CHAR) LEN(4)

DCL VAR(&DEC) TYPE(*DEC) LEN(9 0)

/* Create a temporary message file */

CRTMSGF MSGF(QTEMP/TESTMSGF)

/* Add a message to the message file */

ADDMSGD MSGID(TST0000) MSGF(QTEMP/TESTMSGF) +

MSG('Number is &1') FMT((*BIN 4))

/* Set the variable to a number */

CHGVAR VAR(&DEC) VALUE(100)

/* Change the variable to a binary value using %BIN */

CHGVAR VAR(%BIN(&BIN)) VALUE(&DEC)

/* Send the message using the SNDPGMMSG command */

SNDPGMMSG MSGID(TST0000) MSGF(QTEMP/TESTMSGF) +

MSGDTA(&BIN)

ENDPGM

Figure 1: Here’s a way to add edited numbers to messages in CL.

Time for a Change

Q: I’m having a problem with something that should be simple but has me baffled. I’m hoping you can help. I would like my RPG IV interactive program to timeout if there’s no response from the workstation after x number of seconds. I have several CL programs that do this very thing. I’ve even done it in RPG III on the System/38, but for the life of me, I can’t seem to get it to work in my RPG IV program.

— John De Young

Compulit, Inc. This email address is being protected from spambots. You need JavaScript enabled to view it.

A: To make a display file time out after a given number of seconds, you need to do a couple of things. I’ve included a working example to demonstrate how this works.

The display file shown in Figure 2 is pretty generic except for the use of the INVITE keyword. Use this keyword in your display file so you can read from the display device. When you compile display file DSP00D1, place a value on the Wait record (WAITRCD) parameter of the Create Display File (CRTDSPF) command. The value you put here is the number of seconds the program will wait for input from the user before it times out. When I created the file, I put a value of 10 seconds in this parameter so I could very quickly make sure this technique worked. When you use this technique in the real world, you should make this value high enough that the user has at least a fighting chance to get to the keyboard before the program times out.

As shown in Figure 3, the RPG IV program DSP00R1 has a couple of lines that you need to add to your program to make this all work. To get the program to timeout, you need to code an Infds keyword on the F-spec as well as code the Maxdev keyword with a value of 1. This tells the program that there is only one device to read from. On the D-spec,


Infds should be coded to use the *Status keyword. The program will read the values placed in *Status by the display file and perform some appropriate action based on their content.

When you read the display file (with INVITE active), make sure that you WRITE to the record format but READ from the file name itself. This is different from the normal EXFMT op code you’d normally use when working with display files. After the READ, check to see that the STATUS field contains a value of 1331; this status code indicates that the display file has timed out. If it does, you can either end the program or perform some other logic.

— Shannon O’Donnell Senior Technical Editor

Midrange Computing

A**************************************************************

A*

A* CRTDSPF FILE(XXX/DSP00D1) SRCFILE(XXX/QDDSSRC) +

A* MBR(DSP00D1) WAITRCD(10)

A*

A**************************************************************

A DSPSIZ(24 80 *DS3)

A CA03(03 'EXIT')

A INVITE

A R SCREEN1

A 1 19'Test Waitrcd Paramter To Timeout DA isplay'

A DSPATR(HI)

A DSPATR(UL)

A 9 28'Input:'

A INPUT 1A B 9 35

A 22 7'F3=Exit'

A COLOR(BLU)

**********************************************************************

*

* CRTBNDRPG PGM(xxx/Dsp00r1) SRCFILE(xxx/QRPGLESRC) +

* MBR(Dsp00r1)

*

*

**********************************************************************

FDsp00d1 CF E Workstn Infds(Infds)

F Maxdev(1)

D Infds DS

D Status *Status

C Dow *IN03 = *OFf

C Write Screen1

C Read Dsp00d1 99LR

C If *In99 = *On And Status = 1331

C Eval *IN03 = *On

C Endif

C Enddo

C Eval *Inlr = *On

Figure 2: Display file DSP00D1 demonstrates use of the INVITE keyword.

Figure 3: Make sure you use the Maxdev keyword in your RPG IV program to cause it to timeout.

Anarchy in the U.K.?

Q: We have Y2K software to be distributed on an AS/400 in the United Kingdom. When distributing files created on our U.S. machine, such as physical files and logical files, the coded character set ID (CCSID) and language ID (LANGID) parameters are 37 and ENU, respectively. However, they’re 285 and ENG on the U.K. machine. What are the implications or problems, if any, that we risk running into if the files were distributed with
U.S. defaults for CCSID and LANGID parameters?

— Mukesh Shah


This email address is being protected from spambots. You need JavaScript enabled to view it.

A: It is impossible to predict what may happen in a mixed CCSID environment such as you describe without in-depth knowledge of the application you are porting. That is why it is critical that the developers of the application have access to and understanding of the AS/400 National Language Support V4R2 (SC41-5101-01, CD-ROM QB3AWC01) and AS/400 International Application Development V4R2 (SC41-5603-01, CD-ROM QB3AQ501) manuals for the AS/400.

Having said that, I will go through one scenario that may or may not be relevant to your application. Assume that you have a control file for field names and that this file is CCSID tagged with 37. Also assume that one of the valid characters used in field names is the dollar ($) sign (or x‘5B’ in CCSID 37) and that you have a field called $Y2KA, which you generate into target RPG application source. Now assume that your application program runs on the customer systems under job CCSID 285 and modifies RPG source in customer CCSID 285 tagged files. Data management causes your control file dollar sign
(x‘5B’) to become a 285 dollar sign (x‘4A’) when read into the application. If your application then outputs the dollar sign to the customer file, the dollar sign is written as
x‘4A’. If the Original Program Model (OPM) compiler attempts to compile the RPG source containing a field name, the compile fails. The key to making this type of scenario work, then, is proper planning and a good understanding of National Language Support.

— Bruce Vining

IBM Rochester

When the Answer Varies

One of IBM’s V4R2 enhancements to RPG was support for varying-length fields, which you can use as return values in procedures. When the fields are used in this way, you can create procedures that work a lot like RPG IV built-in functions such as %EDITC and %TRIM. Before varying-length character fields were supported, it was necessary to wrap procedures that returned a variable-length value in the %TRIM built-in function. This was cumbersome and, because %TRIM required the returned value to be scanned for the first nonblank value, could add a significant amount of processing time.

The declared length of a varying-length character field is the maximum length for a varying-length field. To determine or set the length of data contained in the varying-length field, use the %LEN built-in function. Setting the length of varying-length fields is seldom necessary when using newer free-format op codes such as EVAL. With older fixed-format op codes, it’s necessary to set the length of a varying-length field prior to using it as a result field.

To demonstrate some of the advantages of varying-length fields, I have included some sample procedures that use varying-length fields to return a translated character field. (Download them atwww.midrangecomputing. com/mc). These procedures allow you to use the XLATE op code as a built-in function in expressions. Procedure XLT receives a character string in the first parameter and converts the characters of the string from values specified in the second parameter to values specified in the third parameter.

The converted string is then returned from the XLT procedure. Because parameters passed to XLT are constants, they can be literals or fixed-length character fields.

Procedure DM001R demonstrates how to use this procedure to convert an input string to uppercase.

Rather than wait for IBM to provide built-in functions for op codes such as XLATE, create them yourself. Not only is this easier to do with varying-length fields, but procedures that use varying-length procedures also run faster than those that use %TRIM to remove blanks from char-acter fields.


— David Morris This email address is being protected from spambots. You need JavaScript enabled to view it.

Don’t Be DUPed

Q: We have recently restricted all production data on our AS/400. Because the IS staff has only use rights to production data, they cannot use the Create Duplicate Object (CRTDUPOBJ) command. When this command is used, the system returns a “not authorized” error. I know that other shops have their production data secured from the IS staff. How did you deal with this command? CRTDUPOBJ is used primarily to build work files in QTEMP.

— Darlene Kelley This email address is being protected from spambots. You need JavaScript enabled to view it.

A: I created my own CRTDUPOBJ command and compiled the CL command processing program (CPP) to adopt the authority of the program owner (which is QSECOFR). This allows anyone to use the command with the authority of the security officer. I also added code to allow only the duplicate to be created in a test library.

— Mark McCall This email address is being protected from spambots. You need JavaScript enabled to view it.

A: At a previous employer, we created a CRTDUPOBJ work-alike called Duplicate Production Object (DUPPRDOBJ) with the same keywords and everything. It adopted sufficient authority to perform CRTDUPOBJ, then granted the object’s creator (the person who ran the command) sufficient authority to the new object.

— Michael Polutta This email address is being protected from spambots. You need JavaScript enabled to view it.


BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

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: