Compiling RPG400 program

0 pts.
Tags:
Application development
AS/400
RPG
Hi I am trying to compile an RPG400 program which is using an os/400 file that was created by SQL (JDE Table), the problem i am having is that one field within the table is a "Packed Numeric" Field however it has a length of 31 this causes an error, error reads numeric field is greater than 30 digits. Is there any way around this problem, do i need to use a different RPG?
ASKED: June 29, 2007  12:58 AM
UPDATED: June 29, 2007  4:07 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi

Changing the source type to SQLRPGLE won’t make any difference, but there is a way you can program around it.

Within your program define the file as being internally described and then use the old fashioned “I” specs to describe the record layout using from and to positions.

When you get to the field that’s giving the problem define the first byte of the field as a single character field and the rest of the field as numeric packed.

What you are doing is effectively chopping off the leading two digits of the value making it a 29 digit packed field instead.

In your program you can check the contents of the single character field to see if it contains x’00′. If it does then the truncation made no difference, if it did then you have to work that into your value somehow (possibly by converting to a floating point value).

The code below shows an example of how this works…

FSqlTable IF F 66 Disk

D* Figurative Constants
D Null c Const(x’00′)

I* File Layout
ISqlTable NS
I 1 10 Code
I 11 50 Description
I 51 51 HighByte
I 52 66 NumericVal

C* Read record from SQL Table
C Read(e) SQLTable
C If Not %Eof(SQLTable)

C* Check for truncation of numeric field…
C If HighByte <> Null
C* …packed value truncated…
C Else
C* …okay to use…
C EndIf
C EndIf

C* End program
C Eval *InLR = *On

All the best

Jonathan

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following