02
Sat, Nov
2 New Articles

The AS/400 Report Download Utility

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

Suppose a user in accounting uses his PC spreadsheet package to produce reports, such as financial statements. This user wants to take information from the AS/400 and move it into a PC spreadsheet to process it or spruce it up for presentation.

Such an operation is a nuisance for the programmer because of the steps involved.

o Convert the data on the AS/400 into a format that is meaningful to the user when it is downloaded to the PC.

o Use PC Support to get the data to the PC by creating a transfer request and downloading the data.

o Once the file is on the PC, import it to a spreadsheet package, like Lotus or Excel, then parse the file (parsing is the process of assigning text data to spreadsheet columns).

o Finally, strip extra baggage like page headings.

While this process is effective, it's too clumsy to perform on an ongoing basis.

The user-driven AS/400 Report Download Utility performs all these steps, freeing programmers and users to spend their time more productively.

The utility is an example of Visual Basic (VB) client/server coding. It is a client/server application that allows PC users to download an AS/400 report into a Microsoft Excel spreadsheet, Microsoft Word document, or PC text file- all from a Windows-based PC.

There are no PC Support transfer requests, file description files (FDFs), or intermediate steps-the PC Support router is a direct conduit. So instead of programmers downloading data to PCs, users can download data themselves by following these simple steps.

o Generate a query on the AS/400 to collect and summarize the data into report form or run an existing AS/400 report. The report is not printed; it's kept in an output queue.

o Call the Report Download Utility from the PC. To display a list of spooled files, enter an output queue name or select one from the list.

o Select and download a spooled file. Once the data is downloaded, the utility also can run a specified macro to do parsing, stripping, formatting, calculating, printing, and anything else the PC program is capable of.

o Without leaving the download utility, select the next file to be downloaded, or simply begin processing the information using the PC application.

The macro is attached to the download process, so the process is automated for the user's future use. The next time the user wants to download the same report, the macro is called again, thereby automating the entire process.

The utility is useful because of its ability to automatically run an Excel or Word macro over the downloaded data. The utility downloads a spooled file to a PC spreadsheet or document and then invokes saved macro instructions to process the data. The macros must be prerecorded and stored in a macro sheet (Excel) or a template (Word) before the utility can execute them.

This utility can be modified to work with other products, such as WordPerfect or Lotus 1-2-3. Programmers who want to modify the VB source code must use Microsoft's Visual Basic.

The Client/Server Platform

The AS/400 Report Download utility is a nuts-and-bolts client/server application. The components are simple and common: a VB program, an RPG program, CL programs, physical files, and an Intersystem Communication Function (ICF) file.

The link from the PC Support router to the RPG partner program is achieved through the ICF file. Support for the functions of ICF files is built into OS/400 and PC Support for Windows.

A standard Advanced Program-to-Program Communications (APPC) relationship, established through the PC Support router, maintains the link between the AS/400 and the PC. Data is then transported over the link.

Some of the data passed back and forth takes the form of messages from one program to the other. The PC program sends requests to the AS/400 program. The AS/400 collects the requested information and sends it back with messages telling the PC the status of the request.

For information on installing this utility, see the accompanying sidebar.

How to Use It

To use this utility, the user starts PC Support and Windows. The utility uses only the PC Support router; it doesn't require any workstation function (WSF) sessions. Once PC Support is started, the user launches the utility the same way he would launch any other Windows application-by double-clicking the icon (see 1). The install process creates a program group and two icons.

To use this utility, the user starts PC Support and Windows. The utility uses only the PC Support router; it doesn't require any workstation function (WSF) sessions. Once PC Support is started, the user launches the utility the same way he would launch any other Windows application-by double-clicking the icon (see Figure 1). The install process creates a program group and two icons.

The utility checks to make sure that the PC Support router is loaded. Next, it checks the standard installation directories for Microsoft Excel and Word. The opening screen for the utility is then presented (see 2).

The utility checks to make sure that the PC Support router is loaded. Next, it checks the standard installation directories for Microsoft Excel and Word. The opening screen for the utility is then presented (see Figure 2).

The user can specify an output queue or click on Browse Outqs to present a list of the output queues to which he's authorized (see 3). Once the user selects an output queue, the screen displays a list of spooled files and the option buttons that represent the features available to process the downloaded report (see 4). Excel and Word options will be visible only if the utility finds them in their standard directories.

The user can specify an output queue or click on Browse Outqs to present a list of the output queues to which he's authorized (see Figure 3). Once the user selects an output queue, the screen displays a list of spooled files and the option buttons that represent the features available to process the downloaded report (see Figure 4). Excel and Word options will be visible only if the utility finds them in their standard directories.

