E9.1 Max Number of Array Elements

FrankCLT

Well Known Member
Morning All,

For all you C BSFN developers out there, what is the maximum number of array element JDE allows?

array[???}

Thank you,
FrankCLT
 
For a simple array in C? There is not a defined fixed limit per se other than the maximum value of size_t.

Having said that you will probably run into stack memory issues long before you run into any compile type issues. What are you trying to store in the array and how many elements? You may be better off with some other data structure such as a dynamically sized array allocated on the heap, a linked list or jdeCache, etc.
 
For example, use the JDE jdeAlloc family of API's
C:
szDocTypeList = jderealloc(szDocTypeList, jdesizeof(dsF4111.ildct)*(nDocTypes+1));
 
Thank you for the reply. I am trying to store SHAN and DOCO for some sales analysis. The user will have a processing option to be able to limit the number of orders to pull for analysis.

So let’s say the user selects 3 orders for a for a given time period but that SHAN has 20 orders and 40 lines of detail for the time period.

I would like to store 3 orders for that SHAN which might be 15 lines of data.

I can possible do that in a report with level breaks and counters, but that would be extremely slow. I thought using an array would speed things up for the data pull and the report would then take no time at all….
 
And you are correct, I played with having over 999 elements it will compile, but when you run it and hit that maximum, stack overflow error.
 
I will post a price of code I’ve used before that works well for accumulating values looping through an array.
 
This is a piece of code I've used in the past for accumulating totals, in this example for Items within an order. Never had an issue with this, but never came close to the maximum 999 array elements.


bFound = FALSE;
x = 0;
while (x < y && !bFound )
{
if (jdestrcmpwithnull(aOrdDetailA[x].szIdentifier2ndItem, dsF4211.sdlitm)==0)
{
bFound = TRUE;
}
else
{
x++;
}
}
if (bFound)
{
/* exists in array - accumulate totals */
MathAdd(&aOrdDetailA[x].mnUnitsQuantityShipped, &aOrdDetailA[x].mnUnitsQuantityShipped, &dsF4211.sdsoqs);
MathAdd(&aOrdDetailA[x].mnAmountOrderGross, &aOrdDetailA[x].mnAmountOrderGross, &dsF4211.sdaexp);
}
else
{
/* does NOT exist in array - copy to array */
MathCopy(&aOrdDetailA[x].mnAddressNumber, &dsF4211.sdan8);
jdeStrncpy(aOrdDetailA[x].szIdentifier2ndItem, dsF4211.sdlitm, DIM(aOrdDetailA[x].szIdentifier2ndItem));
jdeStrncpy(aOrdDetailA[x].szSalesReportingCode3, dsF4211.sdsrp3, DIM(aOrdDetailA[x].szSalesReportingCode3));
MathCopy(&aOrdDetailA[x].mnUnitsQuantityShipped, &dsF4211.sdsoqs);
MathCopy(&aOrdDetailA[x].mnAmountOrderGross, &dsF4211.sdaexp);
y++;
}
 
BOster, in your example, "szDocTypeList = jderealloc(szDocTypeList, jdesizeof(dsF4111.ildct)*(nDocTypes+1));" not sure how this works or how I would access the elements in a manner of how I did in my example.

Thank you,
FrankCLT
 
BOster, in your example, "szDocTypeList = jderealloc(szDocTypeList, jdesizeof(dsF4111.ildct)*(nDocTypes+1));" not sure how this works or how I would access the elements in a manner of how I did in my example.

Thank you,
FrankCLT
That wasn't my example.

However based on the other posts in this thread the best data structure to use would be jdeCache. You can think of it as a dynamically expanding array and using the jdeCache API it will handle all the memory stuff for you. For what you are describing it can also do some other things for you like automatically filter out duplicates, etc. (just call jdeCacheAdd and ignore the return error indicating you are trying to add a duplicate... I use it for this exact purpose all the time).

Also. You shouldn't be running into stack related memory issues with only 999 elements unless the elements are huge... which I doubt it is. You have some other issue going on.
 
Last edited:
Thank you....Not having used Cache in this way, is there a JDE app the I can use as a template to review on how I can piece this together? I have done a search and seen samples, but having a problem putting the pieces together to make it all work.

Thank you,
FrankCLT
 
Hi All,

First off, I'd like to thank everyone for their input, it is truly appreciated. I have looked at the B3101570 and I'll be honest, I do get some of the C concepts as related to array processing as in my above example (several posts up). But the cache processing in B3101570 as simple as this may seem for some, for me, not getting the concepts and simply coping code without understanding why\what I'm doing will not work well for me. I will keep looking for some tutorials that may help in a conceptual way for a better understanding.

But again, thank you all for the input.

FrankCLT
 
Hi All,

First off, I'd like to thank everyone for their input, it is truly appreciated. I have looked at the B3101570 and I'll be honest, I do get some of the C concepts as related to array processing as in my above example (several posts up). But the cache processing in B3101570 as simple as this may seem for some, for me, not getting the concepts and simply coping code without understanding why\what I'm doing will not work well for me. I will keep looking for some tutorials that may help in a conceptual way for a better understanding.

But again, thank you all for the input.

FrankCLT
You could do the same thing that jdeCache does with a work table BTW. So if you are not comfortable with JDE C/jdeCache at this point you could effectively implement the exact same logic using a work table.
 
Back
Top