• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • QTEMP Is A Different Animal

    November 15, 2016 Hey, Ted

    I have a problem with an FTP script. I wish to send a file in QTEMP to a remote system, but the script tries to send the file from QGPL instead. The PUT command does not tell which library to send the file from because our standards prohibit the use of hard-coded library names. Any thoughts will be appreciated.

    –Al

    I commend you and other wise people in your shop for outlawing the hard-coding of library names, Al. The library list is a wonderful feature of IBM i, a feature that is sorely missing from other database systems. I have mentioned this before.

    However, QTEMP is a different animal. Since each job has its own QTEMP library, there is no way two users can step on one another’s feet. I suggest that you push to change the standards to make an exception of QTEMP. That would solve your FTP problem.

    If you are successful in having the policy changed, then I recommend the next step be to consider how best to hard code QTEMP. I’ll show you what I mean.

    Here’s a program that uses QTEMP.

    pgm
    
       dcl   &Abending      *lgl
       dcl   &MsgKey        *char      4
       dcl   &PgmName       *char     10
       dcl   &Sender        *char     80
    
       monmsg cpf0000 exec(goto Abend)
    
       /* Retrieve the program name. */
       sndpgmmsg msg(' ') topgmq(*same) msgtype(*info) keyvar(&msgkey)
       rcvmsg    pgmq(*same) msgtype(*info) sender(&sender) rmv(*yes)
       chgvar    &PgmName   %sst(&Sender 56 10)
    
       /* Create temporary objects */
       crtdtaara    qtemp/Sequence    *dec    (3 0)
    
       crtpf  qtemp/billwork1
       crtpf  qtemp/billwork2
       crtpf  qtemp/billwork3
    
       ovrdbf billwork1  tofile(qtemp/billwork1)
       ovrdbf billwork2  tofile(qtemp/billwork2)
       ovrdbf billwork3  tofile(qtemp/billwork3)
    
       call Bill500r
    
       dltovr billwork1
       dltovr billwork2
       dltovr billwork3
    
       return
    
    Abend:
       if (&Abending) do
          sndpgmmsg  msgid(cpf9898) msgf(qcpfmsg) +
                       msgdta('Unexpected error in' *bcat &PgmName) +
                       msgtype(*escape) keyvar(&MsgKey)
       enddo
       chgvar  &Abending   '1'
    
       movpgmmsg  msgtype(*diag)
       rsnescmsg
    
    endpgm
    

    The program creates a data area and three physical files in QTEMP, the RPG program runs, and all’s right with the world. There’s nothing wrong with this. But I would do this instead:

    pgm
    
       dcl   &WorkLib       *char     10     value(QTEMP)
    
       dcl   &Abending      *lgl
       dcl   &MsgKey        *char      4
       dcl   &PgmName       *char     10
       dcl   &Sender        *char     80
    
       monmsg cpf0000 exec(goto Abend)
    
       /* Retrieve the program name. */
       sndpgmmsg msg(' ') topgmq(*same) msgtype(*info) keyvar(&msgkey)
       rcvmsg    pgmq(*same) msgtype(*info) sender(&sender) rmv(*yes)
       chgvar    &PgmName   %sst(&Sender 56 10)
    
       /* Create temporary objects */
       crtdtaara    &WorkLib/Sequence    *dec    (3 0)
    
       crtpf  &WorkLib/billwork1
       crtpf  &WorkLib/billwork2
       crtpf  &WorkLib/billwork3
    
       ovrdbf billwork1  tofile(&WorkLib/billwork1)
       ovrdbf billwork2  tofile(&WorkLib/billwork2)
       ovrdbf billwork3  tofile(&WorkLib/billwork3)
    
       call qad06631r
    
       dltovr billwork1
       dltovr billwork2
       dltovr billwork3
    
       return
    
    Abend:
       if (&Abending) do
          sndpgmmsg  msgid(cpf9898) msgf(qcpfmsg) +
                       msgdta('Unexpected error in' *bcat &PgmName) +
                       msgtype(*escape) keyvar(&MsgKey)
       enddo
       chgvar  &Abending   '1'
    
       movpgmmsg  msgtype(*diag)
       rsnescmsg
    
    endpgm
    

    QTEMP is still hard coded in the program, but only in one spot–the initial value of the &WORKLIB variable. On many occasions, I have found and exterminated bugs in batch jobs by changing the value of the work library variable. The sequence is:

    • Start a service job on the batch job
    • Put the program into debug
    • Set a breakpoint before the first executable statement
    • Change the value of the work library variable to the name of a temporary library I had created for the occasion
    • Let the program run to completion
    • Query the temporary database tables

    By the way, if you’re not familiar with Brian Rusch’s fabulous Move Program Messages (MOVPGMMSG) and Resend Escape Message (RSNESCMSG) commands, I enthusiastically recommend you remedy that situation. You can learn about them here.

    QTEMP is another feature of IBM i that doesn’t exist on other systems. It pains me each time I see such well-designed software replaced by a cobbled-together assortment of utilities.

    Ted Holt welcomes your comments and questions. Email him through the IT Jungle Contacts page.

    RELATED STORIES

    Where Do Library Lists Reside?

    CL Error-Handling With APIs

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Tags:

    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
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Sponsored Links

    Profound Logic Software:  NOW ON DEMAND! Webinar: Agile Modernization with Node.js.
    Fresche:  IBM i staffing for all of your IT needs. Request a FREE estimate. 1-800-361-6782
    Chrono-Logic:  Simplify deployment with LANSA-based Change Management and Deployment solutions.

    SQL PL–The LOOP Loop What Koch’s $2.5 Billion Infor Investment Means For IBM i

    Leave a ReplyCancel reply

Volume 16, Number 25 -- November 15, 2016
THIS ISSUE SPONSORED BY:

ProData Computer Services
T.L. Ashford
WorksRight Software

Table of Contents

  • Calling SQL Functions From RPG, A Service Program
  • SQL PL–The LOOP Loop
  • QTEMP Is A Different Animal

Content archive

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

Recent Posts

  • Inside The Encryption Key Management Changes In IBM i 7.6
  • FalconStor Moved To The Blue Lagoon, And Is Poised For Growth Because Of It
  • Guru: Claude’s SQL Tip
  • Astera Makes Extracting Legacy Report Data an AI Specialty
  • IBM i PTF Guide, Volume 28, Number 27
  • Welcoming The New IBM i Chief Architect And Other New Top Brass
  • A Deep Dive Into That Power S1112 Entry Power11 Server
  • Guru: Beyond Three-Part Naming – Running SQL Across Remote IBM i Systems
  • How IBM Bolstered IBM i Resilience In The Summer Tech Refreshes
  • IBM i PTF Guide, Volume 28, Number 26

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