Quick view contents of a data file

We use this command to view the contents of a data file. It's really just a wraparound of RUNQRY, but it is very convenient.

Usage: q filename

  • Save the CL source into member QC in QGPL/QCLSRC
  • Compile with CRTCLPGM QGPL/QC QGPL/QCLSRC
  • Save the CMD source into member Q in QGPL/QCMDSRC
  • Compile with CRTCMD CMD(QGPL/Q) PGM(QGPL/QC) SRCFILE(QGPL/QCMDSRC)
     CL member QC:
    /* this lets you type Q filename and get a query w/selection up */     
    PGM PARM(&FILENAME)                                                    
        DCL &FILENAME *CHAR 10                                             
                 RUNQRY     QRY(*NONE) QRYFILE((&FILENAME)) RCDSLT(*YES)   
                 MONMSG     MSGID(QRY1012) EXEC(SNDPGMMSG MSGID(CPF9898) + 
                              MSGF(QCPFMSG) MSGDTA('File ' *CAT +          
                              &FILENAME *TCAT ' doesn''t exist') +         
                              TOPGMQ(*PRV (*)) MSGTYPE(*ESCAPE))           
                                                                           
    ENDPGM       

    ==================================
    MORE INFORMATION ON THIS TOPIC
    ==================================

    The Best Web Links: tips, tutorials and more.

    Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

    Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

    CMD member Q: cmd prompt('quick query of file') PARM KWD(FILE) TYPE(*NAME) LEN(10) MIN(1) + EXPR(*YES) CHOICE('(assumes *LIBL)') + PROMPT('Filename')

    This was first published in September 2004

  • Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.