If the user is unsure which spooled file he wants to process, he can preview it as shown in 5. Scrolling through the preview display will reveal the first 150 lines (about three pages) of the file. Report widths of 132 or 198 columns display in correspondingly smaller fonts than 80 column reports. (Any overprinting causes additional lines to be displayed as illustrated by the report title.

If the user is unsure which spooled file he wants to process, he can preview it as shown in Figure 5. Scrolling through the preview display will reveal the first 150 lines (about three pages) of the file. Report widths of 132 or 198 columns display in correspondingly smaller fonts than 80 column reports. (Any overprinting causes additional lines to be displayed as illustrated by the report title.

When the user chooses to download a report to Word or Excel and run a macro, a dialog box comes up (see 6). Selecting the Run macro box prompts the user for the macro name. Word macros are kept in a template (.DOT files), and Excel macros are kept in a macro sheet (.XLM files). The macro must be prerecorded and stored before it can be referenced.

When the user chooses to download a report to Word or Excel and run a macro, a dialog box comes up (see Figure 6). Selecting the Run macro box prompts the user for the macro name. Word macros are kept in a template (.DOT files), and Excel macros are kept in a macro sheet (.XLM files). The macro must be prerecorded and stored before it can be referenced.

When the user chooses to download a report to a PC text file; he is presented with the dialog box shown in 7. This box offers the option to Replace file or to Add to file. With this feature the user can accumulate several AS/400 reports into one file.

When the user chooses to download a report to a PC text file; he is presented with the dialog box shown in Figure 7. This box offers the option to Replace file or to Add to file. With this feature the user can accumulate several AS/400 reports into one file.

Modifications to the Utility

Consider the utility a starting point. It can be modified to do other things, such as interface to other DDE-capable software packages like WordPerfect or Lotus. Programmers can even extract routines from the utility and use them to start new applications. For instance, instead of downloading spooled files, the utility can be modified to download database files. (Indeed, spooled files are copied to database files before they are transmitted.)

Programmers can create bitmap pictures in a utility like Paintbrush and insert them into the utility's forms. For example, the utility's opening form has been enhanced with a personalized logo and 3-D controls (see 8).

Programmers can create bitmap pictures in a utility like Paintbrush and insert them into the utility's forms. For example, the utility's opening form has been enhanced with a personalized logo and 3-D controls (see Figure 8).

How It Works

The AS/400 Report Download Utility is an inclusive and full-function client/server application that ties together several elements of today's application solutions-the AS/400, Windows, PC Support, Microsoft Excel, and Microsoft Word. The help system explains all features of the utility and is accessed from most menus (see 9).

The AS/400 Report Download Utility is an inclusive and full-function client/server application that ties together several elements of today's application solutions-the AS/400, Windows, PC Support, Microsoft Excel, and Microsoft Word. The help system explains all features of the utility and is accessed from most menus (see Figure 9).

The utility is written in VB, and it uses a feature of PC office systems called Dynamic Data Exchange (DDE) to link objects within a VB program to other programs running in Windows. DDE also sends commands to other Windows applications, making functions within Word or Excel available to the VB program.

This VB client/server utility is central to the process of putting all the players together in a cooperative processing solution. This is a role that VB is good at.

Chris Peters is a senior programmer/ analyst for Murphey Favre Securities Service. He can be reached on Compuserve at 76714,1253 or on MC-BBS.

REFERENCES Peters, Chris. AS/400 Client/Server Programming with Visual Basic. Carlsbad, Calif.: Midrange Computing, 1995. Microsoft Corporation. Microsoft Visual Basic Programmer's Guide. Redmond, Wash.: Microsoft Press, 1993. PC Support/400 API Reference (SC41-8254, CD-ROM QBKA6102).

Installing the AS/400 Report Download Utility

Since there are two parts to this client/server utility-the AS/400 part and the PC part-the installation process likewise has two parts. Installation on the AS/400 need be done only once per AS/400; the programs are then available to all users. Installation on the PC must be done on each PC that uses the utility.

You can download a free copy of this utility from MC-BBS. Use a modem to call 619-931-9909. From the Files area, select "MC Magazine's Published Files for AS/400," then download the self-extracting file named RDUPKG.EXE. To extract the utility, copy it into an empty subdirectory on your hard drive and execute RDUPKG from a DOS prompt.

Installing the Utility-AS/400 Code

1. With PC Support running and shared folders active, go to the Windows Program Manager or File Manager. Open the File menu and select Run.

2. Specify the directory containing the expanded files transmitted from MC-BBS.

3. Run the SETUP400 program. (This setup program is a modified version of the VB source code generated by the Application Setup Wizard.) From within the SETUP400 program, the Shell command is used to run a batch file. Since the SETUP400 program can't detect if the batch file runs successfully, the batch file pauses at the end for you to examine the screen messages for errors.

During the installation process, the utility creates an AS/400 library named VBSPL where the AS/400 portion of the utility resides. Because of required hard-coded references to a specific library, you cannot run the utility from any other library without modifying the source code. The utility also creates source files to receive the uploaded AS/400 source code members and uploads them with the PC Support file transfer program RFROMPCB.EXE. Finally, the utility compiles the AS/400 physical files, the ICF file, and the RPG and CL programs.

Source Code for the AS/400

When you download this utility from the MC-BBS, all the source code is included for the elements of the utility. (There's a simple help system, too.) The large amount of code in this utility prohibits us from publishing it in this article.

Installing the AS/400 portion of the Download Utility creates the source files QDDSSRC, QRPGSRC, and QCLSRC in library VBSPL. These source files contain all the AS/400 code for the utility. To help sort things out, a brief description of the AS/400 objects follows. All objects are created in library VBSPL.

ICF File

VBSPLF1 is a standard ICF file for APPC connections. It contains fields for transporting data and messages between the PC and the AS/400.

CL Programs

VBSPLF1C sets the AS/400 environment for the utility (establishes the library list and creates temporary files) and calls VBSPLF1R, the main AS/400 partner program.

CHEKOUTQ checks to see if a requested AS/400 output queue exists.

GETOUTQS loads physical file PQLIST with a list of AS/400 output queues.

GETSPLFS loads physical file PTLIST with a list of AS/400 spooled files for a specific output queue.

GETSPLE loads physical file PDDATA with records from a specific AS/400 spooled file.

RPG

VBSPLF1R program is a standard APPC application communicating through an ICF file. It is the main AS/400 partner program. It handles the APPC conversation with the PC and calls the other AS/400 programs.

Installing the Utility-PC Code 1. The installation program for the PC portion of the code is also a Windows Setup program. Again, open the file menu and select Run. This time, select the program SETUP.EXE.

2. Designate the directory to receive the application; the rest is automatic. This process installs the utility and the Dynamic Link Libraries (DLLs) VBRUN300 and DDEML, and creates two program icons in a new program group.

Running the Utility

To run the utility, PC Support must be running under Windows. The support for the APPC conversation in this client/server relationship comes with OS/400 and PC Support.

This utility requires two Windows fonts-Courier New and Terminal. These nonproportional fonts align properly in subfile-like lists.

Depending on how your AS/400's security is set up, you may have to grant users authority to access the database files in VBSPL that come with the utility- PDDATA, PQLIST, and PTLIST.

Source Code for the PC

A discussion of the VB source code files included in the MC-BBS transmission is beyond the scope of this article. However, all of the utility's VB and client/server code and techniques are explained in AS/400 Client/Server Programming with Visual Basic published by Midrange Computing.


The AS/400 Report Download Utility

Figure 1 Report Download Icon

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 2 Report Download Screen

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 3 Browsing Output Queues

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 4 Displaying Spooled Files

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 5 Previewing a Spooled File

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 6 Loading a Word Macro

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 7 Writing to a Text File

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 8 Personalized Version

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 9 Help Window

 UNABLE TO REPRODUCE GRAPHIC 
The AS/400 Report Download Utility

Figure 10 RDUPKG.EXE Programs

 All components for this utility are contained in the self-extracting file: RDUPKG.EXE This file can be found in the download area of the MC-BBS. 

Chris Peters has 32 years of experience with IBM midrange and PC platforms. Chris is president of Evergreen Interactive Systems, a software development firm and creators of the iSeries Report Downloader. Chris is the author of i5/OS and Microsoft Office Integration Handbook, AS/400 TCP/IP Handbook, AS/400 Client/Server Programming with Visual Basic, and Peer Networking on the AS/400. He is also a nationally recognized seminar instructor and a lecturer in the Computer Science department at Eastern Washington University. Chris can be reached at This email address is being protected from spambots. You need JavaScript enabled to view it..


MC Press books written by Chris Peters available now on the MC Press Bookstore.

i5/OS and Microsoft Office Integration Handbook i5/OS and Microsoft Office Integration Handbook
Harness the power of Office while exploiting the i5/iSeries database.
List Price $79.95

Now On Sale

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: