Ok, this has been bugging me for a long time and I finally decided to ask someone about it. It has to do with numeric field definitions in programs.
I always try to define my variables based on fields from an external file for the obvious reasons. The problem I am running into is that fields definied as zoned numeric in the file are being defined in the program as packed.
For example:
I have a file with two zoned fields.
In my program, I want to define the input parameters based on those fields... like so:
So I would expect those fields to be zoned as well.
When I try to call this routine though I get decimal data errors because those fields are actually defined as packed.
When I look at the compiler listing I see the following:
Here is the input buffer
Everything is zoned. Thats nice.
Here is the cross reference listing.
Now that I am starting to prototype things this is getting to be a pain in the butt because I declare the prototyping parms as subfields in a data structure so that they can be based upon a file. Like so:
In this case, the LIKE statement works correctly and declares OrderNumber as Zoned. Unfortunately, the field I attempt to do the call with has been incorrectly defined by the compiler as packed.
As a result, data decimal errors.
Can anyone explain this to me? Thanks a bunch
I always try to define my variables based on fields from an external file for the obvious reasons. The problem I am running into is that fields definied as zoned numeric in the file are being defined in the program as packed.
For example:
I have a file with two zoned fields.
Code:
Data Field Buffer Buffer Field Column Field Type Length Length Position Usage Heading CMORD# ZONED 6 0 6 1 Both CMORD# Field text . . . . . . . . . . . . . . . : Order # CMSUF# ZONED 2 0 2 7 Both CMSUF# Field text . . . . . . . . . . . . . . . : Suffix CMLNUP ZONED 2 0 2 9 Both CMLNUP Field text . . . . . . . . . . . . . . . : Line-up
Code:
*--------------------------------------------------------------- * Standalone variables. *--------------------------------------------------------------- * Entry parameters. D P_Order# S LIKE(CMORD#) D P_Suffix# S LIKE(CMSUF#)
When I try to call this routine though I get decimal data errors because those fields are actually defined as packed.
When I look at the compiler listing I see the following:
Here is the input buffer
Code:
000002=I S 1 6 0CMORD# Order # 000003=I S 7 8 0CMSUF# Suffix
Here is the cross reference listing.
Code:
CMORD# P(6,0) 004400 6000002D 006700 007300 ... CMSUF# P(2,0) 004500 6000003D 006800 007400 ... P_ORDER# P(6,0) 004400D 006300 008200M 012800 ... P_SUFFIX# P(2,0) 004500D 006400 008300M 012900
Now that I am starting to prototype things this is getting to be a pain in the butt because I declare the prototyping parms as subfields in a data structure so that they can be based upon a file. Like so:
Code:
* File definitions used for parm definitions. D OHFile E DS QUALIFIED EXTNAME(OHP) D O3File E DS QUALIFIED EXTNAME(O3) D O4File E DS QUALIFIED EXTNAME(O4P) D PCFile E DS QUALIFIED EXTNAME(PCP) *--------------------------------------------------------------- * ChkMfgHold routine. * This routine is used to check if an order is on * manufacturing hold. * * Input Parameters: * Order Number * Return Parameter: * Indicator: *ON: order is on mfg hold * *OFF: order can be released *--------------------------------------------------------------- ChkMfgHold PR N OrderNumber LIKE(OHFile.OHORD#) CONST
As a result, data decimal errors.
Can anyone explain this to me? Thanks a bunch
Comment