Go to Home Page
Questions?
Call 1-800-572-5517
 
  Go to Home Page  
  See all products
  See price schedules
  See manuals, tutorials, articles
  Download a free 30-day trial
  See user testimonials
  About Pacific Systems Group
 
  Welcome Rocket Software MXI Users - Learn about Spectrum SMF Writer for MXI
  Choose Spectrum Writer to add 4GL to your product
  Report Writer Speedup Tips Article

Spectrum Writer Overview of Features

Chapter 3. Creating ASCII Files

 


Chapter Table of Contents

Why PC Formatting Is Necessary
How to Create a PC File in 5 Minutes
Translating the PC File to ASCII
Creating Native ASCII Files on the Mainframe


Spectrum Writer's easy 4GL language is also perfect for quickly producing custom output files. You can produce files for further use on the mainframe. Or for use on PCs or other ASCII-based platforms. For example, with just one command Spectrum Writer will automatically format your mainframe data as a comma delimited PC file. Such files can be downloaded to your PC and imported directly into virtually any spreadsheet, database, presentation, or word processor program.

Producing PC files with Spectrum Writer is easy because you use the same control statements that you use to produce reports. You simply add an OPTIONS statement that causes the "report" to be specially formatted as a PC file.

               
   OPTIONS: PC

The above statement specifies that the "report" should be formatted as a PC file.

Why PC Formatting Is Necessary

The PC option tells Spectrum Writer to format your mainframe data so that PC programs can use it (once it has been downloaded to the PC.) Why is this special formatting necessary? Because most mainframe files contain fields that are formatted in ways that cannot be used by PC programs. For example, the following types of mainframe data are not acceptable to most PC programs:

  • packed numeric fields
  • binary numeric fields
  • fields with implied decimal points
  • numeric fields with internal signs in the last digit (produced by many COBOL programs)
  • date fields stored in packed, binary, or hexadecimal format
  • Julian dates
  • bit fields

    As a mainframe report writer, Spectrum Writer naturally can process these kinds of data. The PC option tells Spectrum Writer to reformat your mainframe data into the kind of character data that PC programs can process. Spectrum Writer also delimits your output file, putting quotation marks around character strings, and separating each field with a comma. Files in this standard format (called "delimited ASCII") can be imported into virtually all popular PC programs.


    How to Create a PC File in 5 Minutes

    You remember that you can produce a Spectrum Writer report with just two statements. The INPUT statement identifies the input file to use. And the COLUMNS statement specifies the columns desired in the output.

    To create a PC file with Spectrum Writer, we simply add a third statement:

                   
       OPTIONS: PC
    

    The OPTIONS statement tells Spectrum Writer that we want the output formatted as a PC file.

    Figure 4 illustrates this. The top box in this Figure shows our three control statements. Based on these statements, Spectrum Writer creates a PC file containing the requested data in delimited ASCII format.

    The PC screen shows the Lotus 1-2-3 spreadsheet obtained by importing Spectrum Writer's PC file. The spreadsheet contains the mainframe data we requested, properly laid out into rows and columns. There are even column headings for each column. (Once imported into Lotus, we also used its graphing facility to graph the AMOUNT and TAX columns.)

    That's all there is to creating custom PC files with Spectrum Writer. With three simple statements we did all of the data selection and reformatting that would otherwise have taken an entire COBOL program to do.



    Figure 4


    Translating the PC File to ASCII

    In the preceding example, the PC file that Spectrum Writer created was an EBCDIC file. That makes it easy to work with on the mainframe. (For example, you can browse it with ISPF to verify the contents and format.) So how was Lotus 1-2-3 able to use this EBCDIC file? The file transfer program translated it to ASCII during the download.

    When downloading PC files, look for a "Translate ASCII" or similar option and make sure it is selected. Also, select the "CRLF" option. It adds ASCII carriage-return/line-feed bytes to the end of each record, which most PC programs expect.

    This is a very convenient way to convert your EBCDIC mainframe data to ASCII. While on the mainframe, you can use mainframe tools to examine it. Then convert the file to ASCII as you transfer it to your PC. There you can use standard PC tools to work with it.

    You may wonder why you couldn’t just translate the whole, raw mainframe data file this same way. The answer is that you could do that, as long as the mainframe file doesn't contain any binary fields. (The binary fields would also get "translated" during the transfer, resulting in garbage appearing in those fields on your PC.) If the mainframe file has any binary fields (such as packed, binary integer or bit fields) then you need Spectrum Writer to first reformat the data into a PC file. All of the binary fields will be expanded into EBCDIC character fields. The resulting PC file will be pure EBCDIC — no binary data in it. Now it’s safe to download it to your PC using the ASCII translation option.


    Creating Native ASCII Files on the Mainframe

    If you prefer, Spectrum Writer can also produce true ASCII files directly on the mainframe. This is useful if you want to build an output record that contains some ASCII character data along with some binary data. Such mixed records can’t simply be translated as a whole.

    Figure 4.1 shows an example of creating a native ASCII file with Spectrum Writer. In this example, we want to produce an output file containing the same data as in Figure 4. However, this time we want fixed-format records rather than a comma-delimited file. We want the character fields to be in ASCII. However, we want the AMOUNT and TAX fields to be 4-byte binary integer fields in the output file.

    The MAINFRAME option in Figure 4.1 tells Spectrum Writer that we are producing a mainframe-type file (not a comma-delimited PC file). This option sets the inter-column spacing to zero bytes. It also suppresses titles, column headings and totals.

    On the COLUMNS statement, we specify the ASCII option for the fields that we want to be written in ASCII character format. For the SALES-DATE and SALES-TIME fields, we also specified the date and time formats that we wanted for the output file. All of these fields will now be written in ASCII rather than EBCDIC. The AMOUNT and TAX fields will be written as 4-byte binary integer fields.

    The lower box in Figure 4.1 shows some of the resulting records (in hex format). That’s all there is to writing ASCII files directly on your mainframe with Spectrum Writer. When downloading ASCII files like this one to your PC, remember to perform a binary download. That is, turn off the ASCII translation option. However, you may still want to use the "CRLF" option (depending on how you will use the file on the PC). This option adds carriage-return/line-feed bytes to the end of each downloaded record.



    Figure 4.1



  • Proceed to Chapter 4. Web Report Examples
  • Return to Booklet Table of Contents


  • Copyright 2024.
    Pacific Systems Group.
    All rights reserved.


    Spectrum Writer 4GL - the economical alternative to SAS, Easytrieve, DYL-280...

    Home | Products | Prices | Documentation | 30-Day Trials | Customer Reviews | Company
    Send Your Comments or Questions