mgo
OS/400 Edition
Volume 2, Number 64 -- August 23, 2002

Odds and Ends


Dear Readers:

Back by popular demand, here are more "Odds and Ends." I hope you find something of interest.


-- Ted

Question:

Is there a command to get the source type of a source physical file member?

I've written an automated source backup/update program, and if I could get the type of source I could then determine which command to issue to create or compile the source.

 

Answer:

Try Retrieve Member Description (RTVMBRD). There's a SRCTYPE parameter that will do the trick.

DCL  VAR(&LIB)     TYPE(*CHAR) LEN(10)                   
DCL  VAR(&FILE)    TYPE(*CHAR) LEN(10)                  
DCL  VAR(&MEMBER)  TYPE(*CHAR) LEN(10)                
DCL  VAR(&SRCTYPE) TYPE(*CHAR) LEN(10)               
                                                           
RTVMBRD  FILE(&LIB/&FILE) MBR(&MEMBER) SRCTYPE(&SRCTYPE)

Question:

I have two files with the same record format, but different field names. Can I move one record into the other in RPG IV? That is, does RPG IV have anything like CL's CPYF command with FMTOPT(*NOCHK)?

Answer:

You can't reference the record names as fields in RPG IV. The ideal solution would be to use the Copy File (CPYF) command, but since that doesn't fit in your case, here are two ways to handle the copy with RPG.

Here are two files with the same layout, but with different field names:

A* File PAYWORK
A                                      UNIQUE 
A          R PAYREC                           
A            PWCLOCK        3P 0              
A            PWGROSS        7P 2              
A            PWMARSTAT      1                 
A            PWNBRDEP       2P 0              
A            PWNBRPER       3P 0              
A            PWSTATETAX     7P 2              
A            PWLOCALTAX     7P 2              
A          K PWCLOCK                          

A* File PAYHIST
A                                      UNIQUE   
A          R HISTREC                            
A            PHCLOCK        3P 0                
A            PHGROSS        7P 2                
A            PHMARSTAT      1                   
A            PHNBRDEP       2P 0                
A            PHNBRPER       3P 0                
A            PHSTATETAX     7P 2                
A            PHLOCALTAX     7P 2                
A          K PHCLOCK                           

Let's say you want to copy a record in PAYWORK to PAYHIST.

One easy way is to rename the fields in the input file so that they have the same names as the corresponding fields in the output file:

Fpaywork   if   e           k disk                    
Fpayhist   o    e             disk                    
Ipayrec                                               
I              pwclock                     phclock    
I              pwgross                     phgross    
I              pwmarstat                   phmarstat  
I              pwnbrdep                    phnbrdep   
I              pwnbrper                    phnbrper   
I              pwstatetax                  phstatetax 
I              pwlocaltax                  phlocaltax 
C                   read      paywork                 
C                   dow       not %eof(paywork)       
C                   write     histrec                 
C                   read      paywork                 
C                   enddo                             
C                   eval      *inlr = *on             

The other way is to use externally described data structures to give names to the record formats:

Fpaywork   if   e           k disk                     
Fpayhist   o    e             disk                     
D work          e ds                  extname(paywork) 
D hist          e ds                  extname(payhist) 
C                   read      paywork                  
C                   dow       not %eof(paywork)        
C                   eval      hist = work              
C                   write     histrec                  
C                   read      paywork                  
C                   enddo                              
C                   eval      *inlr = *on             

Question:

I need to provide a way for our users to enter a free-format comment of a few hundred characters. If I create a single input field for the comment, the users can insert and delete text, but it looks bad.

Figure 1

If I use several input fields instead, the display looks much nicer, but insert and delete don't work across lines.

Figure 2

Can you help?

Answer:

Define the comments field as one long field in the DDS. Use the Continued-entry field (CNTFLD) keyword to divide the field into more than one line. CNTFLD takes one parameter, which isthe number of characters to be displayed on each line.

The following DDS will generate the display you require. Notice that the 240-byte NOTES field is displayed on eight lines, thirty bytes per line.

A          R REC                                  
A                                  4  3'Name:'    
A            NAME          30   B  4 10           
A                                  6  2'Title:'   
A            TITLE         30   B  6 10           
A                                  8  2'Notes:'   
A            NOTES        240   B  8 10CNTFLD(30)

For this to work properly, you must use an enhanced workstation controller. I have had no trouble using this technique with a Client Access Express session.



Question:

Is this your full time job or just a hobby on the side? lol

Answer:

I just do this on the side. However, sometimes I spend so much time putting this newsletter together that it almost seems like a full-time job.

-- Ted


Sponsored By
COMMON

REGISTER FOR COMMON IN DENVER, OCT. 13-17

Get the IT training you need by attending COMMON Users Group's Fall 2002 IT Education Conference & Expo, October 13-17 in Denver. Early Bird registration is $1,150 until September 4.

Choose from over 720 sessions and labs covering a wide range of industry topics. Also receive training from J.D. Edwards, MAPICS, and other vendors.

Don't miss out! Go to www.common.org


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
COMMON


BACK ISSUES

TABLE OF CONTENTS

Use Monitor to Trap QCMDEXC Errors

Odds and Ends

Reader Feedback and Insights: More on TCP/IP Printing


Editors
Howard Arner
Joe Hertvik
Ted Holt
David Morris

Managing Editor
Mari Barrett

Publisher and
Advertising Director

Jenny Thomas

Contact the Editors
Do you have a gripe, inside dope or an opinion?
Email the editors:
editors@itjungle.com



Last Updated: 8/23/02
Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
All content published in Guild Companies publications is for informational purposes only, and accuracy of said content is not guaranteed by Guild Companies and its staff. Guild Companies and its staff do not warrant that its content is error-free. Also, Guild Companies and its staff are not responsible for the availability or content accuracy of other Web sites and services that may be linked to this Web site and service.
Use of any content published in Guild Companies publications is at your own risk.