7 Understanding JD Edwards EnterpriseOne Defined Structures

This chapter contains the following topics:

Oracle's JD Edwards EnterpriseOne provides two data types that should concern you when you create business functions: MATH_NUMERIC and JDEDATE. Since these data types might change, use the Common Library APIs provided by JD Edwards EnterpriseOne to manipulate them. Do not access the members of these data types directly.

7.1 MATH_NUMERIC Data Type

The MATH_NUMERIC data type is commonly used to represent numeric values in JD Edwards EnterpriseOne software. This data type is defined as follows:

struct tag MATH_NUMERIC

{
   ZCHAR String [MAXLEN_MATH_NUMERIC + 1];
   BYTE  Sign;
   ZCHAR EditCode;
   short nDecimalPosition;
   short nLength;
   WORD  wFlags;
   ZCHAR szCurrency [4];
   Short nCurrencyDecimals;
   short nPrecision;
};

typedef struct tag MATH_NUMERIC MATH_NUMERIC, FAR *LPMATH_NUMERIC;

This table shows math-numeric elements and their descriptions:

MATH_NUMERIC Element Description
String The digits without separators
Sign A minus sign indicates the number is negative. Otherwise, the value is 0x00.
EditCode The data dictionary edit code used to format the number for display
nDecimalPosition The number of digits from the right to place the decimal
nLength The number of digits in the String
wFlags Processing flags
szCurrency Currency code
nCurrencyDecimals The number of currency decimals
nPrecision The data dictionary size

When assigning MATH_NUMERIC variables, use the MathCopy API. MathCopy copies the information, including Currency, into the location of the pointer. This API prevents any lost data in the assignment.

Initialize local MATH_NUMERIC variables with the ZeroMathNumeric API. If a MATH_NUMERIC is not initialized, invalid information, especially currency information, might be in the data structure, which can result in unexpected results at runtime.

/*************************************************
 * Variable Definitions
 *************************************************/
   MATH_NUMERIC   mnVariable  = {0};

/************************************************
 * Main Processing
 ************************************************/
   ZeroMathNumeric( &mnVariable );
   MathCopy( &mnVariable,
             &lpDS->mnVariable );

7.2 JDEDATE Data Type

The JDEDATE data type is commonly used to represent dates in JD Edwards EnterpriseOne. The data type is defined as follows:

struct tag JDEDATE
{
   short nYear;
   short nMonth;
   short nDay;
};

typedef struct tag JDEDATE JDEDATE, FAR *LPJDEDATE;
JDEDATE Element Description
nYear The year
nMonth The month
nDay The day

7.2.1 Using Memcpy to Assign JDEDATE Variables

When assigning JDEDATE variables, use the memcpy function. The memcpy function copies the information into the location of the pointer. If you use a flat assignment, you might lose the scope of the local variable in the assignment, which could result in a lost data assignment.

/****************************************************
 * Variable Definitions
 ****************************************************/
   JDEDATE   jdToDate;
/****************************************************
 * Main Processing
 ****************************************************/
   memcpy((void*) &jdToDate,
          (const void *) &lpDS->jdFromDate,
          sizeof(JDEDATE) );

7.2.2 JDEDATECopy

You can use JDEDATECopy, as well as memcpy, to assign JDEDATE variables. The syntax is as follows:

#define JDEDATECopy(pDest, pSource)
        memcpy(pDest, pSource, sizeof(JDEDATE))