Sorry, you do not have permission to ask a question, You must login to ask a question.

Sorry, you do not have permission to ask a question.

brainchime.com

brainchime.com

brainchime.com Navigation

  • Home
  • About Us
  • Contact Us

Mobile menu

Close
  • Home
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags

brainchime.com Latest Questions

Admin
Admin
Asked: October 6, 20242024-10-06T06:36:43+05:30 2024-10-06T06:36:43+05:30In: IBM i

How can i pass an integer variable to an RPG program from the command line?

I have been struggling to pass an integer value as a parameter to the RPG program when calling from IBM i green screen command line.
I have written an RPG program that accepts two input parameters of numeric 3 and numeric 4.
Now, when I call my RPG program from the command line like this CALL PGM(PGM1) PARM((1) (10)) then it’s not receiving the correct value in the input parameters of the program.

What should be the correct way to pass integer(numeric) value to numeric(integer) parameter value to the RPG program call from the command line?

as400rpg
  • 0
  • 0
  • 11
  • 1
  • Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
    • Share on WhatsApp

Related Questions

  • what is level check error and how to resolve level check error?
  • What are AS400 systems. Please provide a introduction of AS400 systems?
  • Is there any online server available for practicing on AS400 system?
  • What are the menus available in AS400?
  • What is subsystem in AS400?
  • How to copy a save file from IFS to a library?
  • How to transfer savf from as400 to pc?
  • How to copy ifs file to another directory?
  • How to copy savf from ifs to pc?
  • How to copy ifs file to physical file?
  • How to copy save file to ifs?
  • How to copy spool file to ifs?
  • How to copy physical file to ifs?
  • How to copy file from pc to IFS?
  • How to download spool file from AS400?
  • How do I delete a library in AS400?
  • How do I copy data from AS400 to excel?
  • What is library in AS400?
  • How to find all the source physical file available in AS400?
  • How to find all libraries in AS400?
  • How to change the library list in AS400?
  • What is access path in AS400?
  • What is the difference between source physical file and physical file in as400?
  • how to find the source file of an object in as400?
  • how to change record length of source physical file in as400?
  • What is cpf4174 error in as400?
  • What is the use of varying keyword in rpgle?
  • What is DDS in AS400?
  • What is the difference between PF and LF in as400?
  • Why do we use CHGPF command in AS400?
  • how to create physical file in as400?
  • What are the data types supported by physical files in AS400?
  • how to add data in physical file in as400?
  • how to view journal entries in as400?
  • what is the use of ovrdbf in as400?
  • What is an array in AS400?
  • what is a data queue in as400 and why do we use data queue?
  • How to run stored procedure in AS400?
  • How to resolve session and device error in AS400?
  • how to check as400 system values?
  • How to check triggers on a file in as400?
  • How to find damaged objects in AS400?
  • what is module in as400?
  • How to create binding directory in as400?
  • how to create ifs folder in as400?
  • What is ASP in AS400?
  • What is JOBQ and how to create a JOBQ in AS400?
  • What is PSDS in AS400?
  • What is SEU in AS400 and why do we use it?
  • What is the multi-format logical file in AS400?
Leave an answer

Leave an answer
Cancel reply

Browse
Browse

Choose from here the video type.

