• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Easy Printing From CL

    March 1, 2016 Ted Holt

    CL cannot write to printer files. This is understandable, since CL fits into the category of job control languages. Even though I’d never use CL to build an aged receivables report, there are times when it is advantageous for a CL program to generate a report (i.e., produce a spooled file), and here are two fairly easy ways to do that.

    Suppose you have a CL program that runs three RPG programs in nightly batch processing. There are people in your organization who need to know whether these programs ran successfully or not. If you could build a short spooled file with that information, you could route that spooled file to an output queue that is monitored by third-party software, which in turn can email the report in PDF format.

    First, create a printer file with the proper settings.

    CRTPRTF    FILE(MYLIB/STATUSPRTF) +
       TEXT('Nightly production status report') +
       OUTQ(EMAILOUTQ)
    

    Here are two ways to build the spooled file.

    Method 1: Qshell and Rfile

    Make the CL program build a Qshell command that uses the Rfile utility to write to the printer file.

    pgm parm(&RunDate)
    
       dcl &RunDate      *char     8   /* YYYYMMDD */
       dcl &Status       *char
    
       dcl &EOL          *char     2   x'0d25'
       dcl &Cmd          *char   256
    
       chgvar &Cmd ('echo ''')
    
       call   QDP007101R  (&RunDate &Status)
       chgvar &Cmd (&Cmd *tcat 'Widgets   =' *cat &Status *cat &EOL)
    
       call   QDP007102R  (&RunDate &Status)
       chgvar &Cmd (&Cmd *tcat 'Thingies  =' *cat &Status *cat &EOL)
    
       call   QDP007103R  (&RunDate &Status)
       chgvar &Cmd (&Cmd *tcat 'Dohickeys =' *cat &Status *cat &EOL)
    
       chgvar &Cmd (&Cmd *tcat ''' | rfile -wQ mylib/StatusPrtf')
    
       qsh    cmd(&Cmd)
       
    endpgm
    

    The &Cmd variable will have a value like this (except that I have put two question marks where the carriage return and line feed characters go):

    echo 'Widgets   =OK??Thingies  =OK??Dohickeys =FAIL??' | rfile -wQ mylib/StatusPrtf
    

    The echo command writes text to the standard output stream. Standard output is piped into the Rfile utility. That is to say, the output from the echo is the input to Rfile. Rfile writes the streamed data to the printer file that we created. Voilà! Several cell phones display the following:

    Widgets   =OK  
    Thingies  =OK  
    Dohickeys =FAIL
    

    Method 2: Native files and RUNSQL

    With the exception of the RUNSQL command, this method uses features that have been around since day 1.

    pgm parm(&RunDate)
    
       dcl &RunDate      *char     8   /* YYYYMMDD */
       dcl &Status       *char
    
       dcl &PrintLine    *char    24
       dcl &Cmd          *char   256
       dcl &Quote        *char     1  value('''')
    
       clrpfm qtemp/StatusRpt
       monmsg cpf3142 exec(do)
          crtpf qtemp/StatusRpt rcdlen(24)
       enddo
    
       call   QDP007101R (&RunDate &Status)
       chgvar &PrintLine ('Widgets   =' *cat &Status)
       callsubr  WriteStat
    
       call   QDP007102R  (&RunDate &Status)
       chgvar &PrintLine ('Thingies  =' *cat &Status)
       callsubr  WriteStat
    
       call   QDP007103R  (&RunDate &Status)
       chgvar &PrintLine ('Dohickeys =' *cat &Status)
       callsubr  WriteStat
    
       cpyf   qtemp/statusrpt  StatusPrtf  fmtopt(*nochk)
    
       return
    
    subr WriteStat
    
       chgvar &Cmd ('insert into qtemp/StatusRpt values(' *cat +
                    &Quote *cat &PrintLine *tcat &Quote *cat ')')
       runsql sql(&Cmd) commit(*none)
    
    endsubr
    
    endpgm
    

    This routine begins by clearing program-described work file StatusRpt if it exists and creating it otherwise. After each program call, the WriteStat subroutine writes a record to the work file. The Copy File (CPYF) command copies the work file to the printer file, producing the report.

    Where there’s a will, there’s a way.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Focal Point Solutions Group

    Comprehensive Data Protection from Focal Point SG

    Your organization needs to be thinking differently about your backup & disaster recovery strategy

    Concerns of the Industry

    • Inefficient manual backup processes
    • Effectively storing data offsite
    • Developing and testing a concrete disaster recovery plan
    • Efficient access to data in a disaster scenario for necessary users
    • Risk of cyber security attack
    • Declining IT staff and resources

    The true cause of the above concerns is an organization’s status quo – 80% of IBM i users currently backup to tape and 40% of companies have no DR plan at all. Don’t wait for a disaster to take action.

    The new way to ensure cost-effective safety

    • Automated cloud backup
    • Two (2) remote sites – redundant storage, power, internet pipe, firewalls, etc.
    • Data encryption at all times – in-flight and at-rest
    • Fully managed remote hardware DR, including remote VPN access for necessary users
    • Regularly simulated phishing tests and cyber security training

    Potential “landmines” in solutions to avoid

    • Single point of storage – no redundancy
    • Misleading data analysis, compression/de-dup ratios, sizing of necessary computer resources for backup and DR
    • Large-scale cloud storage with difficult recovery
    • Inability to meet RTO/RPO

    Don’t get caught like the many organizations we’ve seen with inefficient exposed backup data and no DR plan!

    What VAULT400 has to offer

    Backup

    • Native software agent schedules backups to the Focal Point SG cloud based on your retention scheme
    • Client data is backed up to two data centers in US or two data centers in Canada
    • 256-bit AES encryption in-flight and at rest – only the client has the encryption key
    • Detailed data analysis to ensure proper sizing

    Disaster Recovery as a Service (DRaaS)

    • Focal Point SG provides “hands-off” DR – fully managed recovery
    • 60 days of remote VPN access available to unlimited users in event of a disaster
    • Documented reports to ensure defined SLAs are met

    Managed Service Cyber Security Training

    • Fully managed phishing tests
    • Detailed reporting of results
    • Fully managed administration of custom online cyber security training

    VAULT400 Cloud Backup & DRaaS is an IBM Server Proven Solution.

    VAULT400.com/proposal for FREE analysis & proposal

    813.513.7402 | ContactUs@FocalPointSg.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    COMMON:  2016 Annual Meeting & Expo, May 15 - 18, in New Orleans! Great Power Systems event!
    System i Developer:  RPG & DB2 Summit - March 22-24 in Dallas. Check out the session grid!
    Four Hundred Monitor Calendar:  Latest info on national conferences, local events, & Webinars

    Where In The World Is IBM i? A Possibly Coherent Future Power Hybrid System

    Leave a Reply Cancel reply

Volume 16, Number 05 -- March 1, 2016
THIS ISSUE SPONSORED BY:

WorksRight Software
Rocket Software
Northeast User Groups Conference

Table of Contents

  • Retrieving Data From All Members With SQL
  • Easy Printing From CL
  • The Three Sources Of RUNSQLSTM

Content archive

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

Recent Posts

  • IBM i Has a Future ‘If Kept Up To Date,’ IDC Says
  • When You Need Us, We Are Ready To Do Grunt Work
  • Generative AI: Coming to an ERP Near You
  • Four Hundred Monitor, March 22
  • IBM i PTF Guide, Volume 25, Number 12
  • Unattended IBM i Operations Continue Upward Climb
  • VS Code Is The Full Stack IDE For IBM i
  • Domino Runs on IBM i 7.5, But HCL Still Working on Power10
  • Four Hundred Monitor, March 6
  • IBM i PTF Guide, Volume 25, Number 11

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 © 2023 IT Jungle