Pages

Wednesday, January 7, 2015

Which Control options/H-specs do you use?

In my many years of experience working for various companies I have found that just a few programmers define Control specifications in their RPG programs. The Control specification is commonly known as the Header specification, or H-spec, as in fixed format RPG the specification character, in the sixth position of the line, is 'H'. In all free RPG the Control specification was replaced by the Control options, 'CTL-OPT'.

In my opinion this was the most cryptic of the specifications in RPG III as you had to know what each column stood for, as it would only reveal its meaning when F4 was pressed to prompt the line.

*NODEBUGIO: If this is not given when I start debug (STRDBG) break points are generated for each field in the file. This means if I am stepping through the program I have to press F10 for each field in the file before I proceed to the next statement. By using *NODEBUGIO no break points are generated for the fields, so with one press of the F10 key I advance to the next statement.

*SRCSTMT: The source statement line numbers are used for the line numbers in the generated program or module. Therefore, when I receive an error message about line 223.00 I can go straight to that line number in the source. Without using this option the line numbers are determined sequentially and will not match the source line numbers.

*NOUNREF: The unreferenced fields and variables are not generated, unless they are used by some other module. On the plus side: this makes your program smaller. On the minus side: the unreferenced fields cannot be used in debug.

These are others I do use on a regular basis, just when circumstances need them:

DFTACTGRP(*NO): The program will be associated with the activation group given in the ACTGRP.

ACTGRP(*NEW): This is only valid when the program is created using the CRTBNDRPG command. I just use *NEW as I am yet to encounter a reason why I need to name the activation group the program will be running in.

BNDDIR('*LIBL/BNDDIRNAME'): If you are binding modules and service programs to other programs then, in my opinion, you should be using a binding directory. I always name mine the same name of the program that will use it.

H NOMAIN
ctl-opt nomain ;

NOMAIN: I use this in all of the source code of my modules. It denotes that the code does not have main procedure, and does not use the RPG cycle.

H MAIN(MainPrcedure)
ctl-opt main(MainProcedure) ;

MAIN(MainProcedure): In a "linear" program that does not use the RPG cycle this gives the name of the main line procedure. This is something I will discuss in a future post.

H ALWNULL(*INPUTONLY)
ctl-opt alwnull(*inputonly) ;

ALWNULL(*USRCTL): At times I do have to work with a file that comes from a different server or database. These tables/files do contain columns/fields that contain nulls. By specifying ALWNULL(*USRCTL) I can read these files without the program erroring as a field contains null, and handle the nulls using the null indicator.

If I use ALWNULL(*INPUTONLY) if a field containing null is encountered in the input operation, READ, CHAIN, etc., it is transformed into the field's default, blank, zero, etc.

I would like to hear from you what Control specifications/options you use? And why? Let me know by either posting a comment, below, or use the Contact form on the right and I will include your feedback in this post.

You can learn more about the Control specification on the IBM website here.

This article was written for IBM i 7.2, and it should work with other releases too.

Hi Simon: Is there any way that I could use the compile option DBGVIEW(*SOURCE) inside my RPG program. It would be very useful specially when we are testing an application. Thanks. Carlos. Carlosir@bellsouth.net

This came about because I used to use *CALLER and when I posted some code for help in a forum, Scott Klement and numerous others... how shall I say it... quite emphatic that is a not a good idea and that I should provide a name... so I use CCGOV (I work for Campbell County GOVernment) - turns out to be good advise - there have been a few times that I needed to do a RCLACTGRP CCGOV - if you use *CALLER and the program is called from a non-ILE program (a CLP or RPG/400 program) there's no way to reclaim that activation group outside of ending the job.

Presence any one or more of ACTGRP, BNDDIR, STGMDL keyword(s) will cause the DFTACTGRP keyword to default to *NO.Hence, one can knock off dftactgrp(*no) in most casesTo reduce coding and to standardize pgms across applications, ctl-opt's KWs can be stored externally either in /COPY or in dtaara and be referred in the pgm.

To prevent "comment spam" all comments are moderated.Learn about this website's comments policy here.

Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.