CLP parameters overwritten

15 pts.
Tags:
CL Program
CLP
OS/400
Parameters
SBMJOB
Hi. 
When I call a CLP, either from command line or from a sbmjob with alpha parameters, if I don't fill up the whole string length it's trailing blanks are overwritten by the next parameters. 
Example: 
PGM PARM(&P1 &P2 &P3) 
DCL VAR(&P1) TYPE(*CHAR) LEN(50) 
DCL VAR(&P2) TYPE(*CHAR) LEN(50) 
DCL VAR(&P3) TYPE(*CHAR) LEN(50) 
.... 
CALL XX PARM('aaaaaaaa' '111111111' 'ww') 
... 
Result: 
 P1='aaaaaaaa 111111111                 '
 P2='111111111 ww                           '
 P3='ww                                            '
(more or less)
 It would be great if anyone gave me an answer... It 's urgent... Thx.


Software/Hardware used:
OS/400

Answer Wiki

Thanks. We'll let you know when a new response is added.

This is a quirk in the way the command line passes parameters.

less than 32 characters are passed as 32 characters, which is ok, because the CL program receives pointers to the values and parses out what it expects.

more than 32 characters, it only passes exactly what is passed.

the problem becomes when the CL program expects to get more than 32 characters, it will always parse out the 50 (in this case), but if less than 32 characters were passed, the 33rd character will start the next parameter, and so the parsing gets garbage data. If more than 32, but less than the full characters are passed, the overlay will occur after the last character.

one work around is to create a command front end for the CL and instead of calling the program, run the command. The command interface will properly pass the parameters to the CL program

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Jsebastians
    Thanks a lot!! It works!
    15 pointsBadges:
    report
  • TomLiotta
    I'm not so sure it's a quirk exactly. It is the documented behavior and it makes sense. I would think more in terms that the padding of short parameters out to 32 bytes is the 'quirk'. If all undeclared parms were passed only to their limit of significant characters, this possibly would never cause confusion. I.e., if 'ABCDE' was passed as a *CHAR (5) element in memory, everyone would learn immediately how to handle it. By enabling some mostly hidden memory management, the padding tends to obscure what really happens. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following