• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • SBMJOB, CALL, And Decimal Parameters

    February 23, 2016 Ted Holt

    In spite of my great admiration for the IBM i operating system, I have to admit it has its idiosyncrasies. One of them, which has been there since Day 1, is the way the Submit Job (SBMJOB) command reformats decimal parameters of the CALL command. Fortunately, a relatively recent addition to CL provides an easy way to deal with this quirk.

    Assume a CL program calls an RPG program, passing along two decimal variables and a character variable.

    dcl  &Option       *char    1
    dcl  &Account      *dec     5
    dcl  &ThruDate     *dec     7
    
    call AR100R (&Account &ThruDate &Option)
    

    One day you are told to change this program so that it submits program AR100R to the batch subsystem. You could embed the call within a SBMJOB command, like this:

    sbmjob  cmd(call AR100R (&Account &ThruDate &Option)) +
               job(AR100) jobd(ARJOBD)                               
    

    But that would cause a decimal data error the first time the RPG program accessed the account number or date.

    Instead, overlay the decimal variables with character variables of the same size, like this:

    /* parameters for the submitted program */               
    dcl  &cAccount   *char 3 stg(*defined) defvar(&Account) 
    dcl  &cThruDate  *char 4 stg(*defined) defvar(&ThruDate)
    

    &Account is five digits packed decimal, which occupies three bytes, so &cAccount is defined as a three-byte character variable that overlays &Account. The &ThruDate variable occupies four bytes of memory, so &cThruDate is defined as a four-byte character variable. (To find the number of bytes of storage that a packed decimal variable occupies, add 1 to the number of digits and divide by 2. If the answer is not a whole number, round up. Another method is to add 2 to the number of digits, divide by 2, and throw away the remainder.)

    Use these character variables instead of the decimal variables in the SBMJOB command.

    sbmjob  cmd(call AR100R (&cAccount &cThruDate &Option)) +
         job(AR100) jobd(ARJOBD)                                 
    

    There you have it: an easy solution to an old problem!

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Chilli IT

    Chilli is one of the UKs leading IBM support and management providers with 20 years’ experience in the power and storage industry. Our bespoke solutions for maintenance, security and infrastructure delivers a service which is cost effective, increases productivity and enhances efficiency. Our ethical approach and unrivalled knowledge has secured business partnerships with blue-chip companies in the technology, retail, banking and travel sectors.

    As an IBM Business Partner, we provide you with the peace of mind that you are working in partnership with a company accredited to the highest standard. Our team of experts have worked together for many years and deliver projects which include consolidation, High Availability, Operating System upgrades; and backup and recovery installations.

    Contact us to see how we can help your business with IBM support and management.

    www.chilli-it.co.uk

    info@chilli–it.co.uk

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    COMMON:  2016 Annual Meeting & Expo, May 15 - 18, in New Orleans! Great Power Systems event!
    System i Developer:  RPG & DB2 Summit - March 22-24 in Dallas. Check out the session grid!
    BCD:  Webinar - Getting Started with PHP on IBM i with Mike Pavlak. Feb 25

    The Rewards of IBM i Community Engagement Payday For The People Who Make The IBM i Go

    2 thoughts on “SBMJOB, CALL, And Decimal Parameters”

    • John Torres says:
      July 18, 2019 at 10:59 am

      This is great!!

      Reply
    • Ron S says:
      September 17, 2019 at 8:07 am

      That’s awesome. I wish I’d known this about a month ago, would’ve saved me some time.

      Reply

    Leave a Reply Cancel reply

Volume 16, Number 04 -- February 23, 2016
THIS ISSUE SPONSORED BY:

Bug Busters Software Engineering
WorksRight Software
System i Developer

Table of Contents

  • PHP Crash Course For RPG Developers
  • SBMJOB, CALL, And Decimal Parameters
  • XML-INTO And Optional Elements

Content archive

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

Recent Posts

  • DRV Brings More Automation to IBM i Message Monitoring
  • Managed Cloud Saves Money By Cutting System And People Overprovisioning
  • Multiple Security Vulnerabilities Patched on IBM i
  • Four Hundred Monitor, June 22
  • IBM i PTF Guide, Volume 24, Number 25
  • Plotting A Middle Age Career Change To IBM i
  • What Is Code Transformation Even?
  • Guru: The CALL I’ve Been Waiting For
  • A Frank Solstice
  • The Inevitable Wave Of Power9 Withdrawals Begins

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 © 2022 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.