From: Michael Moschitta To: All
How can I determine the number of characters in a CL variable? I'm sending files to a mainframe and the job name can't exceed eight characters. This does not present a problem-I just use the Change Variable (CHGVAR) command as follows.
CHGVAR VAR(%SST(&RPTNAME 1,8)) + VALUE(&SPFILE)
Because &SPFILE is *CHAR, length 10, I truncate &RPTNAME to a length of 8. The problem is the AS/400 spool files that I send are sometimes less than eight characters. This causes the mainframe Job Control Language (JCL) to default to a different class. To prevent this, I need to determine the number of characters in the field and then pad it on the right with a constant such as XXX.
From: Ted Holt To: Michael Moschitta
You can use the *TCAT operator to drop the trailing blanks and concatenate eight Xs, like this:
CHGVAR VAR(%SST(&RPTNAME 1 8)) + VALUE(&SPFILE *TCAT 'XXXXXXXX')
This will add Xs on to the end of &SPFILE, so that a &SPFILE value such as MYJOB will become MYJOBXXX. This eliminates the intervening blanks that are messing up your mainframe JCL.