Decimal-data Error In Field In As400
Contents |
statements Oracle on iSeries File Sharing View All Integrated File System (IFS) iSeries Access (Client Access) iSeries managed email and decimal-data error occurred in as400 groupware NetServer Network File System (NFS) QNTC File System High what is decimal data error in as400 Availability View All Business Continuity High Availability Tools Replication IBM iSeries division news View All mch1202 error in as400 iSeries application development View All iSeries Application development tools iSeries CL programming iSeries COBOL programming iSeries ILE programming iSeries Java programming iSeries programming commands
How To Handle Decimal Data Error In Rpg
RPG iSeries programming Visual basic on iSeries iSeries backup and recovery View All Data backup, storage and retrieval on iSeries iSeries disaster recovery and business continuity Remote Journaling Restores Storage iSeries database management View All DB2 UDB (universal databases) iSeries SQL commands and statements Oracle on iSeries iSeries document output decimal data error in cobol 400 View All Imaging on iSeries Printing on iSeries Printing-Imaging Tools iSeries hardware management View All Grid Computing Logical Partitions (LPAR) On-demand Computing iSeries networking View All Connecting to Printers FTP Physical connections to iSeries Remote Access to iSeries TCP-IP VoIP iSeries security planning View All iSeries physical security iSeries system and application security Security Tools iSeries systems management View All Change Management Debugging i5-OS -- OS-400 iSeries Applications iSeries compliance and regulation iSeries service and support issues iSeries system performance and monitoring Multi-platform Integration Performance Server Consolidation Server Installation Server Pricing Systems Management Tools iSeries training and education View All iSeries job market iSeries skills User Groups iSeries upgrades and modernization View All Web Topics Archive View All iSeries Resources Please select a category File Sharing High Availability IBM iSeries division news iSeries application development iSeries backup and recovery iSeries database management iSeries document output
available for download here, and it has been updated since it originally ran [Updated 06/13/07] I have seen requests many times in the forums from programmers asking how best to handle data with invalid decimal data. Typically this type of error is first discovered when a program ends rpgle monitor decimal data error abnormally. I have found this problem occurs most often with data received from outside sources: customers and vendors. Many times this data comes from systems other than a System i. I've developed a command to identify and (optionally) "fix" errant data. What's in a Number? First, what is invalid decimal data? This is non-numeric data in a numeric field. For example, a field defined as "5s 0" should contain a number in the range of -99999 to +99999. The data is invalid if it http://search400.techtarget.com/answer/What-is-a-Decimal-Data-Error contains values such as ABCDE or 123A6. Of course in the case of a zoned-decimal field such as this one, it is acceptable for the last (and only the last) position to contain a value that appears to be alphabetic. This is because the last position of the field identifies the sign. To consider numeric values properly you must think in terms of the hexadecimal (hex) representation of the field. The first four bits of each byte are called the "zone" and the last http://www.itjungle.com/fhg/fhg061307-story01.html four bits the "digit". Values for each zone and digit can range from 0 to 9 and A to F for the values 0 to 15 in the base-16 (hexadecimal). The base-10 (decimal) numbers 0 to 9 are defined for zoned-decimal fields in hex as F0-F9, respectively. The last byte identifies the sign of the value. For this byte only, the zone portion can be either a C or F for positive values and a D for negative. The hex representation of the zoned-decimal value 123 stored in a "5s 0" field is: F0F0F1F2F3 or F0F0F1F2C3. Packed fields are stored differently. Normally packed fields have an odd length, such as "7p 0" or "9p 2". The physical length of the stored data is: (scale of field + 1) / 2. For example, a "7p 2" field is stored in (7 + 1) / 2 = 4 bytes. For packed fields each zone and digit contains a position of the value except for the right-most digit which contains the sign. If the number 123 is stored in a "5p 0" field, the hex value is 00123F or 00123C. Valid values for all zones and digits must be in the range 0-9, except for the last digit which must be F or C for positive values or D for negative. Identifying Errors How do we identify invalid data? This depends on the definition of the file fields. If a byte contains the hex value C1 (the letter "A") it would be val
download here. We have all encountered decimal data errors at some time or another. The biggest difficulty they present is that, by the time they have been detected, no recovery is possible. Or to http://www.itjungle.com/fhg/fhg031715-story01.html be more precise, no practical recovery is possible. In my previous tip, I mentioned that one of the benefits of data structure I/O is that you can avoid decimal data errors. In this tip I'm going http://www.rpgpgm.com/2015/04/coping-with-data-decimal-error-when.html to show you how and why that works. The code package associated with this tip contains three test programs that demonstrate the different scenarios. The first is a straightforward RPG program with no defenses. It reads data error a file in a loop and will encounter decimal data errors. The second is intended to show the basic use of DS I/O. It still has errors but they are subtly different. The third program demonstrates how to extend the program to fully defend against such errors. See the Readme.txt file for instructions on how to install the source code on your system. One factor that adds to the difficulty of decimal data error handling data decimal errors is that that they may occur on a READ or CHAIN operation, making it difficult to determine exactly which field is in error. This happens because the system detects the error while moving the data from the buffer to the internal variable. When we use DS I/O, the entire record is moved as if it were a large character field. In other words the numeric data is not differentiated. Since numeric fields are not differentiated they can't cause errors! Let's walk through the process of running each of the three programs so that you can see the differences between them. First, here are relevant portions of program DATAERRS1. FBadData IF E DISK DoU %EOF(BadData); Read BadData; If %EOF(BadData); Leave; EndIf; records += 1; total += amount; date = %Date(numDate: *YMD); EndDo; If you run this program, you will receive an error when reading the second record. Using F1 to look at the actual details of the error reveals that it occurred on one of the compiler-generated lines associated with the READ. This is even more obvious when you run the program in debug. If you tell the program to go (option G) you will find a similar error occurs on the reading of the third record. In both
April 29, 2015 Coping with data decimal error when read file I am sure we have experienced running a program when it errors with "Decimal-data error occurred", RNQ0907. After analyzing the program I would find that the error is caused by bad data in a field in the input file. Yes, I will correct the bad data, but I might want to have the program continue using a default value and create a dump that can be used for analysis later. Examples of creating dumps can be found in the post: Producing a dump from programs. How can I flag the record as having an error, give the numeric field a default value, and continue processing? First let's start with our file, TESTFILE. It contains two fields, see below: The program will only error if the field containing the bad data is used. A R TESTFILER A FLD1 3P 0 A FLD2 5A I put blanks into FLD1, the numeric field, of the second record of the file: FLD1 FLD2 1 ONE TWO 3 THREE All I am going to do is to create simple RPG program to read TESTFILE and output to the display, using RPG's DSPLY operation code, the values of the two fields, see below. If you are not familiar with all free RPG line 1 denotes that TESTFILE is being for only input. 01 dcl-f TESTFILE ; 02 dow (1 = 1) ; 03 read TESTFILER ; 04 if (%eof) ; 05 leave ; 06 endif ; 07 dsply ('Record = ' + %char(FLD1) + ' ' + FLD2) ; 08 enddo ; 09 *inlr = *on ; Which when I run this program the output will be: DSPLY Record = 1 ONE Decimal-data error occurred (C G D F). I can take the option "D" to create a dump, and the program ends. If I did not need FLD1 I would just remove it from line 7, see below. Now when the program runs it does not error as FLD1 is not used. 07 dsply ('Record = ' + FLD2) ; So what approaches are there to stop the program erroring and continue? The first approach I tried was using the *PSSR subroutine. This subroutine is only executed when an error occurs, any error. It is just coded like any other subroutine, the only difference is the second parameter with the ENDSR operation code, line 14. 01 dcl-f TESTFILE ; 02 dow (1 = 1) ; 03 read TESTFILER ; 04 if (%eof) ; 05 leave ; 06 endif ; 07 dsply ('Record = ' + %char(FLD1) + ' ' + FLD2) ; 08 enddo ; 09 dsply ('End of pgm') ; 10 *inlr = *on ; 11 begsr *PSSR ; 12 dump(a) ; 13 dsply ('Oh no! I am in *PSSR') ; 14 endsr '*CANCL' ; I