|
>Now, after I'm done manipulating the date,
>I need to move it to a database field that
>is defined as packed 8,0. I keep getting the
>compile error 'The types of the right and left
>hand side do not match in the EVAL operation'.
>What's the trick?
Unfortunately, RPG IV currently has no BIF to convert a Date variable back
to a Numeric variable.
Various techniques can be used:
- use %SUBDT repeatedly to unpick each element of the Date and use
arithmetic (addition and multiplication) to recombine the elements into a
Numeric variable - <yuk>
NumField = (%Subdt(DateField:*Y) * 10000) +
(%Subdt(DateField:*M) * 100) +
(%Subdt(DateField:*D));
- use %CHAR to convert the Date to a Character variable and have this
Character string overlayed in a Data
Structure with a Zoned Decimal subfield, (this could in turn be assigned as
required to your Packed field)
- use the %CHAR BIF in combination with the atol C-language function, along
the lines of:
// Access C runtme library through Binding Directory
H DftActGrp(*No) ActGrp(*New) BndDir('QC2LE')
// Prototype for C atol function
D AtoL PR 10I 0 ExtProc('atol')
D 20A Const Options(*Varsize)
D DateField S D Inz(*Sys) DatFmt(*Iso)
D Packed S 11P 0
/Free
Packed = AtoL(%Char(DateField:*Eur0));
I prefer the latter technique - but whatever you use encapsulate it in a
subprocedure of your own, as has been suggested.
Brian Parkins
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.