Guild Companies, Inc.  
 
Midrange Guru - Tech Tips
OS/400 Edition
Volume 2, Number 26 - April 5, 2002

Odds and Ends

Dear Readers:

Due to the overwhelming response to previous Odds and Ends columns, here are more. I hope they're helpful.

I still have a lot of material to work through. I've received many questions. I can't find answers to some of them. I have received answers to other questions from my associates and contacts, but I still have to verify the solutions they've provided. I will continue to work through your questions, giving priority to those that seem most applicable to a wide audience. Keep the questions and feedback coming .

-- Ted

Question:

I am using the Open Query File (OPNQRYF) command to sort a non-keyed database file. How does the system determine how to sort the data after the key? That is, what happens when two records have the same key? 

Answer:

The system makes no guarantees about the order of records with the same key value. It will get them in whatever order it considers best. You can't depend on them to be in arrival sequence.



Question:

How do I find all of the trigger programs associated with a database file? The Display File Description (DSPFD) command only tells me how many there are (unless I'm overlooking something).

Answer:

You're overlooking something. Try this:

DSPFD FILE(CUSTOMER) TYPE(*TRG)

If you specify OUTPUT(*OUTFILE) to direct-trigger information to a database file, the data will be in the format of file QSYS/QAFDTRG. The record format name is QWHFDTRG.



Question:

Here's the scenario: I'm debugging an RPG IV program. The program hits a chain. The next step goes to the F spec for the file being accessed. I press F10 to step, but the cursor stays on the F spec until finally moving back into the program. Why does this happen, and is there some way to prevent it?

Answer:

The debugger steps once for each input (or output) specification in the record format. Put OPTION(*NODEBUGIO) in an H spec.

I recommend you also include the *SRCSTMT option, so that the compiler uses the sequence numbers from your source member:

OPTION(*SRCSTMT : *NODEBUGIO)



Question:

How can I call an ILE module from an AS/400 COBOL program? Should I use the QCMDEXC API?

Answer:

There are three methods. I can illustrate them by having a COBOL module call the STS03CL module that was used in the February 6, 2002 issue of Midrange Guru. STS03CL's mission is to send a status message to the workstation. It accepts one parameter--a 76-character message that is passed by reference.

Method one is to include the LINKAGE TYPE IS PROCEDURE phrase in the CALL, like this:

Data division.                                
Working-storage section.                      
01  Msg    pic x(76).                         
                                              
Procedure division.                           
Main-logic.                                   
    Move "Doing step 1 ..." to Msg.           
    Call linkage type is procedure "STS03CL"  
        using Msg.                            

If you will be calling this procedure many times, you may prefer the second method. You can put the linkage type in the special names, rather than in the procedure division.

Environment division.                        
Configuration section.                       
Special-names.                               
    Linkage type is procedure for 'STS03CL'. 
                                             
Data division.                               
Working-storage section.                     
01  Msg    pic x(76).                        
                                             
Procedure division.                          
Main-logic.                                  
    Move "Doing step 1 ..." to Msg.        
    Call "STS03CL"      
        using Msg.              

The special-names entry tells the compiler that all calls to STS03CL are to be treated as calls to procedures, not as calls to programs.

If all your external calls are to procedures, not programs, you can omit the linkage type phrases from the source code and specify linkage type in the LINKLIT parameter when you compile.

CRTCBLMOD MODULE(mylib/mymod) 
   SRCFILE(mylib/mysrcf) +
   LINKLIT(*PRC)           

LINKLIT(*PRC) says that all CALLs are to be interpreted as calls to procedures, not programs.

This will get you started. The ILE COBOL Programmer's Guide has more information.



Question:

How can I display an OS/400 IFS file in a Qshell interactive session?

Answer:

Use the cat command:

cat myfile

I know it's strange, because cat's purpose in life is to combine two or more files into one file. However, it writes to standard output, so you can use it to display a file.

By the way, it also works for files in the QSYS.LIB file system:

cat /qsys.lib/mylib.lib/qclsrc.file/sts03cl.mbr



Question:

When I create a comma-separated values (CSV) file with Client Access, I get a nice, compact little file. Records look like this:

61,"DESC",10,25,"TEXT"

But when I use the Copy to Import File (CPYTOIMPF) command to create a CSV file, I get a file that's a lot larger than it should be. The CPYTOIMPF command uses enough space for the full length of each field as follows:

61   ,"DESC                ",10      ,25     

,"TEXT            "

Is there any way to get CPYTOIMPF to create a CSV file that looks like the one Client Access creates?

Answer:

I understand what you are saying; it drives me nuts too. If there's a way, I haven't found it and the people I've asked haven't either.

Sponsored By
TRAMENCO

Learn what's over the horizon for the iSeries and AS/400, and how it will impact your career, by attending the premier training event of 2002. It's the iSeries and AS/400 Connection Conference June 16 – 19, 2002 in Naples Florida. Join 19 of the industries greatest minds including Dr. Frank Soltis, Skip Marchesani, Wayne O. Evans, Susan Gantner, Jon Paris, Marie Finnegan-Cronin, and Howard Arner, Jr. as they deliver AS/400 training and education to prepare you for the challenges of tomorrow. A full agenda of 96 sessions (including 10 hands-on labs) provide practical instruction in a full range of topics, including:

  • Understanding Websphere Development Studio

  • Accessing DB2/400 data from Linux

  • Learning how JavaBeans are used

  • Make the most of RPG IV's built in functions

  • SQL Tricks and Techniques

  • ABCs of System Management

  • And much more!
Whether you are an old pro, or just getting your feet wet, there is something for everyone during this intensive four-day conference. Best of all, your classroom is the Registry Resort and Spa, Naples Florida's premier 5-star resort. To register, or for more information, call 1 800 897.5923, or go to the web at www.tramenco.com. But hurry, you must register before May 15, 2002 to save $200 off the standard registration and be eligible for special hotel rates.

THIS ISSUE
SPONSORED BY:
Aldon Computer Group
TRAMENCO
BACK ISSUES
TABLE OF CONTENTS
One Way to Ease Conversion of RPG II Programs
Odds and Ends
Reader Feedback and Insights: Query Management and MBROPT(*UPDADD)
  Newsletters | Subscribe | Advertise | About Us | Contact | Search | Home  
  Last Updated: 4/5/02
Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.