• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Editing Numbers in CL, Take Two

    November 30, 2005 Hey, Ted

    I just read Cletus’ tip on the editing of numbers in CL procedures, called Editing Numbers in CL. I will add these techniques to my tool kit. As always, thanks for the great stuff. Here’s another method I’ve used to remove leading blanks from numbers in CL.

    –Russ

    Russ’s method uses a message description that has a four-byte binary variable. Here’s how it works. (This following code is mine, not his, so any mistakes are also mine.)

    Let’s use the example from the previous article. Variable &CustOrders contains the number of orders that have been added to a database file. Our job is to load the number of orders, without leading blanks, into the &AlphaNum variable.

    First, a few variable declarations.

    dcl  &CustOrders   *dec      10 
    dcl  &AlphaNum     *char     10 
    dcl  &BinVar       *char      4 
    

    Second, a message description that defines a four-byte binary variable.

    CrtMsgf    Msgf(Qtemp/TempMsg)      
    MonMsg     MsgID(CPF2112)           
    AddMsgd    MsgID(TMP1001) Msgf(QTEMP/TEMPMsg) Msg('&1') +  Fmt((*BIN 4)) 
    MonMsg     MsgID(CPF2412) 
    

    The MONMSG message commands keep the CL procedure from erroring out during a rerun.


    As before, variable &CustOrders has the number of orders. Convert the number of orders to binary format.

    RtvMbrd    File(ORDERS) NbrCurRcd(&CustOrders)  
    ChgVar     Var(%BIN(&BinVar)) Value(&CustOrders) 
    

    Now, retrieve the message description into a CL variable. In the process, the system applies the number of orders to the message.

     RtvMsg     MsgID(TMP1001) Msgf(Qtemp/TempMsg) + 
                 MsgDta(&BinVar) Msg(&AlphaNum)
    

    At this point, &AlphaNum contains the number of records in the ORDERS file, left-adjusted.

    Thanks to Russ for submitting this editing technique.

    –Ted

    RELATED STORY

    Editing Numbers in CL

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Maxava

    Migrate IBM i with Confidence

    Tired of costly and risky migrations? Maxava Migrate Live minimizes disruption with seamless transitions. Upgrading to Power10 or cloud hosted system, Maxava has you covered!

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Ipedo Seeks to Bridge Web Services with Business Intelligence NetManage Cuts Complexity and Cost of iSeries Product

    Leave a Reply Cancel reply

Volume 5, Number 44 -- November 30, 2005
THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
WorksRight Software
Guild Companies

Table of Contents

  • Everything You Ever Wanted to Know About Converting Dates
  • Editing Numbers in CL, Take Two
  • Selectively Deleting OS/400 Spool Files

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle