JDB_Fetch Issue

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
 
I just figured it out, but so this can be available for someone else to search, here's what I did.

In the JDB_OpenTable command for the table that is used in this select and fetch, it takes in an array of NID values, as well as the number of columns used. All I had to do was add the NIDs of the desired columns, adjust the count of columns sent in to the open table command to reflect the new columns I added, and then add the new data items to that data structure in the order of the NIDs I added.

To those who would have helped me, I appreciate your time.

Thanks,
Gary
 
The order of the fields in the DSTR for the business function does not have to be the same as the order of the DSTR for the table unless you are using a mem copy to copy the contents from one to the other.

Are you adding fields to the table data structure or the data structure for the business function (or cache)?
 
JDB Select Keyed Failed error in Crystal

I have one custom table in JDE F55XXXX and one report in crystal is based on the same table F55XXXX.

I have added one new column in F55XXXX in JDE. that new column is not reflecting in field explorer of the Crystal.

I did "refresh databse", "logon and Off server" & "Verify Databse" in crystal but not worth.

also that report is giving me the error JDB SelectKeyed Failed.

How to resolve this error...

Please Help....

I am using CRYSTAL Report RI X2 and JDE 811...

Regards,
Parag
 
Back
Top