29
Fri, Nov
0 New Articles

Object Reference Utility

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

Brief: Because every programming change has the potential to cause unexpected problems, fear of change is something every programmer lives with. Using the utility in this article, you can find the relationships between objects.

Programmers are not particularly close-minded or staunchly traditional. But experience has taught them that changing a file or data area can often have an unintended and detrimental effect elsewhere.

These unwelcome surprises have led to the popularity of change-management systems. The tools continue to become more important as AS/400s grow increasingly complex.

The down side is that many organizations have a small MIS budget, and a pricey change-management system can be a tough sell.

The following utility offers one of the best features of change management without the big price tag. The object reference utility presented here gives you access to information about where an object is used and allows you to determine how an object interacts with the rest of the system. The utility is made up of the Create Object Reference (CRTOBJREF) and Display Object Reference (DSPOBJREF) commands.

The CRTOBJREF command creates an object reference file for a specified library, and the DSPOBJREF command displays the object references. 1 illustrates the display presented by the DSPOBJREF command for ITEM01PF physical file. This subfile display essentially tells you what programs use the object; and if the object is a file, its usage is shown (e.g., update, input, or output).

The CRTOBJREF command creates an object reference file for a specified library, and the DSPOBJREF command displays the object references. Figure 1 illustrates the display presented by the DSPOBJREF command for ITEM01PF physical file. This subfile display essentially tells you what programs use the object; and if the object is a file, its usage is shown (e.g., update, input, or output).

How to Use It

Before you can display an object's references, you must create an object reference file for a given library with the CRTOBJREF command. CRTOBJREF accepts three parameters: the reference library, the library that is to contain the OBJRFPF output file, and an option to add records to or replace records in the output file. If you need to find references across multiple libraries, you must execute the CRTOBJREF command for each library with the add records (*ADD) option.

To display an object's references, use the DSPOBJREF command. Key the name of an object (program, file, or data area) in the first parameter and the library that contains the OBJRFPF file in the second parameter.

How It Works

The file containing the program references is called OBJRFPF (see 2). It is created in the library you designate when you run the CRTOBJREF command (see 3). The file is created by the CPP for the CRTOBJREF command, OBJ012CL (see 4). CRTOBJREF uses a master copy of OBJRFPF, which resides in the same library that contains the object reference utility. OBJ012CL will, if necessary, build the OBJRFPF file in the designated library.

The file containing the program references is called OBJRFPF (see Figure 2). It is created in the library you designate when you run the CRTOBJREF command (see Figure 3). The file is created by the CPP for the CRTOBJREF command, OBJ012CL (see Figure 4). CRTOBJREF uses a master copy of OBJRFPF, which resides in the same library that contains the object reference utility. OBJ012CL will, if necessary, build the OBJRFPF file in the designated library.

A monitor message command checks for a condition in which no object references another object in the designated library. For instance, this condition would exist if you ran the command over a library that contains nothing but files. Other error handling was removed to shorten the code so that it could be printed with this article.

The OBJRFPF file is automatically rebuilt if you told the command to replace the file. The file is not cleared each time, so you can build a reference file over more than one library. For instance, you create a file over all libraries that make up your accounting system. OBJ012CL then calls the OBJ012RG program (see 5), which reads the PGMREFO work file and writes the cross- reference records to the OBJRFPF file.

The OBJRFPF file is automatically rebuilt if you told the command to replace the file. The file is not cleared each time, so you can build a reference file over more than one library. For instance, you create a file over all libraries that make up your accounting system. OBJ012CL then calls the OBJ012RG program (see Figure 5), which reads the PGMREFO work file and writes the cross- reference records to the OBJRFPF file.

Displaying the Reference File

The DSPOBJREF command (see 6) displays the records from the OBJRFPF file using a subfile defined in display file OBJ013DF (see 7). RPG program OBJ013RG (see 8, page 52) reads the OBJRFPF file and loads the records into the subfile. The OBJ013RG program accepts parameters for the object name and the library name that contains the OBJRFPF file. Since the DSPPGMREF command does not accept more than one library name, you must call this command for each library in the search.

