fhg
Volume 7, Number 21 -- June 6, 2007

Special Files Can Do It All, Part 2

Published: June 6, 2007

Hey, Ted:

I just wanted to tell you how much I appreciate your real world ideas and examples. They are the kinds of ideas that can really help smaller shops do the practical, bulletproof kinds of jobs we need to do. I have used your special files technique to replace some old System/36 #GSORT sales analysis programs. I know, it takes us a long time to convert, but some of these programs have not changed in 15 years.

We have S/36 OCL procedures that display a screen to ask for parameters, use #GSORT to create an address-out file using the parameters for selection and sorting, and call a program. We replaced the addrout sorts with special files.

Thanks again for the special-files tip. I think we are going to use it in conjunction with CGI to bring reports to the Web with only a few changes to the back-end code. Should be cool.

--Jim Horn


Thanks to Jim for sharing his use of special files with the rest of us. A lot of shops have old code that still serves its purpose, and that needs to be tweaked, but completely rewriting the application is out of the question.

I worked up an example based on Jim's code. If you find any mistakes in it, don't laugh too hard. It's been almost 20 years since I wrote System/36 code.

Here's the RPG II program that reads the sorted data and produces a report.

H                                                                    SORT4
 *                                                                        
FADDROUT IR  F   3   3    T      EDISK                                    
FQCUSTCDTIP  F      60            DISK                                    
FQSYSPRT O   F     132     OF     PRINTER                                 
 *                                                                        
E    ADDROUT QCUSTCDT                                                     
 *                                                                        
IQCUSTCDTNS  01                                                           
I                                        1   60CUSTNO                     
I                                        7  14 LNAME                      
I                                       15  17 INIT                       
I                                       37  38 STATE                      
I                                       49  542BALANC                     
 *                                                                        
C**                                             HILOEQ                    
C           BALANC    COMP 500.00               25  25                    
OQSYSPRT H   01   1P                                                      
O       OR        OF                                   
O                                   13 'CREDIT REPORT' 
O                         UDATE Y   25                 
O                                   32 'PAGE'          
O                         PAGE  4   36                 
O        H 21     1P                                   
O       OR        OF                                   
O                                    5 'STATE'         
O                                   16 'CUSTOMER'      
O                                   43 'BAL DUE'       
O        D 1      01                                   
O                         STATE      2                 
O                         LNAME     16                 
O                         INIT      21                 
O                         CUSTNO    28                 
O                         BALANCJ   44                 
O                    25             49 '***'           

And here's the OCL that sorts the data and calls the report program.

// LOAD #GSORT                                         
// FILE NAME-INPUT,LABEL-QCUSTCDT,DISP-SHRRM           
// FILE NAME-OUTPUT,LABEL-ADDROUT,RECORDS-100,RETAIN-J 
// RUN                                                 
     HSORTA     2A                                     
     I C  48  48NEC1                                   
     FNC  37  38                                       
// END                                                 
// LOAD SORT4
// FILE NAME-ADDROUT                                   
// FILE NAME-QCUSTCDT,DISP-SHRRM                       
// RUN                                                 

Jim modified the F specs to convert the RPG II program to RPG III, then used CVTRPGSRC to RPG IV. He removed the addrout file and defined his input file as a special file.

H dftactgrp(*no) actgrp(*new)                                          
                                                                       
FQCUSTCDT  IP   F   60        SPECIAL PGMNAME('SORT4SPEC')             
FQSYSPRT   O    F  132        PRINTER OFLIND(*INOF)                    
 *                                                                     
IQCUSTCDT  NS  01                                                      
I                                  1    6 0CUSTNO                      
I                                  7   14  LNAME                       
I                                 15   17  INIT                        
I                                 37   38  STATE                       
I                                 49   54 2BALANC                      
 *                                                                     
C**                                             HILOEQ                 
C     BALANC        COMP      500.00                             25  25
OQSYSPRT   H    1P                       01                            
O         OR    OF                                                     
O                                           13 'CREDIT REPORT'         
O                       UDATE         Y     25                         
O                                           32 'PAGE'                  
O                       PAGE          4     36                         
O          H    1P                  2  1                               
O         OR    OF                                                     
O                                            5 'STATE'                 
O                                           16 'CUSTOMER'
O                                           43 'BAL DUE' 
O          D    01                  1                    
O                       STATE                2           
O                       LNAME               16           
O                       INIT                21           
O                       CUSTNO              28           
O                       BALANC        J     44           
O                  25                       49 '***'     

Jim kept his prompting logic. Instead of building sort specs and calling #GSORT, he used the input fields to create an SQL command, which he stuffed into the local data area. His special-file program, immediately below, retrieved the SQL command, from which it prepared and opened a cursor.

H option(*srcstmt: *nodebugio) dftactgrp(*no) actgrp(*caller)         
                                                                      
D Buffer        e ds                  extname(QCUSTCDT)               
D LDA            uds                  dtaara(*LDA)                    
D  SqlCommand           501   1000                                    
                                                                      
C     *ENTRY        PLIST                                             
C                   PARM                    OPTION            1       
C                   PARM                    STATUS            1       
C                   PARM                    ERROR             5 0     
C                   PARM                    BUFFER                    
C                                                                     
C/EXEC SQL                                                            
C+  set option closqlcsr=*endactgrp                                   
C/end-exec                                                            
C                                                                     
C                   select                                            
C                   when      option = 'O'                            
C                   reset                   Buffer                    
C                   in        lda                                     
C                                                                     
C/EXEC SQL                                                            
C+  prepare p1 from :SqlCommand                                       
C/end-exec                                 
C                                          
C/EXEC SQL                                 
C+  declare c1 cursor for p1               
C/end-exec                                 
C                                          
C/EXEC SQL                                 
C+  open  c1                               
C/end-exec                                 
C                                          
C                   when      option = 'C' 
C/exec sql                                 
C+   close c1                              
C/end-exec                                 
C                   eval      *inlr = *on  
C                   when      option = 'R' 
C/exec sql                                 
C+   fetch c1 into :Buffer                 
C/end-exec                                 
C                   endsl                  
C                                          
C                   select                         
C                   when      sqlstt < '02000'     
C                   eval      Status = '0'         
C                   when      sqlstt = '02000'     
C                   eval      Status = '1'         
C                   other                          
C                   eval      Status = '2'         
C                   endsl                          
                                                   
C                   move      sqlstt        error  
C                   return                         

I admire Jim's creativity. In case anybody wants to play with this technique, I've put all the example code in a Zip file that you can download. The QCUSTCDT file is in library QIWS.

Thanks again to Jim for sharing his solution.

--Ted


RELATED STORIES

Special Files Can Do It All

Use Special Files to Access the IFS



                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot


Sponsored By
WORKSRIGHT SOFTWARE

Do you need area code information?
Do you need ZIP Code information?
Do you need ZIP+4 information?
Do you need city name information?
Do you need county information?
Do you need a nearest dealer locator system?

We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

Just call us and we'll arrange for 30 days FREE use of either
ZIP/CITY or PER/ZIP4.

WorksRight Software, Inc.
Phone: 601-856-8337
Fax: 601-856-9432
E-mail: software@worksright.com
Web site: www.worksright.com


Senior Technical Editor: Ted Holt
Technical Editors: Howard Arner, Joe Hertvik, Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Brian Kelly, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

New Generation Software:  Leading provider of iSeries BI and financial management software
COMMON:  Join us at the Annual 2008 conference, March 30 - April 3, in Nashville, Tennessee
LASERTEC USA:  Fully integrate MICR check printing with your existing application


IT Jungle Store Top Book Picks

The System i Pocket RPG & RPG IV Guide: List Price, $69.95
The iSeries Pocket Database Guide: List Price, $59.00
The iSeries Pocket Developers' Guide: List Price, $59.00
The iSeries Pocket SQL Guide: List Price, $59.00
The iSeries Pocket Query Guide: List Price, $49.00
The iSeries Pocket WebFacing Primer: List Price, $39.00
Migrating to WebSphere Express for iSeries: List Price, $49.00
iSeries Express Web Implementer's Guide: List Price, $59.00
Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
WebFacing Application Design and Development Guide: List Price, $55.00
Can the AS/400 Survive IBM?: List Price, $49.00
The All-Everything Machine: List Price, $29.95
Chip Wars: List Price, $29.95

 

The Four Hundred
IBM's Rumored System i Power6 Server Plans

IBM Tries Online Discounts to Move Server, Storage Gear

The Market for Servers in Europe Is Hot

Mad Dog 21/21: Missing Inaction

The Linux Beacon
Red Hat Puts Out Fedora 7 Community Release

Novell Posts Another Loss in the Second Quarter

Microsoft-Novell Deal Has Escape Clause

As I See It: Operating on Overload

Four Hundred Stuff
Maximum Availability Shakes Up Business Plan

SEA Delivers Web and Mobile Consoles for absMessage

Aldon Boosts Identity Tracking in ALM Tool

Quadrant Bolsters FastFax with Dynamic Line Allocation

Big Iron
Virtualization, Consolidation Drive Server Sales in Q1

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
June 2, 2007: Volume 9, Number 22

May 26, 2007: Volume 9, Number 21

May 19, 2007: Volume 9, Number 20

May 12, 2007: Volume 9, Number 19

May 5, 2007: Volume 9, Number 18

April 28, 2007: Volume 9, Number 17

The Windows Observer
All Your IT Dollars Are Belong to Microsoft

Microsoft-Novell Deal Has Escape Clause

Virtualization, Consolidation Drive Server Sales in Q1

As I See It: Operating on Overload

The Unix Guardian
The Persistence of Unix

HP Pursues Telcos with New Entry NonStop Server

The Market for Servers in Europe Is Hot

As I See It: Operating on Overload

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

THIS ISSUE SPONSORED BY:

WorksRight Software
Help/Systems
Guild Companies



TABLE OF CONTENTS
Special Files Can Do It All, Part 2

Load a Spreadsheet from a DB2/400 Database

Admin Alert: Weird i5 User Profile Sign-On Secrets

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
Keeping a trace of each CL

Problem with "cpyfrmimpf"

FTP a library to a server

Uploading data from Excel to the iSeries

How to calculate the last day of the month





 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement