• 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:

    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

  • With Power11, Power Systems “Go To Eleven”
  • With Subscription Price, IBM i P20 And P30 Tiers Get Bigger Bundles
  • Izzi Buys CNX, Eyes Valence Port To System Z
  • IBM i Shops “Attacking” Security Concerns, Study Shows
  • IBM i PTF Guide, Volume 27, Number 26
  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25

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