Decimal data error – Scenario 1
Page 1 of 1
Decimal data error – Scenario 1
Decimal data error – Scenario 1
One of the downside of IBM i OS is that when the program is called by SBMJOB, it given a decimal data error. If you call interactively this decimal data error will not occur. Let us assume CL pass a numeric variable ( decimal) as a parameter to RPG program.
If you call directly (interactively) for example
DCL VAR(&INVNO) TYPE(*DEC) LEN(5 0)
CALL PGM(INVPRINT) PARM(&INVNO)
Above call command will not give decimal data error.
But you submit as follows
SBMJOB CMD(CALL PGM(INVPRINT) PARM(&INVNO)) JOB(INVPRINT) JOBD(INVJOBD)
The above command causes a decimal data error.
How to get rid of it?
We can overlay decimal variable with character variable as follows:
DCL VAR(&INVNO1) TYPE(*CHAR) LEN(3) STG(*DEFINED) DEFVAR(&INVNO)
&INVNO is packed decimal WITH LENGTH 5, which occupies 3 bytes, so &INVNO1 is defined as a 3 byte character variable that overlays &INVNO
Now we can use this char variable & INVNO1 to call INVPRINT program instead of &INVNO as follows:
SBMJOB CMD(CALL PGM(INVPRINT) PARM(&INVNO1)) JOB(INVPRINT) JOBD(INVJOBD)
One of the downside of IBM i OS is that when the program is called by SBMJOB, it given a decimal data error. If you call interactively this decimal data error will not occur. Let us assume CL pass a numeric variable ( decimal) as a parameter to RPG program.
If you call directly (interactively) for example
DCL VAR(&INVNO) TYPE(*DEC) LEN(5 0)
CALL PGM(INVPRINT) PARM(&INVNO)
Above call command will not give decimal data error.
But you submit as follows
SBMJOB CMD(CALL PGM(INVPRINT) PARM(&INVNO)) JOB(INVPRINT) JOBD(INVJOBD)
The above command causes a decimal data error.
How to get rid of it?
We can overlay decimal variable with character variable as follows:
DCL VAR(&INVNO1) TYPE(*CHAR) LEN(3) STG(*DEFINED) DEFVAR(&INVNO)
&INVNO is packed decimal WITH LENGTH 5, which occupies 3 bytes, so &INVNO1 is defined as a 3 byte character variable that overlays &INVNO
Now we can use this char variable & INVNO1 to call INVPRINT program instead of &INVNO as follows:
SBMJOB CMD(CALL PGM(INVPRINT) PARM(&INVNO1)) JOB(INVPRINT) JOBD(INVJOBD)
Similar topics
» Initialize Decimal data error field with zero
» File Zoned Decimal has been changed to Packed Decimal in RPG
» Compilation error
» Calling error
» Pointer error
» File Zoned Decimal has been changed to Packed Decimal in RPG
» Compilation error
» Calling error
» Pointer error
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|