The DSPOBJREF command (see Figure 6) displays the records from the OBJRFPF file using a subfile defined in display file OBJ013DF (see Figure 7). RPG program OBJ013RG (see Figure 8, page 52) reads the OBJRFPF file and loads the records into the subfile. The OBJ013RG program accepts parameters for the object name and the library name that contains the OBJRFPF file. Since the DSPPGMREF command does not accept more than one library name, you must call this command for each library in the search.

Let's examine the RPG code. First, it overrides the OBJRFPF file to the correct library and opens the file. Next, it sets lower limits in the OBJRFPF file with the object name. The load subfile (LODSFL) subroutine is called to load the subfile.

The LODSFL subroutine sets up a loop that causes all records to be read from the OBJRFPF file. The code within this loop ensures that if there are multiple references to an object within the same source member, only one record is written to the subfile. You may prefer to remove this code and include all references in the subfile depending upon your needs. Another option you may want to consider is to count the references and add a field to the subfile record. In any case, the subfile fields are loaded up. If the object is a file, the code converts the file usage field into a description, and the subfile record is then written.

After the subfile is loaded, the main processing loop is entered and continues until F3 or F12 is pressed (indicator 03 is on).

Make Mine Cajun, Please

The utility in this article has been reduced to fit within the confines of the standards of this publication. You can really spice it up by adding the following functions.

The subfile can be modified to bring source members up in SEU. You can do this by including a CL program that will run the Display Object Description (DSPOBJD) command to an outfile to get the source library and file names and then initiating the SEU command for the selected member.

More importantly, you can add the ability to include all logical references to a physical file when searching for object references. To do this, modify the OBJ013RG program to call a CL program that executes a Display Data Base Relations (DSPDBR) command to an outfile for physical file object references. You will then need to open the outfile as a user-controlled file within the RPG program. Read the outfile records and include them when writing the subfile records.

The net result would be that all references to the physical file, even those made using a logical file, would be displayed.

Disclaimer and Limitations

Like most utilities, this tool has limitations. Only files (all types), programs, and data area object references in RPG and CL programs are included. For COBOL programs, only files and literal program names on the CALL command are referenced. (Object references in other program languages are limited. See the help text for DSPPGMREF for more information.) Fortunately, this list covers almost all objects that would include references to others within the system.

The referenced object names and libraries used in this tool may not reflect the actual names of the objects, since the information is stored when the programs were compiled. If overrides were in effect during the compile or objects were moved, the results may not be accurate.

Security can also be a problem if you do not have *USE rights for the programs and libraries being searched. Refer to the Display Program References (DSPPGMREF) command in the CL Reference manual if you think that this problem may affect you.

A Tool for All Seasons

You will find that this tool can save valuable time when you have to change a file, data area, or program. Knowing that you reviewed all of the associated source members when you modify an object can offer a little peace of mind to an otherwise traumatic experience.

Doug Pence is the founder and Ron Hawkins is the research and development manager of Computing Processing Unlimited, Inc. in San Diego, California.


Object Reference Utility

Figure 1 The DSPOBJREF Display

 UNABLE TO REPRODUCE GRAPHICS 
Object Reference Utility

Figure 2 OBJRFPF Physical File

 *=============================================================== * To compile: * * CRTPF FILE(QGPL/OBJREFPF) SRCFILE(XXX/QDDSSRC) + * SIZE(*NOMAX) *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A R OBJREC A OBJNAM 10 COLHDG('OBJECT NAME') A OBJLIB 10 COLHDG('OBJECT LIBRARY') A OBJTXT 40 COLHDG('OBJECT TEXT') A OBRNAM 10 COLHDG('REFERENCED OBJECT') A OBRLIB 10 COLHDG('REFERENCED LIBRARY') A OBRTYP 10 COLHDG('REFERENCED TYPE') A OBRUSE 2 COLHDG('FILE USAGE') A K OBRNAM A K OBRLIB A K OBJNAM A K OBJLIB 
Object Reference Utility

Figure 3 The CRTOBJREF Command Definition

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/CRTOBJREF) PGM(XXX/OBJ012CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*==================================================================*/ CRTOBJREF: CMD PROMPT('Create Object Reference') PARM KWD(REFLIB) TYPE(*NAME) LEN(10) MIN(1) + PROMPT('Reference library') PARM KWD(LIB) TYPE(*NAME) LEN(10) MIN(1) + PROMPT('Output file (OBJRFPF) library') PARM KWD(OPTION) TYPE(*CHAR) LEN(8) RSTD(*YES) + DFT(*ADD) VALUES(*ADD *REPLACE) MIN(0) + PROMPT('Add or replace records') 
Object Reference Utility

Figure 4 CL Program OBJ012CL, CPP for CRTOBJREF Command

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/OBJ012CL) SRCFILE(XXX/QCLSRC) */ /* */ /*==================================================================*/ OBJ012CL: + PGM PARM(&LIBRARY &REFLIB &OPTION) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10) DCL VAR(&OPTION) TYPE(*CHAR) LEN(8) DCL VAR(&REFLIB) TYPE(*CHAR) LEN(10) DSPPGMREF PGM(&LIBRARY/*ALL) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/PGMREFO) OUTMBR(*FIRST) MONMSG MSGID(CPF3033) EXEC(GOTO CMDLBL(ENDPGM)) /* No references */ CHKOBJ OBJ(&REFLIB/OBJRFPF) OBJTYPE(*FILE) MONMSG MSGID(CPF9801) EXEC(DO) RTVOBJD OBJ(OBJRFPF) OBJTYPE(*FILE) RTNLIB(&LIB) CRTDUPOBJ OBJ(OBJRFPF) FROMLIB(&LIB) OBJTYPE(*FILE) + TOLIB(&REFLIB) ENDDO OVRDBF FILE(OBJRFPF) TOFILE(&REFLIB/OBJRFPF) OVRDBF FILE(PGMREFO) TOFILE(QTEMP/PGMREFO) IF COND(&OPTION *EQ '*REPLACE') THEN(DO) CLRPFM FILE(&REFLIB/OBJRFPF) ENDDO CALL PGM(OBJ012RG) /* Write to permanent file */ DLTOVR FILE(PGMREFO) DLTOVR FILE(OBJRFPF) ENDPGM: + ENDPGM 
Object Reference Utility

Figure 5 RPG Program OBJ012RG

 *=============================================================== * To compile: * * CRTRPGPGM PGM(XXX/OBJ012RG) SRCFILE(XXX/QRPGSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 FPGMREFO IF E DISK FOBJRFPF O E DISK C 1 SETLLPGMREFO C *IN50 DOUEQ*ON C READ PGMREFO 50 C *IN50 IFEQ *OFF C MOVELWHLIB OBJLIB C MOVELWHPNAM OBJNAM C MOVELWHTEXT OBJTXT C MOVELWHFNAM OBRNAM C MOVELWHLNAM OBRLIB C MOVELWHFUSG OBRUSE C MOVELWHOTYP OBRTYP C WRITEOBJREC C ENDIF C ENDDO C SETON LR 
Object Reference Utility

Figure 6 DSPOBJREF Command Definition

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/DSPOBJREF) PGM(XXX/OBJ013RG) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*==================================================================*/ DPSOBJREF: CMD PROMPT('Display Object Reference') PARM KWD(NAME) TYPE(*NAME) MIN(1) PROMPT('Object + name') PARM KWD(LIB) TYPE(*NAME) PROMPT('OBJRFPF library') 
Object Reference Utility

Figure 7 Display File OBJ013DF

 *=============================================================== * To compile: * * CRTDSPF FILE(XXX/OBJ013DF) SRCFILE(XXX/QDDSSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A DSPSIZ(24 80 *DS3) A PRINT A CA03(03) A CA12(03) A R SFLRCD SFL A 40 SFLNXTCHG A DOBJNM 10A O 7 3 A DOBJLB 10A O 7 15 A DOBJTX 38A O 7 27 A DUSEDS 7A O 7 67 A R SFLCTL SFLCTL(SFLRCD) A CHGINPDFT A SFLSIZ(0026) A SFLPAG(0014) A OVERLAY A 21 SFLDSP A SFLDSPCTL A 51 SFLEND(*MORE) A UDATE 6Y 0O 1 2EDTCDE(Y) A DSPATR(HI) A WSID 10A O 1 70DSPATR(HI) A 1 29'Object Reference Screen' A DSPATR(HI) A 21 3 3'Object name . . .' A 21 OBJ 10A O 3 22 A 21 4 3'OBJRFPF library .' A 21 RFFLIB 10A O 4 22 A N21 ERROR 50A O 4 3DSPATR(HI) A 21 6 3'Name' A DSPATR(HI) A 21 6 15'Library' A DSPATR(HI) A 21 6 27'Text' A DSPATR(HI) A 21 6 67'Usage' A DSPATR(HI) A R FOOTER A 22 2'F3=Exit' A COLOR(BLU) A 22 12'F12=Cancel' A COLOR(BLU) 
Object Reference Utility

Figure 8 RPG Program OBJ013RG

 *=============================================================== * To compile: * * CRTRPGPGM PGM(XXX/OBJ013RG) SRCFILE(XXX/QRPGSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 FOBJ013DFCF E WORKSTN F RRN KSFILE SFLRCD F KINFDS INFO FOBJRFPF IF E K DISK UC IINFO DS I 197 206 WSID I B 378 3790FSTL I 'OVRDBF FILE(OBJRFPF)-C OVR I ' TOFILE(' I '/OBJRFPF)' C FILENM I 'No references exist -C NOREF I 'for this object.' * C *ENTRY PLIST C PARM OBJ 10 C PARM RFFLIB 10 C MOVELOVR CMD P C CAT RFFLIB:0 CMD C CAT FILENM:0 CMD C CALL 'QCMDEXC' 50 C PARM CMD 50 C PARM 50 LEN 155 C OPEN OBJRFPF 50 C OBJ SETLLOBJRFPF C EXSR LODSFL C RRN IFGT *ZEROS C SETON 21 C ELSE C MOVE NOREF ERROR C SETON 03 C ENDIF C *IN03 DOUEQ*ON C WRITEFOOTER C EXFMTSFLCTL C ENDDO * C SETON LR * *================================================================ C LODSFL BEGSR *================================================================ C *IN51 DOUEQ*ON C OBJ READEOBJRFPF 51 C *IN51 IFEQ *OFF * * If object referenced more than once in same program, only want IT * shown once. * C MOVELOBJLIB F20 20 C MOVE OBJNAM F20 C F20 IFNE DUPES C MOVE F20 DUPES 20 * C MOVE OBJNAM DOBJNM C MOVE OBJLIB DOBJLB C MOVELOBJTXT DOBJTX C MOVE *BLANKS DUSEDS C OBRTYP IFEQ '*FILE' C MOVEL'UNKNOWN' DUSEDS P C SELEC C OBRUSE WHEQ '01' C MOVEL'INPUT' DUSEDS P C OBRUSE WHEQ '02' C MOVEL'OUTPUT' DUSEDS P C OBRUSE WHEQ '03' C MOVEL'WRKSTN' DUSEDS P C OBRUSE WHEQ '04' C MOVEL'UPDATE' DUSEDS P C OBRUSE WHEQ '06' C MOVEL'UPD/ADD' DUSEDS P C OBRUSE WHEQ '09' C OBRUSE OREQ '11' C MOVEL'DEL/CRT' DUSEDS P C ENDSL C ENDIF C ADD 1 RRN 40 C WRITESFLRCD C ENDIF C ENDIF C ENDDO C ENDSR * *. 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: