Discussion of the Issue

The most common error when calling programs from a command line is that unwanted characters appear in a character parameter. This excerpt from the help text for the PARM parameter of the CALL command explains this, but might need some further explication:
Character string constants of 32 bytes or less are always passed with a length of 32 bytes (padded on the right with blanks). If a character constant is longer than 32 bytes, the whole length of the constant is passed. If the parameter is defined to contain more than 32 bytes, the calling program must pass a constant that contains exactly that number of bytes. Constants longer than 32 characters are not padded to the length expected by the receiving program.
The last sentence is the key here ? if the parameter is declared to be longer than 32 bytes and you pass it a constant that is shorter than the length declared, that parameter will get whatever is in memory after the last character of the constant. That is why the above sentence says to pass a constant that is as long as the declared length of the parameter.
There is a possible error with numbers, as well. A numeric constant is assumed by the system to be a packed decimal with precision of 15 and scale of 5 ? that is, 15 digits and 5 of them are after the decimal point.
This behavior also occurs when submitting jobs with the SBMJOB command and using the CMD parameter to submit a CALL. For a CALL from a command line, things are fine if you pad out the parameters to the full length. But if you use a CALL in a SBMJOB CMD parameter, the trailing blanks get stripped off, even if you used long-enough variables for the parameters in the call.

Possible Solutions

There are two possible solutions for this issue.
  1. (RJS Software recommended) An easy way around this issue is to build a command interface for your program. You simply setup the command parameters to match the program parameter sizes and call the command instead of your program.

    For example:

    If your program has one 100 character parameter, you would write a command that would accept that pass one 100 character value to the program. IBM commands have an inherent ability to automatically pad out values that are being passed into a program. Refer to the second IBM link below in Reference for a more complete discussion of this issue, as well as a 3rd solution.

  2. Make sure that you are passing the exact number of characters that your parameter is expecting. Since trailing blanks are stripped anyhow when using CALL in a SBMJOB, you need to use a variable that is one character longer than the declared length of the parameter. Then put a non-blank character in the extra position. This means that if your parameter is 100 characters and the value you are passing is only 30 characters, you need to use a variable with 101 characters. You need to put 1 non-blank character in the extra position.


The following IBM and Midrange Guru articles help detail the problem a bit more and offer some solutions.


Midrange Guru


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: December 10, 2016