On 10/12/2016 12:45 PM, Jose Perez wrote:
Peter be aware that when you pass a parm greater than 32 characters through
a CL, this parm get garbage when it is receive in the RPG programm
This has never been true.
PARM100CL:
pgm
dcl &someparm *char 100
chgvar &someparm ('Short text in a long parm')
call parm100r &someparm
endpgm
PARM100R:
c *entry plist
c parm char100 100
dump(a);
*inlr = *on;
call parm100cl
Dump:
CHAR100 CHAR(100) 'Short text in a long parm
'
81 ' '
VALUE IN HEX
'E2889699A340A385A7A3408995408140939695874097819994404040404040404040404040404040'X
41
'40404040404040404040404040404040404040404040404040404040404040404040404040404040'X
81
'4040404040404040404040404040404040404040'X
There is still confusion about calling a program from the command line
[including SBMJOB CMD()] - this is because there is no DCL for the
command line to declare the storage allocation for the variables. For
characters, IBM i creates a default storage allocation of 32 bytes, or
whatever length was actually typed on the command line, whichever is
longer. For numbers, IBM i allocates packed(15, 5).
So, calling the RPG program directly from the command line results in
'garbage' (uninitialised storage in the caller - the command line):
call parm100r 'twice'
Dump:
CHAR100 CHAR(100) 'twice
twice» CT GROUP '
81 ' '
VALUE IN HEX
'A3A689838540404040404040404040404040404040404040404040404040404040A3A68983858B00'X
41
'00000000C3E340404040404040404040404040404040404040404040404040C7D9D6E4D740404040'X
81
'4040404040404040404040404040404040404040'X
...and finally, calling the RPG program from the command line while
passing the proper length (100) of characters. All parameter storage is
properly initialised:
call parm100r 'many spaces after this
'
Dump:
CHAR100 CHAR(100) 'many spaces after this
'
81 ' '
VALUE IN HEX
'948195A840A297818385A2408186A3859940A38889A2404040404040404040404040404040404040'X
41
'40404040404040404040404040404040404040404040404040404040404040404040404040404040'X
81
'4040404040404040404040404040404040404040'X
As an Amazon Associate we earn from qualifying purchases.