Could someone please tell why this doesn't work? Path = 'SOMENAME. I get a CPF006 ('Errors occurred in command.') The message in the joblog is 'String 'XMLDATAA' contains a character that is not valid.'
D path S 63A Varying
D cpfmsg S 7A Import('_EXCP_MSGID')
D command S 1024A Varying
D system PR 10I 0 extProc('system')
D cmdstring * Value Options(*String)
path = %trimR(PfhWS);
command = 'CRTDIR XMLDATA' + path;
if system(command) <> 0;
Software/Hardware used:
ASKED:
July 2, 2008 6:08 PM
UPDATED:
May 3, 2010 6:02 AM
Have you tried it like this. The VARYING adds a 2(?) byte size to the front of the string.
D path S 63A Varying D cpfmsg S 7A Import('_EXCP_MSGID') D command S 1024A D system PR 10I 0 extProc('system') D cmdstring * Value Options(*String) path = %trimR(PfhWS); command = 'CRTDIR \XMLDATA' + path; if system(%trim(command)) <> 0;hi sloopy,
I thought that the Value Options(*String) would generate the pointer to the VARYING field, and that it was “scooping up” the length bytes as he was getting an invalid character error and not a missing terminator error,
It may well be doing that too, BigKat. But the *String option does require that a terminating X’00′ must be present, and in RPG we have to do that ourselves – it won’t be done by the RPG EVAL operation.
And the error message doesn’t say that string ‘CRTDIR…’ contains an invalid character, which it would (though probably expressing the string fragment in hex) if the variable cmdstring contained the ‘varying’ length bytes.
In any event, the first byte of the length bytes would be hex 00, and that would say ‘null termination’ to the system() command.
(Varying, varsize and *string options become irritating when we start using them all together….)
GLinds01 – please give us feedback on this, and let us know what solves your problem!
Sloopy, after a sedate and responsible lunch.