Why do my input parameters contain garbage when the program is called from the command line, or SBMJOB?How do I work around that CL parameter problem?
When I pass numeric parameters to my RPG program from the command line my program isn’t working as expected, why? The command line doesn’t know what type of parameters it is trying to pass, so it converts all numeric variables into 15,5 before passing them. Number of work arounds include: Create a command to call the RPG program, which will convert the numeric variables to the length declared in the command. Pass the numeric values as character data (I.E. PARM(‘0009’) rather than PARM(9)) This is part of a common misunderstanding of how to pass a constant as a parameter. The caller’s parameter definitions must match the called program’s definitions. The command line has no way to declare a variable so it uses a default type and length. Numeric default is packed 15, 5 decimals (8 bytes.) Character default is character 32 bytes. The manual that describes this is the OS/400 CL Programming manual, section 3.4 (Passing Parameters between Programs and Procedures) http://publib.boulder.ibm.co
Related Questions
- Why do my input parameters contain garbage when the program is called from the command line, or SBMJOB?How do I work around that CL parameter problem?
- iSeries / AS400 FAQ : Programming : RPG : When I pass numeric parameters to my RPG program from the command line my program isn working as expected, why?
- Can I control my programmer with command line parameters? Can I make it program a file automatically by clicking on a shortcut?