How to pass numeric data to CL program from AS/400 command line

695 pts.
AS/400 commands
CL Program
Hi All, I want to pass numeric data of length (8 0) to my CL program while calling from AS/400 command line but program is not receiving correct value into the program. Can anyone please help me how to pass numeric data?

Answer Wiki

Thanks. We'll let you know when a new response is added.

You’re right —
I generally write a test cl that receives the 8 digits as characters
does a chgvar on the input to dec type
calls the CL to be tested.


Discuss This Question: 10  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Cunninjoe
    CALL PGM(PGM1) PARM(X'123F') to call program with a parameter of + 123.
    320 pointsBadges:
  • Mohan K
    Thank you... its working
    695 pointsBadges:
  • Yorkshireman
    On the basis that it will need running more than once - or testing by someone else, I usually just write a command, whose cpp is the program to be tested/run cmd name = pgm name or something more snappy cmd 'apbjfr' parm *DEC length 6 - etc 2 lines is enough code - plus 10 lines of comment
    6,085 pointsBadges:
  • mcl
    You put comments in your code? :) Yeah, definately go with the command instead of calling the CL directly for command-line use.. regards Mike
    2,740 pointsBadges:
  • 9783444184
    if i want to change the value of my parameter in run time for example
     &parm = 123
    chgvar var(&parm) value(342)
    Call pgm(pgm1) parm(&parm)

    So now how can we do this please suggest i have same scenario 
    1,465 pointsBadges:
  • TheRealRaven
    @9783444184 : How can you do what? You asked a question, and you showed code that answers your question. That makes it very confusing to understand what you need to know.

    Also, your question has nothing to do with this thread. Please create your own question. Include all necessary detail including an example of the result that you need.

    If you keep adding to this thread, it won't be seen by the right forum members and it will be harder for members to find in the future.
    35,920 pointsBadges:
  • mahesh8055
    How to pass the *int /*unit value through command line. Please help me any one.
    10 pointsBadges:
  • ToddN2000
    To pass numeric data follow this format.

    This passes the numeric value 123 to the program.
    The F at the end is for the sign value.

    To pass a 2 you would use  PARM(X'2F')
    To pass a 11 you would use  PARM(X'011F')
    To pass 123.45 you would use  PARM(X'12345F')

    The hex value, including the F, must be an even number of positions. If your value plus the sig ( F ) is an odd number of positions, add a leading zero.
    134,455 pointsBadges:
  • GregManzo
    You can also pass negatives by changing the sign nibble from an 'F' to a 'D', so -42 becomes: parm(x'042D')
    2,960 pointsBadges:
  • bvining
    Mahesh8055 was asking about how to pass *int/*uint values to CL from the command line, not *dec values.

    If you have declared a parameter as *int it defaults to a length of four bytes. To pass a parameter value of 5 you would use Parm(x'00000005') to provide a 4-byte integer/binary representation of 5. To pass a value of 257 you would use Parm(x'00000101'). *uints work the same way.

    *ints however also have the ability to represent both positive and negative values. If the most significant (leftmost) bit of the parameter/value is "on" (1) then it's a negative number stored in twos complement form. To pass a value of -5 you would use Parm(x'FFFFFFFB'). To pass a value of -257 you would use Parm(x'FFFFFEFF').

    Passing Parm(x'7FFFFFFF') to a CL program will result in a value of 2,147,483,647. As the most significant bit is "off" (0) when the leading 7 of x'7F...' is processed it's a positive number (and along the same lines any leading nibble of x'8x...' or greater is a negative number. This value (2,147,483,647) also happens to be the largest positive value that can be represented by a 4-byte signed integer (*Int) as adding '1' to the hex value would cause the leading nibble to go to x'8x' and represent a negative number (when using *ints).
    7,070 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: