• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Odds and Ends

    August 23, 2002 Timothy Prickett Morgan

    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

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 64 -- August 23, 2002

    Sponsored by
    ARCAD Software

    DevSecOps & Peer Review – The Power of Automation

    In today’s fast-paced development environments, security can no longer be an afterthought. This session will explore how DevSecOps brings security into every phase of the DevOps lifecycle—early, consistently, and effectively.

    In this session, you’ll discover:

    • What DevSecOps is and why it matters?
    • Learn how to formalize your security concerns into a repeatable process
    • Discover the power of automation through pull requests, approval workflows, segregation of duties, peer review, and more—ensuring your data and production environments are protected without slowing down delivery.

    Whether you’re just getting started or looking to enhance your practices, this session will provide actionable insights to strengthen your security posture through automation and team alignment to bring consistency to the process.

    Watch Now!

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Validating a User Password Timestamps and V5R1 RPG

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 64

This Issue Sponsored By

    Table of Contents

    • More on TCP/IP Printing
    • Use Monitor to Trap QCMDEXC Errors
    • Odds and Ends

    Content archive

    • The Four Hundred
    • Four Hundred Stuff
    • Four Hundred Guru

    Recent Posts

    • What You Will Find In IBM i 7.6 TR1 and IBM i 7.5 TR7
    • Three Things For IBM i Shops To Consider About DevSecOps
    • Big Blue Converges IBM i RPG And System Z COBOL Code Assistants Into “Project Bob”
    • As I See It: Retirement Challenges
    • IBM i PTF Guide, Volume 27, Number 41
    • Stacking Up Power11 Entry Server Performance To Older Iron
    • Big Blue Boosts IBM i Support In Instana, Adds Tracing
    • It Is Time To Tell Us What You Are Thinking And Doing
    • IBM i PTF Guide, Volume 27, Number 40
    • The GenAI Boom Is Only Slightly Louder Than The Dot Com Boom

    Subscribe

    To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

    Pages

    • About Us
    • Contact
    • Contributors
    • Four Hundred Monitor
    • IBM i PTF Guide
    • Media Kit
    • Subscribe

    Search

    Copyright © 2025 IT Jungle