Gary P
Active Member
Hello Listers,
What/Why:
I'm working on some modifications for Supply and Demand, where the user wants me to add new columns and fill them based on various tables (e.g. URAB, EMCU, RORN, DSC2). For us, this application is taking too long as it is, so performance is very important. Thus, rather than looking through the record, determine which table to look through, and look through that, I want to simply pull the columns the first time I go through the relevant tables. I've modified the supply and demand cache/data structure that is used to hold the records before they're written to the grid, and now I just need to go to each table fetch, pull the columns I'm now using, and write the code to put those new fields into the cache data structure.
Problem:
What I'm stuck on now is a particular fetch. When the F4211 is searched, it returns a data structure with the data fetched. For the example I'm on, a JDB_SelectKeyed is used on index 6 (itm, mcu, ppdj, pdtt) and JDB_Fetch commands are used to retrieve the data. To retrieve the additional desired fields, all I have to do is add them to the data structure. However, when I tried to add the columns, I noticed the order doesn't match what's in the table definition.
Here's the code for the data structure:
<font class="small">Code:</font><hr /><pre>
typedef struct
{
JCHAR sdkcoo[6];
MATH_NUMERIC sddoco;
JCHAR sddcto[3];
MATH_NUMERIC sdlnid;
JCHAR sdmcu[13];
MATH_NUMERIC sdan8;
MATH_NUMERIC sdshan;
JDEDATE sdpddj;
MATH_NUMERIC sditm;
JCHAR sdlocn[21];
JCHAR sdlotn[31];
JCHAR sdlnty[3];
JCHAR sdnxtr[4];
JCHAR sduom[3];
MATH_NUMERIC sduorg;
MATH_NUMERIC sdsocn;
MATH_NUMERIC sdqtyt;
JCHAR sdxdck;
MATH_NUMERIC sdxpty;
MATH_NUMERIC sdprjm;
JCHAR sdxkco[6];
MATH_NUMERIC sdxorn;
JCHAR sdxcto[3];
MATH_NUMERIC sdxlln;
JCHAR sdxsfx[4];
} DSF4211B3400310SO, FAR *LPDSF4211B3400310SO;
</pre><hr />
And here's the first 15 fields from the table definition:
<font class="small">Code:</font><hr /><pre>
JCHAR sdkcoo[6]; /* 0 to 11 */
MATH_NUMERIC sddoco; /* 12 to 60 */
JCHAR sddcto[3]; /* 61 to 66 */
MATH_NUMERIC sdlnid; /* 67 to 115 */
JCHAR sdsfxo[4]; /* 116 to 123 */
JCHAR sdmcu[13]; /* 124 to 149 */
JCHAR sdco[6]; /* 150 to 161 */
JCHAR sdokco[6]; /* 162 to 173 */
JCHAR sdoorn[9]; /* 174 to 191 */
JCHAR sdocto[3]; /* 192 to 197 */
MATH_NUMERIC sdogno; /* 198 to 246 */
JCHAR sdrkco[6]; /* 247 to 258 */
JCHAR sdrorn[9]; /* 259 to 276 */
JCHAR sdrcto[3]; /* 277 to 282 */
MATH_NUMERIC sdrlln; /* 283 to 331 */
</pre><hr />
Now, I believe that in order to properly retrieve the additional fields I want, I need to add them properly to the data structure. That is, I can't just tack the fields on to the end - I need to place them in the correct memory locations relative to the beginning of the structure.
Can anyone provide any assistance as to how I would add those fields and in what order? Since the column order in the cache doesn't match the column order in the table definition, I don't know where to look.
Thanks,
Gary
What/Why:
I'm working on some modifications for Supply and Demand, where the user wants me to add new columns and fill them based on various tables (e.g. URAB, EMCU, RORN, DSC2). For us, this application is taking too long as it is, so performance is very important. Thus, rather than looking through the record, determine which table to look through, and look through that, I want to simply pull the columns the first time I go through the relevant tables. I've modified the supply and demand cache/data structure that is used to hold the records before they're written to the grid, and now I just need to go to each table fetch, pull the columns I'm now using, and write the code to put those new fields into the cache data structure.
Problem:
What I'm stuck on now is a particular fetch. When the F4211 is searched, it returns a data structure with the data fetched. For the example I'm on, a JDB_SelectKeyed is used on index 6 (itm, mcu, ppdj, pdtt) and JDB_Fetch commands are used to retrieve the data. To retrieve the additional desired fields, all I have to do is add them to the data structure. However, when I tried to add the columns, I noticed the order doesn't match what's in the table definition.
Here's the code for the data structure:
<font class="small">Code:</font><hr /><pre>
typedef struct
{
JCHAR sdkcoo[6];
MATH_NUMERIC sddoco;
JCHAR sddcto[3];
MATH_NUMERIC sdlnid;
JCHAR sdmcu[13];
MATH_NUMERIC sdan8;
MATH_NUMERIC sdshan;
JDEDATE sdpddj;
MATH_NUMERIC sditm;
JCHAR sdlocn[21];
JCHAR sdlotn[31];
JCHAR sdlnty[3];
JCHAR sdnxtr[4];
JCHAR sduom[3];
MATH_NUMERIC sduorg;
MATH_NUMERIC sdsocn;
MATH_NUMERIC sdqtyt;
JCHAR sdxdck;
MATH_NUMERIC sdxpty;
MATH_NUMERIC sdprjm;
JCHAR sdxkco[6];
MATH_NUMERIC sdxorn;
JCHAR sdxcto[3];
MATH_NUMERIC sdxlln;
JCHAR sdxsfx[4];
} DSF4211B3400310SO, FAR *LPDSF4211B3400310SO;
</pre><hr />
And here's the first 15 fields from the table definition:
<font class="small">Code:</font><hr /><pre>
JCHAR sdkcoo[6]; /* 0 to 11 */
MATH_NUMERIC sddoco; /* 12 to 60 */
JCHAR sddcto[3]; /* 61 to 66 */
MATH_NUMERIC sdlnid; /* 67 to 115 */
JCHAR sdsfxo[4]; /* 116 to 123 */
JCHAR sdmcu[13]; /* 124 to 149 */
JCHAR sdco[6]; /* 150 to 161 */
JCHAR sdokco[6]; /* 162 to 173 */
JCHAR sdoorn[9]; /* 174 to 191 */
JCHAR sdocto[3]; /* 192 to 197 */
MATH_NUMERIC sdogno; /* 198 to 246 */
JCHAR sdrkco[6]; /* 247 to 258 */
JCHAR sdrorn[9]; /* 259 to 276 */
JCHAR sdrcto[3]; /* 277 to 282 */
MATH_NUMERIC sdrlln; /* 283 to 331 */
</pre><hr />
Now, I believe that in order to properly retrieve the additional fields I want, I need to add them properly to the data structure. That is, I can't just tack the fields on to the end - I need to place them in the correct memory locations relative to the beginning of the structure.
Can anyone provide any assistance as to how I would add those fields and in what order? Since the column order in the cache doesn't match the column order in the table definition, I don't know where to look.
Thanks,
Gary