![]() |
|
| Tim Granatir | |
Here's a simple program that uses an API to stamp objects with user-defined attribute text. You can change this user-defined attribute through the API, but you can't change it from IBM-supplied commands. Where the object text gets defined at the source level and carries through to the object level, this API works only on the object level.
I like the fact that you can stamp objects and use this as an additional way to group or identify things about your objects without losing your original object text. For instance, it can be an aid in identifying that your software is production-ready or it can be used to quickly determine what software enhancement/modification last touched this object.
One other thing you can do, although it isn't foolproof, is use this as a way to be reasonably sure that your production objects didn't get recompiled before moving them into production.
I prefer not to put a user interface on this process and instead build the work file through one or more DSPOBJD commands and then run this program when everything is ready.
An example set of commands would be the following:
DSPOBJD OBJ(SEARCH400/FNDMSG) OBJTYPE(*PGM) OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ) OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ) CALL STAMPOBJ
An example of a stamped object immediately follows the source listing.
FQADSPOBJIF E DISK
I 'MY_VERSION' C VERSN
I SDS
I 1 10 @PGM
I 254 263 @USR
C*
ISYSOBJ DS
I 1 10 ODOBNM
I 11 20 ODLBNM
IOUTREC DS
I B 1 40NUMKEY
I B 5 80KEY#
I B 9 120KEYLEN
I 13 22 DATA
I 1 22 ALL
C*
C EXSR INIT
C 1 SETLLQADSPOBJ
C*
C *INLR DOUEQ*ON
C READ QADSPOBJ LR
C* PROCESS RECORDS
C *INLR IFEQ *OFF
C*
C MOVELODOBTP OUTTYP 10 P
C CALL 'QLICOBJD'
C PARM OUTLIB 10
C PARM SYSOBJ
C PARM OUTTYP 10
C PARM ALL
C PARM PERR 40
C END
C END
C*
C*****************************************************************
C* INIT - INITIALIZATION SUBROUTINE *
C*****************************************************************
C*
C INIT BEGSR
C Z-ADD1 NUMKEY
C Z-ADD9 KEY#
C Z-ADD10 KEYLEN
C MOVELVERSN DATA
C ENDSR
C*
Display Object Description - Full
Library 1 of 1
Object . . . . . . . : FNDMSG Attribute . . . . . : CLP
Library . . . . . : SEARCH400 Owner . . . . . . . : QSECOFR
Library ASP device . : *SYSBAS Primary group . . . : *NONE
Type . . . . . . . . : *PGM
User-defined information:
Attribute . . . . . . . . . . . . : MY_VERSION
Text . . . . . . . . . . . . . . . : FNDMSG command processing program
Creation information:
Creation date/time . . . . . . . . : 03/02/02 14:29:36
Created by user . . . . . . . . . : QSECOFR
System created on . . . . . . . . : S1036846
Object domain . . . . . . . . . . : *USER
More...
Press Enter to continue.
F3=Exit F12=Cancel
(C) COPYRIGHT IBM CORP. 1980, 2002.
---------------------------
About the author: Tim is vice president of Technical Services at Interlink Technologies in Maumee, Ohio. He has worked in the banking, insurance, healthcare and distribution industries in various positions, including programmer/analyst, systems analyst and DP manager. Tim has worked on IBM midrange platforms since 1983.
==================================
MORE INFORMATION
==================================
- Emphasizing source code
Ever have some particular comment or section of code that you'd like to have stand out so that when the next person comes along he's sure to see it? Wouldn't it be nice to be able to highlight, reverse image, draw boxes, change the color of the source code, etc. for the source code you want to emphasize? Site expert Tim Granatir show you how. - Working with date and timestamp in DB2
Is it possible for DB2/400 to automatically keep track of the timestamp when the record is inserted or updated? Yes, said DB2 UDB expert Kent Milligan, if you follow the correct steps. - Automatically create file names for daily reports
If you have reports that run daily (or on any set schedule) you may want to be able to keep a history of past reports for some period of time. If your job overwrites the same file every day, you have to manually copy or rename it to keep it around for comparison. This bit of code will allow you to create a filename that ends with the date created (mm/dd) so that you can immediately know which day the report was run, as well as delete older reports in a timely manner.
This was first published in April 2003
