Has IBM Changed the Packed Decimal structure when using a PF file

One of the problems I was struggling with earlier this week was the use of a Database file which stores control data for the auditing process.  I was under the impression that when declaring the file within the C program, the compiler automatically created a character array for any Packed Decimal fields within the file?  I have reviewed code which supported this view and I am still confused as it still works as object code? New compiles complain however that I cannot assign a decimal value to character string!

Here is a code snippet which is used to include a database file within the application program.

#pragma mapinc("jrncfg","*LIBL/JRNCFG(JRNREC)","both","_P","","DATA_F")
#include "jrncfg"
typedef DATA_F_JRNREC_both_t JRNREC;
#define _JREC sizeof(JRNREC)

This will have the compiler automatically generate a structure which is mapped to the fields within the file. I simply have to declare the file within the program as below to use the structure.

JRNREC JrnRec;

To read data into the file I simply open the file and read its contents passing the structure as the holder and then I can address each element of the file record.

_RFILE fp;
_RIOFB_T fdbk;
JRNREC JrnRec;
int Last_Apy;

if((fp =_Ropen("JRNCFG","rr+")) == NULL) {
   printf("Unable to open filen");
   exit(-1);
   }
fdbk = _Rreadf(fp,&JrnRec,_JREC,__DFT);
if(fdbk->num_bytes != _JREC) {
   printf("Record not readn");
   _Rclose(fp);
   exit(-1);
   }
Last_Apy = (int)JrnRec.LSTAPY;

The Last Applied record is defined as Packed Decimal 5.0 in the file and is now defined within the data structure as a decimal(5,0). Previously it was defined as a character array big enough to hold the data and I had to use the QXXPTOI API to convert the data correctly. The new method is obviously a lot cleaner and will be easier to use that having to call the QXXPTOI API everytime. The problem now is that I have to ensure any old code which did use the QXXPTOI to convert the field values is corrected before I use it again. Its not everyday I use the above process so I am not sure when it came into effect?
Anyone shed any light on when it changed?

Chris…

One thought on “Has IBM Changed the Packed Decimal structure when using a PF file”

  1. I have not noticed any change in the look of a packed field in a file.
    Perhaps the C compiler has changed some to do what you are seeing.

    In one of my previous lives, as a PSR, I ran across problems at times where the system, or compiler, ‘fixed a problem’ that people had been coding around. It was usually a result of someone submitting an APAR (do they still call it that) identifying the way it originally worked as a problem.

    It is possible that is what you are seeing. But that is just a guess.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.