Accumulate Item Shipped Quantities in C BSFN

fvlmasl2

Active Member
Hello All,

I have a C BSFN that needs to populates an Item Array and accumulate Item totals, sounds simple enough.....I will give a visual with an explanation.

Read From F4211:::
Item: Qty:
2760039 4
2760040 3
3740089 3
2760039 2
2760040 2
050077 1
810010 1
2520132 1
2760039 2

What the Array should look like after F4211 read completes:::
Array:
Item: Qty:
2760039 8
2760040 5
3740089 3
050077 1
810010 1
2520132 1

I just cant seem to get this to work, doesn't need to be an array. Just need an efficient means of accumulating those with multiple records.

Thanks in advance,
fvlmasl2
 

BOster

Legendary Poster
What isn't working? You may need to post your code to get a meaningful answer. You may also want to look into the JDEBASE aggregate API. You could effectively do:

Code:
select sditm, sum(sduorg), count(sddoco)
from f4211 
where xxxxxxx 
group by sditm

The returned recordset would effectively become an "array" and may be all you need if you only need to scroll forward through the results once. If you need to store the result in memory you can use the LINKLIST api, the JDECACHE api or you could also store via jdeAlloc in an array but you are probably better off with a linked list (if array lifetime is limitted to the function call) or jdeCache (if the lifetime of the array needs persist across multiple function calls).
 

fvlmasl2

Active Member
Well, after many iterations, I can't seem to get this to work as I think it should....below I have the snippet of what I'm trying to do....this is one of many versions I've played with....its more of just getting something on paper to work through. But it should give an idea of what we're attempting.

SEE THE FOLLOWING POST FOR SNIPPET....

Thanks
 
Last edited:

fvlmasl2

Active Member
This is what I attempted to post earlier:::: The &mnProArray should be the result of processing through &mnItemArray. This code snippet is just to put something on paper to work through, I realize the indexing is off....
 

Attachments

  • SampleCode.jpg
    SampleCode.jpg
    12.9 KB · Views: 23

JMR

VIP Member
I don't fully understand your looping logic, but it would be helpful if you showed how you're defining your arrays and the actual output you are getting.

Brian suggested probably the best the option: use the JDEDB api. If you're unfamiliar with its use or just never used it, I understand the apprehension of going that route. However, it would be a great exercise for you to learn that tool... it can be a very handy one to have in your knowledge base for future endeavors.

If you would like to investigate this approach, I would search the existing code base for occurrences of JDB_SetGroupBy and JDB_FetchAggregate. If you find an existing function using both of those api's, you should get a good example of their usage.

Since I don't fully understand your looping logic, here is a suggestion that simplifies it IMO:

Code:
nMaxItems = 0;
for loop
   bFound = false;
   vPas = 0
   while (vPas < nMaxItems && !bFound )
      if( math compare() == 0 )
         bFound = true;
      else
         vPas++;
   end while

   if bFound
      accumulate totals
   else
      add to array
      nMaxItems++;
 

fvlmasl2

Active Member
Thank you for your suggestions, I have been thrown into learning JDE C for a variety of projects that cannot be achieved by normal IV or UBE programming.

Again, Thank you.....
 

BOster

Legendary Poster
Thank you for your suggestions, I have been thrown into learning JDE C for a variety of projects that cannot be achieved by normal IV or UBE programming.

Once you learn JDE C you will realize you can do a lot more than with ER code alone and do it in a lot more organized, reusable, maintainable, and extensible way. I would suggest that you spend some time just learning plain C outside the context of JDE. A solid grasp of the core concepts of C and the language constructs is a must.
 

fvlmasl2

Active Member
I'm finding out the power of C is awesome for numerous tasks......I wish I could devote more time to learning and not be under the gun for project completion....Having said that...one more question and I'll put this thread to bed....How can I setup a partial key for data retrieval? For example, if I needed to retrieve ALL of a specific item from the F4102, I don't have an index of just item? I know this is simple and I've looked but I can't seem to find a good example...

Thanks again,
fvlmasl2
 
Last edited:

fvlmasl2

Active Member
Thank you for the reply, I just used the F4102 as an example. We have times when a partial key is used\required for some table reads. I was asking for partial key setup and table access within a C BSFN.
 
Top