• 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

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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