.st0{fill:#FFFFFF;}

RPG coding tip #73 – using [H SPEC COPYRIGHT] 

 April 20, 2013

By  NickLitten

RPG4 (or RPGLE as its sometimes known) has a neat and little used header specification command called ‘COPYRIGHT’

Presumably, this h-spec function was originally implemented by IBM so that software houses can embed their object copyright within the program source. But us RPG developers are a resourceful lot, and the H SPEC COPYRIGHT statement is an excellent way of storing the current modification version of any given program object.

RPG coding tip #73 - using [H SPEC COPYRIGHT] 1

Sometimes, I am working on a version of a program and planning on making many changes during the coming days or maybe weeks. For structured testing of these code versions, or to allow a different colleague to work on a ‘code-frozen’ earlier version, I might want to store the iterative versions in different levels of a testing environment. You could do this by changing the program object description to add a version number V1.1, V1.2, V1.3, V2 etc But this it can be far too easy to have a fat finger moment, or to just forget.

So, how do we control versions in RPG?

Simples — using the COPYRIGHT H-SPEC actually embeds the version number within the program object itself.

By adding the H COPYRIGHT comment into the first line of code, means we can look at the compiled version (and of course the related source code if you have it) and clearly see the version number. For example, adding something like:

H COPYRIGHT('My Company © 2017 YADA YADA  |  Nick Litten V1R1 last changed July 2017')

to a program and compile it.

This text is free-format and can contain a character literal with a maximum length of 256.
So, when you issue a DSPPGM (program-name) you see the comment embedded in the actual program object itself. Here is an example from the Projex4i Toolkit:

H SPEC COPYRIGHT
H SPEC COPYRIGHT with modification history on line 3

Super useful and easy way of recording the source code changes.

ADVANCED COPYRIGHT CODING

You can do the same technique with CL and with RPG including it as a DUMP variable as well

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

Get In Touch

I’m always looking for awesome input, feedback and critique!

>