Field Padding in CL

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: