27
Wed, Nov
0 New Articles

The Display Percent Complete Utility

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Often, when I'm running a long job in batch, I want to check the status of the job. Fortunately, with certain types of jobs, it's possible to determine the job's progress. For example, if I'm running a Copy File (CPYF) command, I know that the job will be complete when the number of records specified in the TOFILE parameter is equal to the number of records in the FROMFILE parameter. Likewise, if I'm running a job which builds a work file, and I know how many records are supposed to be in the work file when the job has completed, I can tell how far the job has progressed.

To make this calculation easy, I wrote a utility called Display Percent Complete (DSPPCTCMP). The source code for the command is shown in 3. The command processing program, PCT001CL, is shown in 4; and the display file, PCT001DF, is shown in 5.

To make this calculation easy, I wrote a utility called Display Percent Complete (DSPPCTCMP). The source code for the command is shown in Figure 3. The command processing program, PCT001CL, is shown in Figure 4; and the display file, PCT001DF, is shown in Figure 5.

This utility presents you with a window which shows you the percentage of completion for a job. An auto-refresh technique is used to keep the information in the window constantly updated.

The DSPPCTCMP command has three parameters. The first parameter contains the qualified name of a file. The second parameter specifies a member name within the file. The third parameter indicates the number of records you expect to have in the file when a particular job completes.

Let's look at a simple example. Suppose you submit a CPYF command to batch to copy FILEA, which contains 32,768 records, to FILEB. At some point during the execution of that job, you issue the following command:

 DSPPCTCMP FILE(FILEB) + CMPNBR(32768) 

You would then be presented with a window showing an automatically incrementing percent value. When the value reaches 100 percent, the job is complete.

The PCT001CL program calculates the percent complete by retrieving the number of active records in the specified file. It then divides that number by the specified completion number and multiplies the results by 100. This number, which is always between 0 and 100, represents the percentage of the job that is complete. Be aware that this calculation is only as accurate as the completion number you supply. But when you know the number of records you expect to have, this utility can be very useful.


The Display Percent Complete Utility

Figure 3 Command DSPPCTCMP

 /*===============================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/DSPPCTCMP) PGM(XXX/PCT001CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*===============================================================*/ DSPPCTCMP: CMD PROMPT('Display Percent Complete') PARM KWD(FILE) TYPE(QUAL) PROMPT('File name') PARM KWD(MBR) TYPE(*NAME) LEN(10) DFT(*FIRST) + SPCVAL((*FIRST)) PROMPT('Member') PARM KWD(CMPNBR) TYPE(*DEC) LEN(7) + PROMPT('Completion number') QUAL: QUAL TYPE(*NAME) LEN(10) MIN(1) QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library') 
The Display Percent Complete Utility

Figure 4 CL Program PCT001CL

 /*===============================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/PCT001CL) SRCFILE(XXX/QCLSRC) */ /* */ /*===============================================================*/ PGM PARM(&FILE &MBR &CMPRCD) DCL VAR(&FILE) TYPE(*CHAR) LEN(20) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MBR) TYPE(*CHAR) LEN(10) DCL VAR(&ARCDS) TYPE(*DEC) LEN(10 0) DCL VAR(&WORK) TYPE(*DEC) LEN(7 4) DCL VAR(&MSG) TYPE(*CHAR) LEN(80) DCLF FILE(PCT001DF) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) OVRDSPF FILE(PCT001DF) WAITRCD(1) CHGVAR VAR(&FILNAM) VALUE(%SST(&FILE 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&FILE 11 10)) LOOP: + RTVMBRD FILE(&LIB/&FILNAM) MBR(&MBR) RTNLIB(&LIBNAM) + RTNMBR(&MBRNAM) NBRCURRCD(&ARCDS) CHGVAR VAR(&ACTRCD) VALUE(&ARCDS) IF COND(&CMPRCD *GT 0) THEN(DO) CHGVAR VAR(&WORK) VALUE(&ARCDS / &CMPRCD) CHGVAR VAR(&PCTCMP) VALUE(&WORK * 100) ENDDO SNDRCVF RCDFMT(PCT001FM) WAIT(*NO) MONMSG MSGID(CPF0887) IF COND(&IN03) THEN(GOTO CMDLBL(ENDPGM)) RMVMSG CLEAR(*ALL) WAIT MONMSG MSGID(CPF0889) GOTO CMDLBL(LOOP) ERROR: + RCVMSG MSGTYPE(*ANY) MSG(&MSG) SNDPGMMSG MSG(&MSG) ENDPGM: + ENDPGM 
The Display Percent Complete Utility

Figure 5 Display File PCT001DF

 *=============================================================== * To compile: * * CRTDSPF FILE(XXX/PCT001DF) SRCFILE(XXX/QDDSSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A DSPSIZ(24 80 *DS3) A CF03(03) A CF12(03) A R PCT001FM LOCK A WINDOW(6 28 11 20) A WDWBORDER((*COLOR GRN) - A (*DSPATR RI) - A (*CHAR ' ')) A 1 3'Percent Complete' A DSPATR(HI) A 3 1'File....:' A FILNAM 10 O 3 11 A 4 1'Library.:' A LIBNAM 10 O 4 11 A 5 1'Member..:' A MBRNAM 10 O 5 11 A 6 1'Records.:' A ACTRCD 7Y 0O 6 11EDTCDE(3) A 7 1'Complete:' A CMPRCD 7Y 0O 7 11EDTCDE(3) A 8 1'Percent.:' A PCTCMP 5Y 2O 8 12EDTWRD(' 0. %') A DSPATR(HI) A 10 1'F3=Exit' A COLOR(BLU) A 10 11'F12=Cancel' A COLOR(BLU) A R DUMMY ASSUME A 1 2' ' *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: