4.15.34 Some Tips for Inputting / Changing RDML Programs

This section provides some techniques that can be used to make the input or amendment of RDML programs easier, quicker and more accurate.

Use the Prompter

When it is necessary to code a number of commands that may span multiple lines it is easier to use the command prompter than input the lines directly. For example if the commands CHANGE, CHANGE, DISPLAY, INSERT, CHANGE, GOTO had to be coded with all their associated parameters it is easiest to enter them as:



  1 P  ___ CHANGE     _________________________________

  2 P  ___ CHANGE     _________________________________

  3 P  ___ DISPLAY    _________________________________

  4 P  ___ INSERT     _________________________________

  4 P  ___ CHANGE     _________________________________

  5 P  ___ GOTO       _________________________________


When the enter key is pressed a fully formatted prompt will be displayed for each command. All that has to be done then is "fill in the boxes" for each command and let the command prompter automatically assemble and format the resulting RDML commands which may span multiple input lines.

Handling Quotes

Some RDML commands require that associated parameters appear as "quoted strings" because LANSA uses the IBM i operating system command definition and prompting facilities.

For example, to increment field #COUNT by 1 the correct format is:



CHANGE    #COUNT  ('#COUNT + 1')


CHANGE    #COUNT  '(#COUNT + 1)'

but NOT  


This is because the IBM i command facilities demand that a command parameter be enclosed in quotes if it contains imbedded blanks. In this case the string "#COUNT + 1" definitely contains imbedded blanks and thus must be enclosed in quotes (i.e. made into a "quoted" string).

When LANSA processes the command only the part between the quotes (but not the quotes themselves) are passed to LANSA by the operating system.

The matter is complicated even further if you wish to use quotes within a "quoted" string. This situation usually arises when coding IF or CASE conditions.

The rule for using quotes inside a quoted string is: use 2 quotes instead of just one.

For instance, to check if #FIELD contains a lowercase "a" you would have to code:

IF     '#FIELD = ''a'''

What is passed to LANSA by the IBM i operating system command processor as the expression associated with the IF command is actually:

#FIELD = 'a'

because the operating systems do not pass the outer quotes and replaces occurrences of 2 quotes within the string with just one quote.

However, the handling of quotes within LANSA can be made much easier by following 2 simple guidelines:

With regard to point 1, LANSA does not require that alphanumeric literals be quoted. Thus the following are identical conditions because alphanumeric literals that are not enclosed in quotes are converted to uppercase:

IF    '#FIELD = A'

IF    '#FIELD = a'

IF    '#FIELD = ''A'''

Only use quotes around alphanumeric literals if the test involves lowercase characters. For instance the test for a lowercase "a" in #FIELD:

IF    '#FIELD = ''a'''

With further regard to point 2, you will find that the formatted prompting facility will automatically insert the required outer quotes. For instance if you prompt an IF command and enter the condition as:


then the prompter will automatically re-format the condition so that it is a valid "quoted" string. The final version of the command created by the prompter would look like this:

IF     COND('#FIELD = A')

The same applies when it is necessary to use quotes within the expression. For instance if you specify to the prompter the following condition:

#FIELD = 'a'

then it will re-format the command automatically and insert the necessary inner and outer quote symbols. The command created by the prompter would look like this:

IF  COND('#FIELD = ''a''')

Remember the HELP Key

A common problem that occurs when coding RDML programs is the need to look up the definitions of fields or files in the LANSA data dictionary. Questions like:

most frequently arise when coding RDML programs.

To answer any of these questions PRESS THE HELP KEY and use the help facilities to look up the answer. The HELP key can be used from any screen in the LANSA system. Refer to Messages and the Help Key for specific details about the HELP key facilities and how they are used.

Read All the Messages and the Second Level Text

When inputting or amending an RDML program or running the function checker messages may appear on line 22/24 of the screen. When a message appears remember the following points:

For detailed information about messages and message handling within LANSA refer to the relevant section in the Messages and the Help Key.