25
Thu, Apr
0 New Articles

List Orphaned Objects

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

Uncover objects that have been orphaned, without a source.

Objects created through a compiler are expected to have source code somewhere. For example, if you create a logical file with the Create Logical File (CRTLF) command, the source code is probably in source file QDDSSRC if you use IBM's standard file names.

Many times, however, you'll have objects that have no source code. This usually means that there's something you should be aware of. Maybe you created a "one-time" program and discarded the source code but left the compiled object. Maybe you created a flat physical file with the Create Physical File (CRTPF) command, specifying the record length in the RCDLEN parameter instead of using DDS.

For whatever reason, objects without source ("orphans" as I choose to call them) are likely candidates for deletion. This article presents the List Orphaned Objects (LSTORPOBJ) command (1) and its associated programs and files.

For whatever reason, objects without source ("orphans" as I choose to call them) are likely candidates for deletion. This article presents the List Orphaned Objects (LSTORPOBJ) command (Figure 1) and its associated programs and files.

To run it, simply prompt for LSTORPOBJ and key in the name of the library you wish to analyze. LSTORPOBJ will scan to determine that all objects in that library that should have source (based on their object type) actually do. If they do not, they're listed in a report. You can use the report to see if these objects are still necessary and then take corrective action.

How It Works

CL program ORP001CL (2) produces an outfile in QTEMP which has one record for each object in the library-whether the object should have source or not (data areas, for instance, don't require any source code). Then it creates work file ORP001WF in QTEMP by copying the model file (3).

CL program ORP001CL (Figure 2) produces an outfile in QTEMP which has one record for each object in the library-whether the object should have source or not (data areas, for instance, don't require any source code). Then it creates work file ORP001WF in QTEMP by copying the model file (Figure 3).

The loop that follows processes one object at a time. The name of the source file used at the time the object was created is contained in &ODSRCF. If &ODSRCF is blank, it's because the object doesn't require source code-like a user profile or job description-so it loops again, ignoring the object. If not, the Retrieve Member Description (RTVMBRD) command attempts to find the source member from which the object was created.

If RTVMBRD fails, there's no source member. In this case, program ORP001RG (4) writes a record to the work file. This work file will have one record for each object without source. When all objects have been processed, program ORP001RGA (6) prints the report, using printer file ORP001P1 (5).

If RTVMBRD fails, there's no source member. In this case, program ORP001RG (Figure 4) writes a record to the work file. This work file will have one record for each object without source. When all objects have been processed, program ORP001RGA (Figure 6) prints the report, using printer file ORP001P1 (Figure 5).

Try It

LSTORPOBJ works even if the compiled objects are moved to another library after creation, since the compiled object carries within itself the name of the original source file and member. It won't work, however, if you move the source code to another source file or library after creation.

LSTORPOBJ is simple to use and lets you find abnormal situations, ultimately saving you disk space. We've found that it is an invaluable tool in our shop.


List Orphaned Objects

Figure 1 Command LSTORPOBJ

 LSTORPOBJ: CMD PROMPT('List Orphaned Objects') PARM KWD(LIB) TYPE(*NAME) LEN(10) MIN(1) + EXPR(*YES) PROMPT('Library to inspect') 
List Orphaned Objects

Figure 2 CL program ORP001CL

 ORP001CL: + PGM PARM(&LIB) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&SYS) TYPE(*CHAR) LEN(4) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(90) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&RTNLIB) TYPE(*CHAR) LEN(10) DCLF FILE(QADSPOBJ) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(SNDERRMSG)) DSPOBJD OBJ(&LIB/*ALL) OBJTYPE(*ALL) DETAIL(*SERVICE) + OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ) OUTMBR(*FIRST *REPLACE) OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ) RTVOBJD OBJ(ORP001WF) OBJTYPE(*FILE) RTNLIB(&RTNLIB) CRTDUPOBJ OBJ(ORP001WF) FROMLIB(&RTNLIB) OBJTYPE(*FILE) + TOLIB(QTEMP) NEWOBJ(*OBJ) DATA(*NO) MONMSG MSGID(CPF0000) CLRPFM FILE(QTEMP/ORP001WF) OVRDBF FILE(ORP001WF) TOFILE(QTEMP/ORP001WF) RCVF: + RCVF MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(PRTORPS)) IF COND(&ODSRCF *EQ ' ') THEN(GOTO CMDLBL(RCVF)) RTVMBRD FILE(&ODSRCL/&ODSRCF) MBR(&ODSRCM) RTNSYSTEM(&SYS) MONMSG MSGID(CPF0000) EXEC(DO) CALL PGM(ORP001RG) PARM(&ODLBNM &ODOBNM &ODOBTP &ODOBAT + &ODOBTX &ODSRCF &ODSRCL &ODSRCM) ENDDO GOTO CMDLBL(RCVF) PRTORPS: + CALL PGM(ORP001RGA) PARM(&LIB) RCLRSC RETURN SNDERRMSG: + RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM 
List Orphaned Objects

Figure 3 Physical file ORP001WF

 A REF(QADSPOBJ) A R ORPREC A ODLBNM R A ODOBNM R A ODOBTP R A ODOBAT R A ODOBTX R A ODSRCF R A ODSRCL R A ODSRCM R 
List Orphaned Objects

Figure 4 RPG program ORP001RG

 FORP001WFO E DISK A * C *ENTRY PLIST C PARM ODLBNM C PARM ODOBNM C PARM ODOBTP C PARM ODOBAT C PARM ODOBTX C PARM ODSRCF C PARM ODSRCL C PARM ODSRCM * C WRITEORPREC C SETON LR 
List Orphaned Objects

Figure 5 Printer file ORP001P1

 A REF(ORP001WF) * A R HEADER SKIPB(3) A 1'Date:' A +2DATE EDTCDE(Y) A 42'Orphaned Objects Report' A 119'Page:' A +2PAGNBR EDTCDE(J) A SPACEA(1) A 42'Scanned library is' A LIBNAM 10 +1 A 119'Time:' A +1TIME A SPACEA(1) A DASH1 132 1 A SPACEA(1) A 1'Library Object' A 25'Type Attribute' A 47'Object Text' A 100'Src File Library' A 123'Member' A SPACEA(1) A DASH2 132 1 A SPACEA(2) * A R DETAIL A ODLBNM R 1 A ODOBNM R 13 A ODOBTP R 25 A ODOBAT R 35 A ODOBTX R 47 A ODSRCF R 100 A ODSRCL R 111 A ODSRCM R 123 A SPACEA(1) 
List Orphaned Objects

Figure 6 RPG program ORP001RGA

 FORP001WFIP E DISK FORP001P1O E 99 PRINTER * C *IN99 IFEQ '1' C WRITEHEADER C MOVE '0' *IN99 C END * C WRITEDETAIL * C *INZSR BEGSR C *ENTRY PLIST C PARM LIBNAM 10 C MOVE *ALL'-' DASH1 132 C MOVE *ALL'-' DASH2 132 C WRITEHEADER C ENDSR 
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: