PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Decimal data error – Scenario 1

View previous topic View next topic Go down

Decimal data error – Scenario 1

Post  maran on Sat Jun 04, 2016 10:25 pm

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)
avatar
maran
Admin

Posts : 442
Join date : 2009-07-24

View user profile http://pmsinformationsystem.forumotion.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum