How to compare objects across libraries to ensure they came from the same source.

Posted on 2006-04-14
Last Modified: 2008-01-16
I want to compare files and programs in various libraries on an IBM i5 to make sure they all came from the same source compiled at the same time.  For instance, if I compiled my file on a development machine and then moved it to another machine into different libraries, how can I check to make sure they were all compiled at the same time from the same source?  The problem our shop is facing is that developers do not always remember to copy the objects they've installed into production into other libraries which emulate production.  The file structures should be the same even if the data in one comes from production and the data in the others are a subset of productions.  Likewise, I need to check programs for the same reasons.  I ran the DSPOBJD command on a file in various libraries and although they may have the same creation date, the file levels are different for all of them when I run the DSPFD command.  I would have expected them to be  the same if they were compiled around the same time using the same source.  Am I doing something wrong or is my logic faulty using the file level and creation date?

Thank you!
Question by:EugeneJung
    LVL 13

    Accepted Solution

    When a file is created, the system assigns a format level identifier based on the file attributes, including field names, sizes, types, etc. It does not matter when the file is created, if its attributes are the same then the format level identifier is the same. In your case, if the format level identifiers are different, then the files are somehow different.

    Here is a snippet from the IBM infocenter that describes how format level identifers are created:

    The server assigns a unique level identifier for each record format when it creates the associated file. The server uses the following information to determine the level identifier:
    Record format name
    Field name
    Total length of the record format
    Number of fields in the record format
    Field attributes (for example, length and decimal positions)
    Order of the field in the record format

    This is a piece of a DSPFD output, just to ensure we are talking about the same thing:
    Record Format List                                          
                           Record  Format Level                  
     Format       Fields   Length  Identifier                    
     OUTFM            77     1452  3EB4DE5D2D6FB                
       Text . . . . . . . . . . . . . . . . . . . :              
     Total number of formats  . . . . . . . . . . :           1  
     Total number of fields . . . . . . . . . . . :          77  
     Total record length  . . . . . . . . . . . . :        1452  

    The next step would be to use DSPFFD output to outfile of both versions of the file, and compare them to see what is different.

    If you have any questions, post back!
    LVL 14

    Assisted Solution

    I seam to recall that the CCSID can change the file level id.

    that could account for the file difference - check the format level id's

    LVL 32

    Assisted Solution

    running the DSPOBJD command with DETAIL(*SERVICE) will show you the exact source file and member, as well as the source member timestamp during the object creation.
    2 programs in different libraries may have different creation dates, but if the source is exactly the same then the programs are very likely to be the same.

    You will have to create a smart report showing irregularities in the production environment:
    Programs created from invalid source libraries.
    Source version mismatch between production and test.
    When source information is not available, different creation times.
    etc... whatever suites your particular needs.

    LVL 26

    Assisted Solution

    Important note... ILE *PGM objects aren't created from source, but rather from *MODULE objects. Therefore, DSPOBJD *SERVICE against the programs won't help. Use DSPPGM DETAIL(*MODULE) to see the list of modules in an ILE program; then use DSPOBJD DETAIL(*SERVICE) against each module to see source info.

    Also, DSPPGM DETAIL(*MODULE) only outputs to the screen or to a printer file. In order to get useful module info, I use the QBNLPGMI API to list modules into a user space. I process the list and pass extracted values into an SQL insert to build a quick table of modules for query purposes.

    LVL 26

    Expert Comment

    Added note... DSPPGMREF can output record format IDs for database files referenced in a program.

    LVL 26

    Assisted Solution

    Added note... I've put a basic ILE CL source at that extracts some module info and INSERTs it into a simple table in QGPL (or wherever you create it; a sample CREATE TABLE is in a comment). It calls a proc named someDYNSQL which isn't included, but numerous dynamic SQL functions are available on the 'net in almost every programming language -- just google, download one and change the CALLPRC to whatever's appropriate.

    Two parms come in -- the first names a library, all *PGMs in this library are run through the QBNLPGMI API; the second controls whether a user space is created or the previous is reused.

    It's a very basic tool, but might help illustrate getting source info from ILE *PGMs.


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now