19
Fri, Apr
5 New Articles

TechTip: Analyze Your Programs and Applications, Part I

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

In the first of this series of TechTips, find information about each object in each library.

 

Recently, a friend called me for help. His boss asked him two questions:

  • How much lost or forgotten old RPG or CL do we have?
  • What is the status of the "general review of all the ILE programs" project?

 

He added, "I don't want a bullet-point listing. If you can give me a report in Excel in a normal table with normal filters, such as used by normal users every day, that would be better."

 

Uh oh! Something has changed. It's true that the spools are out of favor these days, even the spools copied into an Excel or PDF file.

 

And of course, the boss didn't want to invest in software for analyzing cross-references. "With all the commands in the OS, there is at least one that gives this info, isn't there?" Unfortunately, my friend's boss had forgotten what command was needed to do the job.

 

"Umm, yes, boss. No doubt, boss."

 

Dear friend, it is the Display Object Description (DSPOBJD) command.

 

The IBM i provides much information about each object in each library. And this command can be used on both the objects manufactured in-house and the objects of purchased software packages. Yep, you can easily find out whether your supplier's management of internal development is perfectly logical or as whimsical as what might have been created in-house.

 

Here's proof. In order to not offend anyone (yet still get my point across), I will demonstrate this on my own toolbox. I have added one old CLP and one old RPG to it for the purpose of this article; otherwise, I cannot show how to locate heritage programs.

 

120911JpProgramAnalysis1Fig1

Figure 1: Use the DSPOBJD command. (Click images to enlarge.)

 

DSPOBJD OBJ(JPLTOOLS/*ALL) OBJTYPE(*ALL) DETAIL(*SERVICE)

  OUTPUT(*OUTFILE) OUTFILE(JPLTOOLS/OBJS) OUTMBR(*FIRST *REPLACE)

 

If the analysis must include multiple libraries, use the option below to make as many DSPOBJDs as needed by making all DSPOBJDs append to the same file:

 

 OUTMBR (*FIRST *ADD)

 

Unfortunately, DSPOBJD typically provides too much information. For building extractions, STRSQL is a bit overwhelmed by the width of the file. I used iNav Sql instead (Run SQL Scripts from IBM i Navigator).

 

To make access more rapid, add a shortcut to iNav Sql on your desktop:

 

120911JpProgramAnalysis1Fig2

Figure 2: Add a shortcut to iNav Sql on your desktop.

 

Right-click Properties:

 

Target="C:\ProgramFiles\IBM\ClientAccess\Shared\cwbundbs.exe"

Folder="C:\ProgramFiles\IBM\ClientAccess\Shared"

 

First trial: Get the raw information.

 

select * from jpltools.objs

 

120911JpProgramAnalysis1Fig3

Figure 3: Get the raw data.

 

iNav Sql retrieves data very efficiently, but it's not much for the column headings. With STRSQL in parallel, the gap is filled.

 

Next step: Identify the columns needed—e.g., source file name and date. We have chosen the year of the source code's last update as the marker of reviewed source code. If we were reviewing program recompilation, we would instead have chosen the object creation date. There is so much information in DSPOBJD!

 

Here's the problem: DSPOBJD gives the date of the source code, but it gives it with three columns (all characters): the century, the date, and the time. We seek the four-digit year. SQL can take care of that with the following code.

 

SELECT ODLBNM "Library", ODOBNM "Object" , ODOBTP "Type" , odobat "Attribut",trim(ODSRCL) "Src Lib",  trim( ODSRCF)      "Src PF",  trim(ODSRCM)  "Src Member",case when odsrcc =  '' then ' ' else trim(char( ODSRCC+ 19)) concat substr(ODSRCD , 1 , 2) end as year   FROM jpltools.objs

 

120911JpProgramAnalysis1Fig4 

Figure 4: The year is now shown in standard four-digit format. 

 

Much prettier.

 

Note: The ILE *PGM objects have no source. Normally, my ILE programs are created by CRTPGM. The modules will provide the information I'm searching for. If I wanted to analyze an external application, delivered without modules, DSPOBJD would not give me the information I want. In that case, I would have to code a program that uses  the program descriptions API to obtain the  list of the modules and their source code file names. I'll return to that point later.

 

So my friend's boss was right: the information is available. Now, it's just a matter of extracting this information and exporting it to Excel.

 

Note that we found a wealth of information, just with the DSPOBJD command. Having discovered that gives us the opportunity to show many different aspects of the application we are analyzing.  So, in the second part of this TechTip series, we'll pursue the application analysis with some other DSPxxx commands. You'll see all the information that can be extracted by using a few DSPxxx commands.

 

For now, we'll just get the requested information to Excel with the SQL above, and we'll reveal the answers to the questions the boss asked.

 

In Excel, we used the ODBC connection, because it's one of the easier connection modes to implement. Moreover, it's likely that the ODBC declaration to use already exists on your PC.

Creating an ODBC Connection

Click Start > Run: odbcad32.exe.

 

120911JpProgramAnalysis1Fig5

Figure 5: Call the ODBC administration application. 

 

Click the ADD button.

 

120911JpProgramAnalysis1Fig6

Figure 6: Create an ODBC connection.

 

Select the Client Access driver.

 

120911JpProgramAnalysis1Fig7

Figure 7: Select the Client Access ODBC Driver.

 

Enter a name for your connection and specify the system to connect to. Leave the other settings on their default values.

 

120911JpProgramAnalysis1Fig8

Figure 8: Name your connection and specify the system log.

 

The ODBC connection is available.

Import the Information into Excel

I used Excel 2007, but with Excel 2003, the method is similar. Open Excel. In the Data menu, choose Get External Data > From Other Sources > From Microsoft Query. Then follow the steps shown below.

 

120911JpProgramAnalysis1Fig9

Figure 9: Select a data source and deactivate the Query Wizard.

 

Close the Add Tables view.

 

120911JpProgramAnalysis1Fig10

Figure 10: Close Add Tables.

 

120911JpProgramAnalysis1Fig11 

Figure 11: Choose the SQL editor.

 

Paste in the SQL query shown below. Note that the query syntax here is simple, and ODBC will accept it. This is not always the case. When a query is too complex to manipulate with this very small editor window, you must run the SQL statement batch on the server (e.g., with a STRQMQRY with output OUTFILE) and then read the result with ODBC.

 

SELECT ODLBNM "Library", ODOBNM "Object" , ODOBTP "Type" , odobat "Attribut",trim(ODSRCL) "Src Lib",  trim( ODSRCF)      "Src PF",  trim(ODSRCM)  "Src Member",case when odsrcc =  '' then ' ' else trim(char( ODSRCC+ 19)) concat substr(ODSRCD , 1 , 2) end as year   FROM jpltools.objs

 

120911JpProgramAnalysis1Fig12 

Figure 12: Paste in the SQL query. 

 

Click OK.

 

MS Query is a little confused by what is asked. Don't worry about that. Click OK.

 

120911JpProgramAnalysis1Fig13

Figure 13: Yes, continue!

 

MS Query retrieves and displays information. Continue to import to Excel.

 

120911JpProgramAnalysis1Fig14

Figure 14: Choose Return Data to Microsoft Office Excel.

 

The information has been received. Choose how you want to view it.

 

120911JpProgramAnalysis1Fig15

Figure 15: Choose how to view your data.

 

And voila!

 

120911JpProgramAnalysis1Fig16

Figure 16: Your data is now in an Excel spreadsheet.

 

With this table in Excel, we will now easily answer the questions we were asked:

 

First question : How much lost or forgotten old RPG or CL do we have?

 

The answer is very simple to provide. Just click on the column labeled Attribute:

 

120911JpProgramAnalysis1Fig17

Figure 17: Object attributes are revealed.

 

The answer is clear: there are objects with CL and RPG attributes. Select just these objects' attributes to get the detailed list.

 

120911JpProgramAnalysis1Fig18

Figure 18: Select RPG and CLP.

 

120911JpProgramAnalysis1Fig19

Figure 19: Details are revealed.

 

Second question: What is the status of the "general review of all the ILE programs" project? 

 

For the answer, we must first filter the objects, keeping only the * MODULE, * PGM, and * SRVPGM objects in which the year is not blank. Remember: we are working on the year of the source update date. Some objects have no source.

 

120911JpProgramAnalysis1Fig20Left               

 

120911JpProgramAnalysis1Fig20Right

Figure 20: First, we filter.

 

Then, we sort by year.

 

120911JpProgramAnalysis1Fig21

Figure 21: Now we sort.

 

We now have an Excel sheet containing the information the boss asked for.If we had worked on ODCCEN plus ODCDAT (i.e., the object creation date) instead of ODSRCC plus ODSRCD (the source update date), we would have gotten a review of a general recompilation project.

 

The SQL extraction targeted only the year. It could also seek the full date by replacing

 

concat substr (ODSRCD, 1, 2) 

 

with

 

concat ODSRCD

 

in the SQL statement:

 

SELECT ODLBNM "Library", ODOBNM "Object" , ODOBTP "Type" , odobat "Attribut",trim(ODSRCL) "Src Lib",  trim( ODSRCF)      "Src PF",  trim(ODSRCM)  "Src Member",case when odsrcc =  '' then ' ' else trim(char( ODSRCC+ 19)) concat substr(ODSRCD , 1 , 2) end as year   FROM jpltools.objs

 

This first part of this TechTip series ends with the import into Excel of the first statistics on the status of programs' compilation. You have seen that generating the requested information is done simply by using the appropriate system command. You have also seen that, with a few clicks, you can insert these statistics into Excel, which is much more comfortable to use than a spool. Imagine how long it would take to produce these statistics without SQL or ODBC!

 

You also saw that we came across a wealth of information. In the second part of this series, you'll see all the types of information we derive from the other DSPxxx commands.

Jean-Paul Lamontre

Jean-Paul Lamontre has been working on IBM machines since 1976. His first was a 3/15 with 128K RAM (the biggest machine of the county). His first program was an RPG program, no more than 15 lines. It never compiled, and nobody ever understood why.

 

Currently, Jean-Paul divides has work time between two companies.

 

For Cilasoft, which offers the Cilasoft Audit and Security suite, he is the director of development. The Cilasoft suite is a cornerstore to any company's compliance process.

 

For Resolution, which offers Xcase, a database engineering suite, he is the CTO of the IBM i department. Xcase allows developers to modernize a DDS database to DDL, discover and implement implicit relationships, and manage SQL databases using an advanced GUI.

 

Jean-Paul also publishes some free tools on his personal Web site. Most popular are SQL2XLS, SPLF2PDF, and MAIL.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

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: