LIKE is Like, Confusing, Man!
December 4, 2002 Timothy Prickett Morgan
Hey, Ted:
IBM is doing it again, and I’m about to pop a vein. I’m getting a data decimal error in an RPG IV program when I access the contents of a data area subfield. The subfield is called PPLANT and it’s defined on the D spec with the LIKE keyword. PPLANT is based on a database file field named IPLANT, which is zoned.
D PlantDS ds D PPlant like(iplant)
|
The compiler listing shows IPLANT in the file input and output buffers as being in zoned-decimal format. However, the cross reference shows IPLANT as being in packed-decimal format. Since IPLANT is defined as packed, so is PPLANT. The data in the data area is passed as zoned from another program, so I need PPLANT to be defined as zoned.
Do you know what’s going on or have any solutions besides hard coding the subfield definition?
— John
With the help of IBM’s Barbara Morris, I have an answer for you.
File definitions, whether internally described with I specs or externally described with DDS or SQL, are not field definitions, but descriptions of data in an I/O buffer. When you define a database field as zoned, you are telling the compiler that the field is stored in a zoned format in the file. (In the case of a zoned field in a logical file, the data may be in some other format in the physical file, but the logical file presents it to the program in zoned format.) Note that you are not telling the compiler how the data should be stored in the computer’s memory while the program is running.
The compiler allocates space for each field of each file. If you define a storage format for a field, the compiler allocates the field according to your definition. The following line defines IPLANT as zoned:
D IPlant s 4s 0
But if you do not define a storage format for a field, the compiler uses a default storage format. For numeric fields, the default format is packed decimal. That is why you see IPLANT defined as packed decimal in the cross reference. When your program reads the file, the zoned-decimal value in the buffer is copied to a packed-decimal workspace for IPLANT.
To solve your problem, IBM recommends that you code an externally described data structure for the externally described file that contains IPLANT.
Fchfile uf e disk D ChFileDS e ds extname(chfile) D PlantDS ds D PPlant like(iplant)
The IPLANT field, which is found in file CHFILE, is zoned, so IPLANT is defined as zoned in data-structure CHFILEDS. Since PPLANT is defined to be like IPLANT, PPLANT is also zoned.
— Ted
Sponsored By CENTERFIELD TECHNOLOGY |
Do your iSeries batch jobs always finish before the results are needed by your business? IT departments are responsible for much more than just keeping the system running . . . they also must answer to financial, marketing, HR, and sales managers who need data analysis NOW. If there were a way for you to deliver the data much faster without going through the intricacies of re-configuring your batch jobs by hand, the expense of more CPU and memory capacity, and finding out how much difference the right tool makes without a lengthy evaluation, wouldn’t you do it? Click now to sign up! Centerfield Technology batch/ACCELERATOR Timely and accurate data analysis depends on large reports, check runs, consolidations, data warehouse extracts and the like–running in batch mode to avoid conflicts between complex, CPU-intensive processing and vital interactive functions. Today, vital interactive applications must be available more hours because of systems consolidations, constant web access, and worldwide operations spanning all 24 hours of every day. Increased data storage requirements, user access, and complexity are making high availability more and more difficult to achieve. Batch processes have become even more important, more resource intensive, and more time consuming. Even with the most powerful iSeries hardware, many shops are finding that batch jobs are taking longer while their batch windows are shrinking. The purpose of batch/ACCELERATOR is to help alleviate the pressure on system and application availability through the use of advanced, automated techniques to reduce batch job elapsed time. Centerfield Technology has developed batch/ACCELERATOR to speed this processing so that business users will get their data quicker, without affecting transaction performance. batch/ACCELERATOR is designed to address application and systems management challenges that include:
batch/ACCELERATOR is fully automated, does not require coding changes to applications, or changes to system configuration, and it adapts to processing changes without human intervention. Centerfield will even pre-configure batch/ACCELERATOR, through a unique data-collection process, so that you’ll barely have to lift a finger to substantially reduce the elapsed time of your most challenging batch processes. Give us a call right away if you have any questions or concerns . . 507-287-8119. |