Problem solve Get help with specific problems with your technologies, process and projects.

Retrieve a program statement/line number

Retrieve a program statement/line number

I am trying to retrieve a program statement/line number from the SDS, but whenever I look at the value of positions 21 - 28 -- whether it is before or after a dump -- all I get are zeros. What am I missing?
There could be two reasons for the statement number field to be zero. The first is that you may have forgotten to code the "S" next to the "DS" in the D or I-spec for the data structure -- I am not insulting you; I have done it myself.

The second is that this field is ONLY filled when an error occurs in your program. The error information is placed into the Program Status Data Structure. The error must be an 'exception' type of error - that is, non-trivial; reading a file past an end-of-file condition will NOT generate an exception error (If you want that information you can get it from the file status data structure associated with the specific file).

Note that a DUMP operation is also not an error. You could force an exception-type error in your program by, for example, dividing by zero, but since you know which line the error is on, you don't need the PSDS to tell you!

There is the possibility that if your program is failing with an exception error and the statement number is zero, the error may well be occurring before any 'statements' are executed. Check the error message information in the PSDS in positions 40 - 46, and the routine in positions 29 - 36 (the value "*INIT" is a giveaway here).

For more information on the PSDS, click here.

And for the whole reference from which that was abstracted (the Websphere Development Studio ILE RPG Reference),click here..


The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

Dig Deeper on iSeries ILE programming