• 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
    Raz-Lee Security

    With COVID-19 wreaking havoc, cybercriminals are taking advantage of the global impact that it has had on our families, our businesses and our societies. It is more important now than ever to ensure that IT systems are protected, so that when all of this is behind us, we can get back to business as usual as quickly as possible.

    iSecurity Anti-Ransomware protects organizations against ransomware attacks and other kinds of malware that may access and change business-critical data on your IBM i. It even protects against zero-day attacks. Anti-Viruses can only report on the damage an attack has caused, but not stop it.

    iSecurity Anti-Ransomware has been recently enhanced with a Self-Test feature that allows you to simulate a ransomware attack on your IBM i. The simulated attack is limited to the test folder and cannot harm any other folders or files. This new feature lets organizations see how they are protected against known or unknown ransomware.

    Key Features:

    • Real-time scanning for known and unknown ransomware threats.
    • Blocks and disconnects the intruder.
    • Instantaneously sends alerts to SIEM as well as the offending computer.
    • Self-Test for attack simulation
    • Classification of the attack based on log.
    • Automatic updates with the most current ransomware definitions.

    Contact us at https://www.razlee.com/anti-ransomware/

    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

  • 2021 Predictions for IBM i, Part 1
  • West Four Stands Out With On Demand Color Label Printing
  • HelpSystems Acquires Data Security, File Transfer Companies
  • Four Hundred Monitor, January 13
  • IBM i PTF Guide, Volume 23, Number 2
  • Seiden Group Unveils A PHP Distro For IBM i
  • Thoroughly Modern: DevOps Refactoring Of RPG Applications with RDi
  • Guru: Fall Brings New RPG Features, Part 2
  • More Vintage Power Systems Feature Withdrawals
  • IBM i PTF Guide, Volume 23, Number 1

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 © 2021 IT Jungle

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.