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

    Start your Road to Zero Trust!

    Firewall Network security, controlling Exit Points, Open DB’s and SSH. Rule Wizards and graphical BI.

    Request Demo

    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

  • 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