Put Video ID here: https://www.youtube.com/watch?v=sdUUx5FdySs Ex: "sdUUx5FdySs".

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Admin
    Admin
    2024-10-06T06:53:56+05:30Added an answer on October 6, 2024 at 6:53 am

    You can use hexadecimal numbers to pass a numeric(integer) value to a parameter in the RPG program when calling it from the command line.

    Passing numeric value to a packed decimal numeric field in RPG:

    CALL PGM(PGM1) PARM((x'0001F') (x'00010F'))

    Here, the first parameter is a 3-length numeric field and passing value 1. The second parameter is a 4-length numeric field with and passing value of 10.

    To pass a hexadecimal field you must start with x after X within quotes, there must be an even number of positions including the F.

    So, passing value 1 to the numeric length 3 would be x’001F’ where F denotes a positive number and it is a signed bit. And as I remember we pass D for negative numbers.

    However, passing value 10 to numeric length 4 is not x'0010F' since inside single quotes 0010F is an odd number of digits. So the correct value would be x'00010F i.e. add an extra zero in front of the number to make it an even number of positions within single quotes including F after X.

    Just refer to some examples to understand it a little bit more,

    1. If you trying to pass value 5.2 to the decimal (3,1) field and 543 value to the decimal (3) field.
      CALL PGM(PGM1) PARM((5.2) (543))
      CALL PGM(PGM1) PARM((x'052F') (x'543F'))
    2. If you trying to pass value 254674 to the numeric parameter of length 6 field.
      CALL PGM(PGM1) PARM((254674)
      CALL PGM(PGM1) PARM((x'0254674F'))
      Add an extra 0 at the start of the number after x and within quotes so that to make it an even number of digits in the hex value being passed.

    Passing 4-byte integer value to integer (10I) field field in RPG:
    If you try to pass 1 and 10 respectively
    CALL PGM(PGM1) PARM((x'00000001') (x'0000000A'))
    Just refer to some other examples to understand it a little more:
    Passing value for 3I and 5I and 10I and 20I parameters in RPG

    1. passing value 10 to each 3I and 5I and 10I and 20I parameters in RPG
      CALL PGM(PGM1) PARM((X'0A') (X'000A') (X'0000000A') (X'000000000000000A'))
    2. passing value 1 to each 3I and 5I and 10I and 20I parameters in RPG
      CALL PGM(PGM1) PARM((X'01') (X'0001') (X'00000001') (X'0000000000000001'))
    3. passing value 18 to each 3I and 5I and 10I and 20I parameters in RPG
      CALL PGM(PGM1) PARM((X'12') (X'0012') (X'00000012') (X'0000000000000012'))

    You can check convert decimal to hex value here.

    Sample program
    This is the sample program that you can create at your end and test the above calls for passing Integer values in 3I, 5I, 10I, and 20I parameters in the RPG program:

         D main            PR                  EXTPGM('PGM1') 
         D                                3I 0                      
         D                                5I 0                      
         D                               10I 0                      
         D                               20I 0                      
         D main            PI                                       
         D num1                           3I 0                      
         D num2                           5I 0                      
         D num3                          10I 0                      
         D num4                          20I 0                      
          /Free                                                     
               dsply num1;                                          
               dsply num2;                                          
               dsply num3;                                          
               dsply num4;                                          
                                                                    
               *INLR  = *ON;                                        
          /End-Free       
      • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp

Sidebar

Statistics

  • Questions 143
  • Answers 177
  • Comments 0
  • Popular
  • Answers
  • Admin

    Why do we use OVERLAY keyword in data structure subfields ...

    • 12 Answers
  • Admin

    How to call sql stored procedure with output parameter from ...

    • 6 Answers
  • Admin

    How to use declare global temporary table statement in RPGLE?

    • 5 Answers
  • Admin
    Admin added an answer CPF4131 is a record format level check error. This indicates… October 18, 2024 at 1:58 am
  • Admin
    Admin added an answer To open the command prompt with administrator rights you can… October 17, 2024 at 12:27 am
  • Admin
    Admin added an answer In AS400, "AS" stands for Application system. This article discusses… October 13, 2024 at 12:49 pm

Related Questions

  • Admin

    what is level check error and how to resolve level ...

    • 1 Answer
  • Admin

    What are AS400 systems. Please provide a introduction of AS400 ...

    • 1 Answer
  • Admin

    Is there any online server available for practicing on AS400 ...

    • 1 Answer
  • Admin

    What are the menus available in AS400?

    • 1 Answer
  • Admin

    What is subsystem in AS400?

    • 1 Answer

Trending Tags

.htaccess (1) as400 (123) bing-webmaster (2) control-language (12) db2 (33) ftp (8) google-adsense (1) google-search-console (3) https-redirect (1) iasp (4) ifs (22) jar (4) operations (3) php-my-admin (1) qshell (3) robots.txt (4) rpg (26) stored-procedure (3) stroed procedure (1) triggers (1) yoast (4)

Explore

  • Home
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags

Footer

BrainChime

BrainChime is a blog that posts question-and-answer-based format articles on diverse topics and engages in discussions by allowing people to provide answers/comments without the need to register and log in.

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • FAQs
  • Categories
  • Tags

© 2024 BrainChime. All Rights Reserved
by BrainChime.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.