|
Hi all, To continue with my earlier mail I understand the meaning of packed decimal when compared to zoned as Packed decimal means N X 2 - 1 where "N" stands for length as an example 6p(2) will accommodate 6 X 2 - 1 = 11 length out of which two are decimal values , where as 6S(2) zoned has only a value of six length out of which two are decimal 1) When I try to define the fields in RPGLE Packed1 S 11P 2 INZ(123456789) Zoned1 S 11S 2 INZ(123456789) I could able to initialize only up to nine length if I define more than nine I have an error "Length of initial value exceeds size of field" when I display by calling the program them I have 12345678900 (Zeros added as decimal values in the end) If I calculate 11P2 should accommodate a length of 11 X 2 - 1 = 21 length Then Eval Packed1 = 123456789112345678921 and run the program I have the below error " The target for a numeric operation is too small to hold the result (C G D F)" , the same case when I define the field in data structure also 2) But the case is different in RPG when I define a field for 11P(2) the I have PAKED1 = 4040404040404040404.04 whole 21 length 3) when I define fields below for a physical file as below A R REC1 A FLD1 11P 2 A FLD2 11 2 A FLD3 11S 2 The when I try to update the file DFU the for all the three fields it allows me only eleven length only and when I query have the below value's. FLD1 FLD2 FLD3 123,456,789.11 333,333,333.33 444,444,444.44 Same case when I try to write a program in RPG and RPGLE and try to add values to fld1, fld2 & fld3 the fields accommodate only eleven length and out of which two are decimal values. Mike, you are true if I define the external file2 with "PACKED" field as Zoned then you have the true value but your data structure length and position changes and there are lot of packed fields in the data structure I need to change all of them and more over the data structure values are passed to a data queue and the receiving program does some validations and postings, so this would be whole work around to the receiving & sending and need to see after modifications if the postings would be true or the earlier Values were only posted properly .........): Kim, File2 is extensively used for only to define for external data structure field purpose only Thanks Sadiq -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of MD, Sadique Sent: Thursday, August 25, 2005 2:52 PM To: RPG programming on the AS400 / iSeries Subject: Data structure gets populated for a junk value Hi all, I have File1 defined as below A R REC1 A FLD1 11P 2 File2 defined as below A R REC1 A PACKED 11P 2 A NUM 4S 0 I have a RPG program as below The value in File1/Fld1 = 131313123.12 FFILE1 IF E DISK IDS EIDSFILE2 C READ FILE1 80 C *IN80 DOWEQ*OFF C Z-ADDFLD1 PACKED C DS DSPLY C READ FILE1 80 C ENDDO * C SETON LR 1) The problem is the data structure "DS" is populated with Junk value 2) When I debug I could see the data structure "DS" has only length of six For Packed and length of four for Num , while the length provided for PACKED in data structure should have been eleven when I execute Eval PACKED (Or F11 key) on debug command line I have the correct value of File1/Fld1 = 131313123.12 in PACKED field too 3) If I look at the spool file the data structure has the below structure P 1 62PACKED 7 100NUM For "Num" the starting position should have been 12 15(0) Num The total length of the data structure "DS" is DS(10) The length should have been = 15 4) This problem exists in RPT, RPG, RPGLE , how ever I could over come the problem if I define exclusively in the data structure for positions 1 to 11(2) Zoned for "PACKED" field I am currently working on V5R3, could some one please help me on this Thanks Sadiq
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.