Search code examples
ibm-midrangeclp

How to pass hexadecimal values in CLP


I can call a program manually by using this command:

CALL PGM(BMANMTHRD) PARM(('TESTPGM') (X'000000465F') ('P') (X'001F'))

But I'm trying to create a CLP in order to call the program BMANMTHRD. But I'm unable to pass the hexadecimal values.

I tried to call it by using *DEC variables and the command would look like this:

CALL PGM(BMANMTHRD) PARM(('TESTPGM') (00465) ('P') (01))

But this will not be able to proceed successfully.


Solution

  • It looks like you don't really need hex values in your CL program; your example shows packed decimals in hex notation, and your example CL also uses numeric values:

    You can read more about packed decimal values here: Packed-Decimal Format

    The important thing to keep in mind is this:

    CL assumes default attributes of *DEC (15 5) for numeric literals, and *CHAR (32) for string literals.

    The Command Line knows nothing about variables, that's why you need to do it the hex way from the there (and also SBMJOB etc), which, by the way, is common practice and okay. You can read more about this here IBM CL Programming

    Code it this way:

    DCL VAR(&PARM1) TYPE(*DEC) LEN(9)
    DCL VAR(&PARM3) TYPE(*DEC) LEN(3)
    

    then move your values to the variables, then call your program like this (you don't need parenteses around your parms either)

    CHGVAR &PARM1 VALUE(456)
    CHGVAR &PARM3 VALUE(1)
    
    CALL PGM(BMANMTHRD) PARM('TESTPGM' &PARM1 'P' &PARM3)
    

    That will fix your problem.

    All the best, AS/400 IBM i forever (Feel free to accept this as answer if you like it)